Search code examples
jenkins-pipelinejenkins-pluginsjirajenkins-cli

i want to change workflow status based on jenkins build with project name and status


I want to change workflow status based on jenkins build with project name and status. can anyone please help me out on this. I am able to do as below: with story-id

def transitionInput = [transition: [id: '41']]

jiraTransitionIssue idOrKey: 'MSDP-198', input: transitionInput, site:  'JIRA'

but I need to list story id based on project name and status


Solution

  • success { script {

                        def searchResults = jiraJqlSearch jql: "PROJECT = 'MSDP' and status = 'READY FOR STAGING DEPLOYMENT' and type = 'Story'", site: 'JIRA'
                        def issues = searchResults.data.issues
                            for (i = 0; i <issues.size(); i++) {
                        def result = jiraGetIssue idOrKey: issues[i].key, site: 'JIRA'
                        
                        def transitionInput = [transition: [id: '41']]                  
                        def statuses = jiraGetProjectStatuses idOrKey: 'MSDP', site: 'JIRA'
                        responce = jiraTransitionIssue idOrKey: issues[i].key, input: transitionInput, site: 'JIRA' 
                            }
                    }       
        } }