Releasing a Project?

Releasing a project?

For instance, if you are releasing more than one project and you want to create a release review jira issue, add Description, Fix version, comment on the issue with error message for a failure in the release process or close the issue, if release is successful. JIRA transitions for any given ticket can be found via this endpoint: /rest/api/2/issue/${issueIdOrKey}/transitions.

import static java.util.UUID.randomUUID

node {
  stage('Releasing A Project') {
    def issueKey
    try {
      def issue = [fields: [ project: [key: 'TESTPRO'],
                             summary: 'Release x.y.z Review',
                             description: 'Review changes for release x.y.z ',
                             issuetype: [name: 'Task']]]
      def newIssue = jiraNewIssue issue: issue
      issueKey =


      def newVersion = jiraNewVersion version: [ name: "new-fix-version-"+ randomUUID() as String,
                                                 description: 'desc',
                                                 project: 'TESTPRO']

      def updateIssue = [ fields: [ fixVersions: []]]                                              
      def response = jiraEditIssue idOrKey: issueKey, issue: updateIssue

      // Transition issue ID can differ based on the JIRA instance
      def transitionInput = [transition: [id: 31]]
      jiraTransitionIssue idOrKey: issueKey, input: transitionInput
      jiraAddComment idOrKey: issueKey, comment: "RELEASING SUCCESSFUL"
    } catch(error) {
      jiraAddComment idOrKey: issueKey, comment: "${BUILD_URL} ERROR WHILE RELEASING ${error}"
      currentBuild.result = 'FAILURE'