Version 1 Use Asset Data in Jira Automation
Use Snipe-IT asset data in Jira Automation to enhance your workflows. Automate Asset Management tasks within Jira for improved efficiency.
You may want to extract Snipe-IT asset values in Jira automation, for example, to send an E-Mail containing the name of the asset(s) linked to the issue.
The only value exposed in Jira automation is issue.Linked assets.value
, which contains the internal ID of the linked asset. If multiple assets are linked, their internal IDs can be accessed by index: issue.Linked assets.value.get(0)
, issue.Linked assets.value.get(1)
, etc.
Using the internal ID, values related to the asset can be retrieved by calling one of the two following APIs:
Provides only basic information like the name or the status of the asset.
Provides all the data, including Snipe-IT custom fields, but is more complex to set up.
Both solutions require a bit of configuration in Jira automation, which is explained in detail below.
Calling the Jira Assets API
If not already the case, generating a Jira Cloud REST API token is necessary for being able to call the Jira Assets API.
Encode
YOUR_JIRA_EMAIL:YOUR_API_TOKEN
using Base64, for example by typingecho -n [YOUR_JIRA_EMAIL]:[YOUR_API_TOKEN] | base64
in a terminal.Create a Send Web Request Jira automation action as below, for fetching the asset data. Please make sure to replace both
####
with the appropriate values, i.e. your Jira instance URL (in the Webhook URL field) and the previously Base64 encoded string (in the Headers field). Please also make sure that the Wait for response checkbox is checked.
The smart value
{{webhookResponse.body}}
can now be used in subsequent steps, it will contain the asset data. For example,webhookResponse.body.values.label.value
contains the name of the asset, which is used in an E-mail in the example below:
The available fields are of course based on what you have in your Snipe-IT dataset.
Calling the Snipe-IT API
Calling the Snipe-IT API provides the complete asset data, including custom fields, but is more complex to set up, as it requires decoding the Base64 part of the internal asset ID.
For example, the internal asset ID (extracted with the smart value issue.Linked assets.value
) may be as follows:
com.codefortynine.asset-sync-for-jira/eyJzbmlwZWl0SW5zdGFuY2UiOiJzbmlwZWl0LWluc3RhbmNlLWV4YW1wbGUiLCJhc3NldElkIjoxMjN9
Decoding the Base64 part of the ID (everything after /
) will return:
{"snipeitInstance":"snipeit-instance-example","assetId":123}
The ID 123
can then be used to retrieve data from the Snipe-IT API by calling GET https://[SNIPE_IT_INSTANCE_URL]/api/v1/hardware/123
.
Unfortunately, Jira Automation does not provide an out-of-the-box solution to decode base64 strings, so you will need to set up and use a custom API endpoint to do so.