Skip to content

Instantly share code, notes, and snippets.

@GLips
Last active March 22, 2018 22:45
Show Gist options
  • Save GLips/05b2bfcd6093c4ef4aef777b512d8868 to your computer and use it in GitHub Desktop.
Save GLips/05b2bfcd6093c4ef4aef777b512d8868 to your computer and use it in GitHub Desktop.
Use Scriptrunner for JIRA Cloud to add the project's lead as a watcher
def issueKey = issue.key
def projectKey = issue.fields.project.key
def projectLead = get("/rest/api/2/project/${projectKey}").asObject(Map).body['lead']['key']
logger.info("Project lead: ${projectLead}")
// Docs for this endpoint: https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-issue-issueIdOrKey-watchers-post
def result = post("/rest/api/2/issue/${issueKey}/watchers")
.header('Content-Type', 'application/json')
.body("\"${projectLead}\"")
.asString()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment