Note: I didn't use this yet, the answer is based solely on documentation.
A GitlabCI pipeline can be triggered via API, see Triggering pipelines through the API.
Triggers can be used to force a pipeline rerun of a specific ref
(branch or tag) with an API call.
You would first need to create a trigger for that pipeline.
Then you can activate that trigger (from your jenkins job in this case):
To trigger a job you need to send a POST
request to GitLab's API
endpoint:
POST /projects/:id/trigger/pipeline
The required parameters are the trigger's token
and the Git
ref
on which the trigger will be performed. Valid refs are the
branch and the tag.
Such triggers support variable passing:
You can pass any number of arbitrary variables in the trigger API call
and they will be available in GitLab CI so that they can be used in
your .gitlab-ci.yml
file. The parameter is of the form:
variables[key]=value
You can use the variables inside .gitlab-ci.yml
like this:
upload_package:
stage: package
script:
- if [ -n "${UPLOAD_TO_S3}" ]; then make upload; fi
And
You can then trigger a rebuild while you pass the UPLOAD_TO_S3
variable and the script of the upload_package
job will run:
curl --request POST \
--form token=TOKEN \
--form ref=master \
--form "variables[UPLOAD_TO_S3]=true" \
https://gitlab.example.com/api/v4/projects/9/trigger/pipeline
This kind of POST requests is what you would to do in your jenkins job. But take a closer look at the triggers, you might find a way to do what you want without jenkins.