Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins: gitlabCommitStatus is not working

My enviroment is the next:

-Jenkins 2.46.1

-Gitlab plugin 1.4.5

-GitLab Community Edition 8.14.3

I have a multibranch pipeline configured. I have tried with:

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" }
                    )
                }
        }
    }
}

It works without erros but i dont see the commit status in my Gitlab. Without erros in production.log from gitlab.

Thanks to all!

like image 801
Daniel Majano Avatar asked Sep 21 '26 02:09

Daniel Majano


1 Answers

You will need to wrap it in gitlabBuilds(build: ["jenkins", "build"]) { }.

This will communicate the statusses that are coming. Note that the value needs to be exactly the same as you are using in gitlabCommitStatus('..').

The layout should be:

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

where off course the name you can choose whatever you like, as long as it matches the values in gitlabBuilds.builds.

Make sure your gitlabConnection is working correctly.

like image 61
Rik Avatar answered Sep 23 '26 17:09

Rik