snippetMinor
How to get GitLab CI to rebuild on JIRA issue status change?
Viewed 0 times
jiragitlabissuestatusrebuildgethowchange
Problem
I would like to start builds in
I have not found a direct way to do that from searching online. I have found ways to get GitLab to tell JIRA what to do, but seemingly no solutions in the other direction.
We have a constraint which would make
Note that we have added a
To satisfy this constraint we run a python script to do deploys for
Instead I would prefer to have
In a JIRA workflow status transitions can "Trigger A Webhook", but it seems we will have to supply our own
GitLab CI in response to issue transitions in JIRA.I have not found a direct way to do that from searching online. I have found ways to get GitLab to tell JIRA what to do, but seemingly no solutions in the other direction.
We have a constraint which would make
JIRA to GitLab messages very helpful: we must deploy to servers under the rule that a branch gets deployed- to ...test.example.com when the JIRA issue has status
QA
- to ...stage.example.com when the JIRA issue has status
Stage
- to ...beta.example.com when the JIRA issue has status
Beta
- to ....example.com when the JIRA issue has status
Done
Note that we have added a
Merge Request field to issues in our JIRA, so we know "the branch for an issue" (and "the issues for a branch").To satisfy this constraint we run a python script to do deploys for
QA, Stage, Beta every hour in a crontab for every project. That script has too many top-level loops, and too many features (being old).Instead I would prefer to have
JIRA notify that an issue is ready for re-build, and then ask our GitLab CI to re-build the relevant Merge Request.In a JIRA workflow status transitions can "Trigger A Webhook", but it seems we will have to supply our own
REST api to which JIRA can post messages, and which can then ping GitLab. That's a new internal app, which will need maintenance, and gain features, so we would like to find out if there are any other solutions.Solution
I didn't get what's wrong with webhooks
You just create a webhook on Gitlab CI side and provide this URL to your Jira account.
Look here for more details how to trigger build on Gitlab via this call
You just create a webhook on Gitlab CI side and provide this URL to your Jira account.
https://gitlab.com/api/v4/projects/PROJECT_ID/ref/REF_NAME/trigger/pipeline?token=TOKENPROJECT_ID - unique project id on GitlabREF_NAME - your qa / stage / beta branches within repositoryTOKEN - uniquely generated access token (gitlab provided)Look here for more details how to trigger build on Gitlab via this call
Code Snippets
https://gitlab.com/api/v4/projects/PROJECT_ID/ref/REF_NAME/trigger/pipeline?token=TOKENContext
StackExchange DevOps Q#13147, answer score: 3
Revisions (0)
No revisions yet.