Hello, all! If I want to auto-tag build numbers onto code complete stories in JIRA, but Jenkins is used to make builds (i.e. I can't use Bamboo) how could I do this, in the absolute simplest (beginner-friendly) way that could explain this?
Hi Elizabeth,
You can do this using an "Incoming webhook" automation trigger. https://support.atlassian.com/jira-software-cloud/docs/automation-triggers/#Automationtriggers-Incomingwebhook
By creating an automation rule with an incoming webhook trigger, you will be given a url which you can send data to your Automation for Jira. You can then use this url inside your Jenkins file to make a POST request, and send the build numbers to your automation rule.
For example, first create your webhook trigger. You see the provided url like so:
If you had a Jenkins build associated with an issue, for example TEST-1, you would then put in your Jenkins file (after the build number has been generated):
curl -X POST -H 'Content-type: application/json' \
--data '{"issues":["TEST-1"], "data": {"buildNumber":"<YOUR_BUILD_NUMBER>"}}' \
https://automation.atlassian.com/pro/hooks/<YOUR_WEBHOOK_ID>
Now, your build number is accessible via smart values in subsequent components in your rule, as {{webhookData.buildNumber}}. If you wanted to add this as a label to your associated issue, TEST-1, you could add an 'Edit Issue' action like so:
Note: In edit issue, select 'Choose fields to set...' as 'Labels', and then you can choose to add instead of replace labels by selecting the '...' option on the right hand side.
This rule will now label issues with build numbers whenever the Jenkins CI pipe is run.
I hope this helps your use case.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.