I am trying to tell GitLab that a build stage was skipped by Jenkins using updateGitlabCommitStatus name: 'Stage', state: 'skipped'. This fails with a HTTP 400 Bad Request error from GitLab. When I tried to find out what I was doing wrong I noticed that skipped is not a valid state for a GitLab commit status as of https://docs.gitlab.com/ee/api/commits.html#post-the-build-status-to-a-commit. So I manually tried the API call to see if maybe the docs are wrong but I also received a HTTP 400 along with the error message state does not have a valid value. Related issue #721 and pull request #786
@MarcelNehring from what I can see, the skipped status is only valid in the GitLab Pipelines API. See https://docs.gitlab.com/ee/api/pipelines.html So maybe the context when you use this step matters. @semos added this, maybe he can explain how to use it correctly.
Actually I didn't had time to test it.
After checking the docs more deeply, it is effectively only available in gitlab pipelines.
I made a wrong assumption here, I'm gonna revert my PR as I can't see a way to inform gitlab of a skipped stage for a given commit.
Thanks for your analysis @semos
I'm trying to use this explicitly _in_ a pipeline. I guess nothing like this is possible yet, even though gitlabBuilds ends up creating Pipeline steps?
node {
gitlabBuild(builds: ['Test', 'Deploy']) {
stage('Test') {
gitlabCommitStatus('Test') {
}
}
stage('Deploy') {
if (env.BRANCH_NAME != "master") {
updateGitlabCommitstatus(name: 'Deploy', state: 'skipped')
} else {
sh '...'
}
}
}
}
Edit: I guess that the Pipeline's API are only to do with Gitlab's internal pipelines - even though the commit status updates report as a pipeline we can't report an individual step as skipped. It is a limitation in the GitLab API :(
I created an issue for being able to do this in Gitlab - if anyone else would like this feature please go and vote on it there https://gitlab.com/gitlab-org/gitlab-ce/issues/50146
Most helpful comment
I created an issue for being able to do this in Gitlab - if anyone else would like this feature please go and vote on it there https://gitlab.com/gitlab-org/gitlab-ce/issues/50146