jenkinsci / gitlab-plugin

A Jenkins plugin for interfacing with GitLab
https://plugins.jenkins.io/gitlab-plugin/
GNU General Public License v2.0
1.43k stars 612 forks source link

Gitlab notification working with script from CI, but not custom script in Jenins - How to debug #890

Open tkruse opened 5 years ago

tkruse commented 5 years ago

Hi, related to #691, I have the situation that using Cloudbees jenkins, notifications from jenkins to gitlab for multibranch pipelines work (roughly) like with a file in the SCM like this:

pipeline {
        // ...
        properties([gitLabConnection('Gitlab connection')])
        updateGitlabCommitStatus name: 'VERIFY', state: 'pending'
        gitlabCommitStatus(name: "VERIFY") {
            sh("mvn --errors --batch-mode verify")
        }
}

But when I copy&paste the changes to the Jenkins configuration of the same jenkins job without any other change, no more notifications are sent to gitlab.

So I assume the action of checking out the repo for the sake of reading the Jenkinsfile to use has an effect on later calls to updateGitlabCommitStatus and gitlabCommitStatus.

How can I further debug this, and is there something else I can do to make notifications work with a custom script?

tkruse commented 5 years ago

Assuming that the git checkout is not done using the gitlab plugin (but e.g. using a shell command), is there any other gitlab plugin command than clone that could be used to prepare the gitlab connection?

omehegan commented 5 years ago

@tkruse I am not sure what you mean by 'custom script.' Can you try to explain what you are doing in a different way?

If you are manually triggering the job, no status update will be sent to GitLab.

tkruse commented 5 years ago

In the Jenkins UI for a multibranch pipelines, I have 2 options for defining the build logic in the "Pipeline" section:

With "custom script" I meant the first option, keeping the build logic in the jenkins job configuration, and not taking it from the SCM.

In our case notifications to gitlab work when the script is taken from SCM, but do not work when the script is kept in Jenkins. I assume it has something to do with gitlab properties/variables being set up when the jenkinsfile is fetched from SCM, whereas those properties variables are not valid when not doing so.

But how can I debug that?

abhiram-krishnan commented 4 years ago

@tkruse : Have the same issue. Did you manage to find a way to get the plugin to post status when using the first option?