简体   繁体   中英

Publish Jenkins Job build status to Gitlab commit with Jenkins Pipeline job

I have integrated my Gitlab CE version 9.3.5 with jenkins version 2.60.1 .

I am able to trigger builds with Gitlab webhook and publish the result back to the commit with a jenkins freestyle job.

I was wondering how can i achieve the same with jenkins pipeline job as every article on the above integration works with jenkins freestyle job.

If I follow the documentation about the Gitlab Jenkins plugin , you should be able to use the gitlabCommitStatus method which will publish the status of the build steps declared after (here is an example from the doc) :

node() {
    stage 'Checkout'
    checkout <your-scm-config>

    gitlabCommitStatus {
       <script that builds, tests, etc. your project>
    }
}

If this is not enough, you also have the possibility to use updateGitlabCommitStatus name: 'build', state: 'pending' to control more precisely which state you're sending to the gitlab instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM