Gitlab-plugin: Not set Gitlab Commit Status

Created on 5 Feb 2019  路  14Comments  路  Source: jenkinsci/gitlab-plugin

Issue

Context

  • Gitlab plugin version: 1.5.11
  • Gitlab version: 11.7.3
  • Jenkins version: 2.163
  • Job type: Freestyle, Multibranch pipeline

Logs & Traces

Pipeline 1

pipeline {
    agent any

    options {
        skipDefaultCheckout()
        gitLabConnection('my-connection')
    }

    stages {
        stage('Checkout') {
            steps {
                dir('test') {checkout scm}
            }
        }
        stage('Run tests') {
            steps {
                gitlabCommitStatus(name: env.STAGE_NAME) {
                    echo 'test'
                }
            }
        }
    }
}

Log for pipeline 1

Feb 05, 2019 10:50:45 AM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
Retrieving gitlab project ids
Feb 05, 2019 10:50:45 AM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
Build does not contain build data.
Feb 05, 2019 10:50:45 AM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
Retrieving gitlab project ids
Feb 05, 2019 10:50:45 AM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
Build does not contain build data.

Pipeline 1 result: Gitlab commit status was not set

Pipeline 2

pipeline {
    agent any

    options {
        skipDefaultCheckout()
        gitLabConnection('my-connection')
    }

    stages {
        stage('Checkout') {
            steps {
                dir('test') {checkout scm}
            }
        }
        stage('Run tests') {
            steps {
                gitlabCommitStatus(name: env.STAGE_NAME, connection:gitLabConnection('my-connection'),
                    builds: [
                        [projectId: 'jenkins_sandbox/buildbot-test-project', revisionHash: 'master'],
                    ]){
                    echo 'test'  
                }
            }
        }
    }
}

Log for pipeline 2

Feb 05, 2019 11:41:34 AM FINEST com.dabsquared.gitlabjenkins.gitlab.api.impl.ResteasyGitLabClientBuilder
Call GitLab:
HTTP method: GET
URL: https://diver.elvees.com/api/v4/projects/jenkins_sandbox%2Fbuildbot-test-project/repository/commits/master
Request headers: [
Accept = [application/json],
PRIVATE-TOKEN = [****FILTERED****]
]
Feb 05, 2019 11:41:34 AM FINEST com.dabsquared.gitlabjenkins.gitlab.api.impl.ResteasyGitLabClientBuilder
Got response from GitLab:
URL: https://diver.elvees.com/api/v4/projects/jenkins_sandbox%2Fbuildbot-test-project/repository/commits/master
Status: 200 OK
... 
Feb 05, 2019 11:41:34 AM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater updateCommitStatus
Updating build 'jenkins_sandbox/buildbot-test-project' to 'running'
...
Feb 05, 2019 11:41:34 AM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater updateCommitStatus
Updating build 'jenkins_sandbox/buildbot-test-project' to 'success'
...

Pipeline 2 result: Gitlab commit status was set to success

Problem description

I had a jenkins job configured with pipeline 1 and it worked correctly. But some time ago, presumably after updating Jenkins and plugins, it started working incorrectly: builds don't change commit status in gitlab. I didn't found any requiest to gitlab in logs in this case, just Retrieving gitlab project ids and Build does not contain build data.

After this I changed configuration to pipeline 2 (manualy setten project name and branch name) and it start work right (there is correct request in log and status was set).

Also I check it with freestyle job (Publish build status to GitLab in post build actions) and result same as for pipeline 1.

Most helpful comment

The issue appears to be a recent change in the git plugin which removes the BuildData from the run. Apparently, "that release was expected to land only in the experimental update center but -rc was used instead of -alpha and -beta" (via Jira). It appears they have hidden the 4.0-rc release from the update center now.

Reverting to 3.9.3 of the Git plugin (and Git client plugin 2.7.6) has fixed the issue for me.

If this change _does_ land in 4.0, the gitlab plugin will need to be modified accordingly.

cc @Azarko @tarekch

All 14 comments

I am having the same issue exactly with the same logs and same version numbers, but I noticed it happened after I updated gitlab to 11.7.3 not when i updated Jenkins to 2.163. Did you update gitlab recently too?

I did some code digging and the error comes from here:
https://github.com/jenkinsci/gitlab-plugin/blob/master/src/main/java/com/dabsquared/gitlabjenkins/util/CommitStatusUpdater.java#L168
which is a result of get build.getActions(BuildData.class)
On Jenkins docs, the function getActions is deprecated (and maybe completely removed in 2.163) which caused the issue now.
https://javadoc.jenkins-ci.org/hudson/model/Actionable.html#getActions--

Yes I do, but I updated gitlab after I found this issue. Before updating gitlab version probably was 11.5.X.

I rolled back my jenkins to 2.160 and issue still there.

The issue appears to be a recent change in the git plugin which removes the BuildData from the run. Apparently, "that release was expected to land only in the experimental update center but -rc was used instead of -alpha and -beta" (via Jira). It appears they have hidden the 4.0-rc release from the update center now.

Reverting to 3.9.3 of the Git plugin (and Git client plugin 2.7.6) has fixed the issue for me.

If this change _does_ land in 4.0, the gitlab plugin will need to be modified accordingly.

cc @Azarko @tarekch

cc @Azarko @tarekch

Thank you, it did the trick.

@omehegan we should discuss the alternatives for the gitlab plugin to adapt to the JENKINS-19022 fixes (remove BuildData bloat) that will be included in git plugin 4.0.0 and git client plugin 3.0.0.

A git plugin implementation error from many years ago has caused the records of individual builds to include the complete list of every SHA1 ever built by that job. When a Freestyle job was defined to process any branch it detected and was monitoring a repository with frequent changes or many branches, the BuildData collected by a single job could become enormous.

An active repository could generate huge collections of BuildData associated with each of the builds for each job. There are ugly workarounds (like a groovy script that discards BuildData on build records) and we'd like git plugin 4.0.0 to remove the bloat.

This issue was caused by an accidentally-released beta update to the Git plugin. That release has been removed. @MarkEWaite and I have discussed in person plans for mitigating this issue before the final release of the changes to the Git plugin, so we will handle that in a PR.

Hello,
What would be a solution if we already did the migration to 4.0.0-rc ?
It's too tricky to downgrade because I鈥檒l have to remove a lot of plugins.
Thank you

There should be no dependencies on git plugin 4.0.0-rc from other plugins in your system. Other plugins have not had the time to create dependencies on git plugin 4.0.0-rc. You should not have to remove or modify any other plugins. Downgrade to the released plugin versions should be straightforward and low risk.

Downgrade Steps:

  1. Stop your Jenkins server
  2. Backup the Jenkins plugins directory (just in case)
  3. Replace jpi of git client plugin 3.0.0-rc with jpi of git client plugin 2.7.6 in the Jenkins plugins directory
  4. Replace jpi of git plugin 4.0.0-rc with jpi of git client plugin 3.9.3 in the Jenkins plugins directory
  5. Start your Jenkins server

If you believe that those steps won't work for you, please explain why you believe they won't work.

There is no solution if you cannot switch back to git plugin 3.9.3 and git client plugin 2.7.6. If you cannot switch back to git plugin 3.9.3 and git client plugin 2.7.6 then you will need to wait for the release of git plugin 4.0.0 and git client plugin 3.0.0. If you'd like to help resolve the issues that are blocking those releases, refer to the git client plugin 3.0 milestone and the git plugin 4.0 milestone.

Hello!

I have git client plugin 2.7.6 and git plugin 3.9.3 but I still have this issue.
Could you help me with an advice?

@alinpa ,
I'm having the same version as you.
I failed because I call the gitlab-plugin function before cloning the project.

Try let the Git clone repo step happens before any gitlab-plugin function call (e.g updateGitlabCommitStatus).

image

Also, If your pipeline job using SCM and indicate Script Path, need to manually set the gitLabConnection in the Jenkinsfile.

image

4. git client plugin 3.9.3

I pinned git plugin to 3.9.3 and git-client to 2.7.6 version, but after day (may be due a jenkins update) updateGitlabCommitStatus doesn't work anymore.

Can I solve installing new plugin release?
How can I understand which is the cause of this issue?

Was this page helpful?
0 / 5 - 0 ratings