Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I auto-tag build numbers, if using Jenkins?

Elizabeth Forth
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 19, 2020

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?

1 answer

1 accepted

1 vote
Answer accepted
Sam Harding
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 23, 2020

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:


webhook trigger.png


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:


edit issue.png

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.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events