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[0].value, issue.Linked assets[1].value, etc.

Using the internal ID, values related to the asset can be retrieved by calling one of the two following APIs:

  • Jira Assets API

    • Provides only basic information like the name or the status of the asset.

  • Snipe-IT API

    • 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 details 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 username:apitoken using Base64, for example by typing echo -n [YOUR_USERNAME]:[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 #### by the appropriate values, i.e. your Jira instance URL and the previously Base64 encoded string. 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.label.value contains the name of the asset, which is used in an E-mail in the example below:

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 to decode 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.