Как получить поля JIRA из заданий Дженкинса - PullRequest
0 голосов
/ 17 октября 2019

Я установил плагин jira-trigger в Jenkins, и я установил плагин Jenkins в Jira. Я могу вызвать задание jenkins, но мне нужно использовать значение настраиваемых полей JIRA, указанное в билете jira в сработавшем задании Jenkins. Я присоединяю конфигурацию JIRA к заданию Jenkins и моему сценарию конвейера.

enter image description here

Pipeline:

pipeline {
        environment {
             UI_PATH = '/opt/app/home/nginx/DTDM'
             BACKEND_PATH = '/opt/app/home/dot_deploy/TDM/mxExpressApp'
        }  
        parameters {
            string(name:'JENKINS_PARAMETER', defaultValue: JENKINS_PARAMETER)
            string(name:'ISSUE_KEY', defaultValue: ISSUE_KEY)
        }
        agent {
            label 'master'
        } 
        stages {
            stage('code Commit'){
                steps {
                    echo "${env}"
                    echo "Code Commited by Developer"
                    echo "${JENKINS_PARAMETER}"
                    echo "${ISSUE_KEY}"
                }

            } 

            stage('JFM Transition Change') {
                steps {
                    script {
                        withEnv(['JIRA_SITE=JFM']) {  
                            def transitionInput = [transition: [id: '61'] ]
                            jiraTransitionIssue idOrKey: "${ISSUE_KEY}", input: transitionInput
                        }
                    }
                }
            }   

            stage('Deployment') {

                steps {
                    script {
                        try {
                            echo "Success"
                            currentBuild.result = 'SUCCESS'
                        }
                        catch (Exception err) {
                            currentBuild.result = 'FAILED'
                        }   
                    }
                }
            }
            stage('JFM Transition Update') {
                parallel {
                    stage ('Success Update'){   
                        when {
                            expression {
                                return currentBuild.result == 'SUCCESS'
                            }
                        }   
                        steps {
                            script {
                                withEnv(['JIRA_SITE=JFM']) {  
                                    def transitionInput = [transition: [id: '81'] ]
                                    jiraTransitionIssue idOrKey: 'MCE-3303', input: transitionInput
                                }
                                withEnv(['JIRA_SITE=JFM']) {  
                                    def comment = [ body: 'deployment Successful' ]
                                    jiraAddComment idOrKey: 'MCE-3303', input: comment
                                }
                            }
                        }
                    }   
                    stage('Failure Update') {
                        when {
                            expression {
                                return currentBuild.result == 'FAILED'
                            }
                        }       
                        steps {
                            script {
                                withEnv(['JIRA_SITE=JFM']) {  
                                    def transitionInput = [transition: [id: '151'] ]
                                    jiraTransitionIssue idOrKey: 'MCE-2017', input: transitionInput
                                }
                                withEnv(['JIRA_SITE=JFM']) {  
                                    def comment = [ body: 'deployment Failed' ]
                                    jiraAddComment idOrKey: 'MCE-2017', input: comment
                                }
                            }
                        }
                    }
                }   
            }
        }

    }   

Но значение дляJENKINS_PARAMETER и ISSUE_KEY дают ноль.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...