Search code examples
jenkinsgitlabgitlab-api

Access GitLab Plug-in's API Token from Jenkins Job


I have instances of Jenkins and GitLab which are successfully connected. Part of setting up the GitLab plug-in involves providing an API token. I believe this is used by the plug-in to get details of the commit which is triggering a job.

I need to run a daily Jenkins job which collects some statistics using the API and then (using R) generates a report. So this is not triggered by an event in GitLab.

To complicate issues a little further, the R code will run inside a container (to avoid hving to install R and all the packages on every Jenkins slave),

It does not appear that the plug-in makes the token available to be used in jobs ... and I can see a sane reason for that.

Is it possible to access the API token from the plug-in?


Solution

  • Job with parametersThere is a plugin which supports credential injecting (https://wiki.jenkins.io/display/JENKINS/Credentials+Binding+Plugin) to the builds which could be used later as an environment variable. Gitlab api token could be also selected.