2017-04-04 804 views
0

我的環境是下一個:詹金斯:gitlabCommitStatus不工作

-Jenkins 2.46.1

-Gitlab插件1.4.5

-GitLab社區版8.14.3

我配置了多分支管道。我曾嘗試過:

pipeline { 
    agent any 
    options { 
     gitLabConnection('MY_GITLAB') 
     gitlabCommitStatus(name: 'jenkins') 
    } 
    triggers { 
     gitlab(triggerOnPush: true, triggerOnMergeRequest: true, branchFilterType: 'All') 
    } 
    stages { 

     stage("build") { 
      steps { 
       gitlabCommitStatus(name: 'build') { 
       withMaven(
          maven: 'maven3', // Maven installation declared in the Jenkins "Global Tool Configuration" 
          mavenSettingsConfig: 'MY_ID', // Maven settings.xml file defined with the Jenkins Config File Provider Plugin 
          mavenLocalRepo: '.repository') { 
           // Run the maven build 
           sh "mvn clean install" 
          } 
       }    
      } 
     } 

     stage("paralelo") { 
     steps { 
      parallel (
        phase1: { sh "echo phase1" }, 
        phase2: { sh "echo phase2" } 
        ) 
       } 
     } 
    } 
} 

它工作沒有錯誤,但我沒有看到提交狀態在我的Gitlab。沒有來自gitlab的production.log中的錯誤。

謝謝大家!

+0

您是否有多分支管道工作?因爲可能你正在尋找[this](https://github.com/jenkinsci/gitlab-plugin#git-configuration-for-multibranch-pipelineworkflow-jobs)配置 – Rik

回答

1

您需要將其包裝在gitlabBuilds(build: ["jenkins", "build"]) { }中。

這將傳達即將到來的狀態。請注意,該值需要與您在gitlabCommitStatus('..')中使用的完全相同。

佈局應該是:

checkout scm 
gitlabBuilds(builds: ["1.", "2.",..."n."]) { 
    gitlabCommitSTatus(name: "1.") { ... } 
    gitlabCommitSTatus(name: "2.") { ... } 
    ... 
    gitlabCommitSTatus(name: "n.") { ... } 
} 

的地方開始當然,你可以選擇任何你喜歡的,只要它在gitlabBuilds.builds值相匹配的名稱。

確保您的gitlabConnection工作正常。

+0

我現在已經這樣做了,但它並沒有工作: ... 選項{ gitLabConnection( 'MY_GITLAB') gitlabBuilds(構建:[ 「建立」, 「paralelo」]) \t} \t .... 階段{ \t \t階段( 「構建」 ){ \t \t \t步驟\t \t \t個\t gitlabCommitStatus(名稱: 「建」){ \t \t \t \t ..... \t \t \t \t} \t \t \t \t \t \t \t} \t \t} \t} –

+0

對不起,我有幾點體會用這個管道代碼... – Rik