How to send new issue notification to project owner/admin? (OD-1697)
Artur opened 2 years ago

For our public and open source projects we allow anybody to open a new issue. We want to make sure that an email notification will be sent to the project owner or/and admins about new issues, even if the Assignee field is empty. How can we accomplish that?

Also, I noticed you have set a default Assignee here. How can I set a default Assignee for each of our projects?

  • Artur commented 2 years ago

    Hi, I have just found this guide: https://docs.onedev.io/tutorials/issue/default-assignee and it works as expected. So part of my question is already solved.

    Now, I am still looking for a solution to get notification in case of an empty Assignee field.

  • Robin Shen commented 2 years ago

    Just subscribe to an issue query. For instance I subscribe to all issues opened:

    2023-12-22_12-30-01.png

  • Artur commented 2 years ago

    Thank you for response. But this approach is not a good solution for us.

    We have 334 projects imported from YouTrack and GitHub. We are slowly going through all of them to make sure owners/admins are set correctly and all other settings. But this takes time, especially that we have to do our normal development work.

    In the meantime, community users already started their activity on the projects migrated to 1dev. They submit new issues. I would like to make sure we did not miss anything new posted to the projects, even if the project is not fully configured yet and/or an issue has an empty Assignee.

    So, is there anyway, to send an email notification for any new issue to the project owner, even if the Assignee is empty?

  • Artur commented 2 years ago

    Actually, I have just noticed I can subscribe to All issues for all projects. This is a working temp solution. But it would be better if we could send notifications to the project owner.

  • Robin Shen commented 2 years ago

    This can be achieved with below approach:

    1. define a groovy script "watch_issues_for_project_owners":
    import io.onedev.server.OneDev
    import io.onedev.server.persistence.dao.Dao
    import io.onedev.server.persistence.SessionManager
    import io.onedev.server.model.*
    	
    def sessionManager = OneDev.getInstance(SessionManager.class);
    sessionManager.openSession();
    try {
    	for (user in OneDev.getInstance(Dao.class).query(User.class)) {
    		for (authorization in user.projectAuthorizations) {
    			if (authorization.role.owner) {
    				def personalizationOfProject = null;
    				for (personalization in user.issueQueryPersonalizations) {
    					if (personalization.project.equals(authorization.project)) {
    						personalizationOfProject = personalization;
    						break;
    					}
    				}
    				if (personalizationOfProject == null) {
    					personalizationOfProject = new IssueQueryPersonalization();
    					personalizationOfProject.project = authorization.project;
    					personalizationOfProject.user = user;
    				}
    				personalizationOfProject.queryWatchSupport.queryWatches.put("g:All", true);
    				OneDev.getInstance(Dao.class).persist(personalizationOfProject);
    			}
    		}
    	}
    } finally {
    	sessionManager.closeSession();
    }
    
    1. Create a ci job in any project to call this script. This can be done by adding a command build step simply running command @script:watch_issues_for_project_owners@
  • Robin Shen changed state to 'Closed' 2 years ago
    Previous Value Current Value
    Open
    Closed
issue 1/1
Type
Question
Priority
Normal
Assignee
Labels
No labels
Issue Votes (0)
Watchers (3)
Reference
OD-1697
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover