jenkinsci / jenkinsci/gitlab-plugin

Feature request: ability to pass environment variables and parameter values via webhook URI

Open
#912 5 comments 8 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.4k
Forks
615
Avg merge
4h 32m
Merged PRs (30d)
10

Description

I think it would be useful to have a mechanism to convey arbitrary information from GitLab to a triggered Jenkins job. At the moment, the GitLab plugin makes variables such as `gitlabActionType` and `gitlabTargetRepoName` readily available to Jenkins, however there doesn't seem to be a way to add arbitrary variables.

I've searched around for this and it seems to be a fairly common question. Some people switch to a generic webhook plugin and populate those variables themselves. Others write a gitlab-CI job that sends the initial webhook request and then monitors the Jenkins job(s).

I think it would be sufficient to add parameters to the webhook URL such that the GitLab plugin adds them to the environment (is this safe?). For example:

`http://jenkins.server/project/MyProject?MYPARAM=FOO`

Then the associated Jenkins job would have a variable called `MYPARAM` set to value `FOO` in its environment. This should also be accessible in the scripted pipeline via `env.MYPARAM`.

This would be even better if such parameters could match the names of "parameterised" parameters, enabling the webhook to set overriding values for those, rather than using the default value.

The reason this is useful to me is that I have a repository with multiple webhooks configured that (ideally) point at the same Jenkins job, but I need that job to behave slightly differently for each. I want to put a special flag in the webhook URL to direct the Jenkins job for each trigger. I'd rather not create multiple Jenkins jobs, or even worse, multiple Jenkinsfiles.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.