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

12,572

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.

Share:
12,572

Related videos on Youtube

Arun.D
Author by

Arun.D

Open Source developer and a big data enthusiast. "If life comes crashing down, check for missing semi colons"

Updated on September 15, 2022

Comments

  • Arun.D
    Arun.D over 1 year

    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.

  • Arun.D
    Arun.D over 6 years
    this actually worked for me but on failure the gitlab smtp server fires an email to all the project contributors about the build failure. What if I want to override this sometime in future?
  • Cédric Julien
    Cédric Julien over 6 years
    @Alex.DA nice to have helped you :) For your other problem, I think it is related to a configuration option in your Gitlab instance, no more related to jenkins
  • Oliver Gondža
    Oliver Gondža almost 5 years
    This appears to also need a gitLabConnection specified so it knows which Gitlab to update. So properties([gitLabConnection('foo')]) or gitlabCommitStatus(connection: gitLabConnection('bar')).