簡體   English   中英

jenkins 管道更新GitlabCommitStatus 不起作用

[英]jenkins pipeline updateGitlabCommitStatus not working

GITLAB_VERSION: GitLab 企業版 13.9.3-ee JENKINS_VERSION: 2.263.4

我已經創建了一個 jenkins 管道,它是由 gitlab 的變化觸發的,但它沒有更新 gitlab 狀態。

pipeline {
    agent any
    stages {
       stage('cloning from gitlab'){
           steps{
             git credentialsId: '7d13ef14-ee65-497b-8fba-7519f5012e81', url: 'git@git.MYDOMAIN.com:root/popoq.git'
               
           }
       }
       stage('build') {
          steps {
             echo 'Notify GitLab'
             updateGitlabCommitStatus name: 'Jenkins-build', state: 'pending'
             echo 'build step goes here'
          }
       }
       stage('echoing') {
           steps{
               echo "bla blaa bla"
           }
       }
       stage(test) {
           steps {
               echo 'Notify GitLab'
               echo 'test step goes here'
               updateGitlabCommitStatus name: 'Jenkins-build', state: 'success'

           }
       }
    }
 }

它在 gitlab 中沒有顯示任何管道,有什么建議嗎?

我認為您錯過了“選項”塊中的“gitlabBuilds”命令,該命令聲明了您將在構建中執行的步驟。

options {
    gitLabConnection('xxx-gitlab')
    gitlabBuilds(builds: ['step1', 'step2', 'step3'])
}

然后您可以使用“updateGitlabCommitStatus”引用這些步驟,但您最好使用“gitlabCommitStatus”命令,如下所示:

pipeline {
agent any
options {
    gitLabConnection('xxx-gitlab')
    gitlabBuilds(builds: ['step1', 'step2', 'step3'])
}
stages {
   stage('step1'){
       gitlabCommitStatus(name:'step1') {
       steps{
         git credentialsId: '7d13ef14-e', url: 'xxxxxxx'
       }
   }
   stage('step2'){
       gitlabCommitStatus(name:'step2') {
       steps{
         .......
       }
   }
}
pipeline {
agent {
    label 'agent_gradle'
}
options {
    gitLabConnection('Gitlab Jenkins integration API connection test')
    gitlabBuilds(builds: ['step1', 'step2'])
}
stages {
    stage('Build') {
        steps {
            gitlabCommitStatus(name: 'step1') {
                container(name: 'gradle') {
                    echo 'Building the application...'
                }
            }
        }
    }
    stage('Test') {
        steps {
            gitlabCommitStatus(name: 'step2') {
                container(name: 'gradle') {
                    echo 'Testing the application...'
                }
            }
        }
    }

}

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM