How to transition Jira Issue from one state to another when a reviewer click request changes in Pull request in Bitbucket?

Viewed 192

When a reviewer clicks request changes in pull request It should change transition of status in JIRA of a particular JIRA issue. I have used webhook in bitbucket repository and url generated in JIRA i.e https://automation.atlassian.com/pro/hooks/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. I have used Jenkins to integrate both Bitbucket and Jira using multibranch pipelines. My Jenkins code is below here.

pipeline {
agent any
stages {
    stage('Build') {
        steps {
            echo 'Getting Branch Info... '
            echo 'Executing on :: ' + env.GIT_BRANCH
        }
        post {
            always {
                jiraSendBuildInfo site: 'example.atlassian.net'
            }
        }
    }
    stage('Curl'){
        steps{
            echo "Making request to ashishrajbanshi70.atlassian.net"
            echo "Requesting ...."
            sh """curl -X POST -H 'Content-type: application/json' --data '{"issues":["${env.GIT_BRANCH}"]}'  https://automation.atlassian.com/pro/hooks/xxxxxxxxxxxxxxxxxxxxxxxxx"""
            echo "Done ..."
        }
    }
}

}

The problem here is when a reviewer 'changes request' in pull request of the repository than the webhook triggers every branch of multibranch job. The status of all the issues changes from one status to another but not the desired one. How can I change status of single issue?

0 Answers
Related