Auto-Book Dependent Environments
When you book an environment, you may also want to book its dependencies to ensure that the necessary resources and configurations are available when needed. Thankfully, you can rely on the already defined environment dependencies to completely automate the booking of dependent environments.
In this step-by-step guide, you will learn how to configure Jira Automation for the purpose of managing bookings of your Golive environments when using Jira Issues and Issue Calendars.
This page documents an advanced setup that requires knowledge in following areas:
Feel free to reach out if you need assistance.
Solution Overview
At the heart of the proposed solution, you will use two different environment custom fields:
"Environments": The main editable custom field used to select the environments you want to book.
"Dependent Environments": Another readonly custom field used to display the list of dependent environments for the environments selected in the "Environments" field.
When a user updates the list of environments to book in the "Environments" field, the list of dependencies in the "Dependent Environments" field is automatically populated by a Jira Automation Rule.

Quick Demo
Jira Automation Rule Setup
Automation Rule Overview
Steps Overview



1. Trigger

2. Fetch the list of Environments to Book (without dependencies)

In order to generate an api-key to call the Golive REST API: Rest API
Web request URL:
https://golive.apwide.net/api/customfield/environment/selected?issueKey={{issue.key}}&customfieldName={{#urlEncode}}Environments{{/}}
3. Store IDs of booked environments

Variable name:
environmentIds
Smart value:
{{webResponses.last.body.items.id.asJsonStringArray}}
4. Log IDs of booked environments

Log message:
EnvironmentIds: {{environmentIds}}
5. Check if booked environments is not empty

First value:
{{environmentIds}}
Second value
[]
6. Fetch dependency information of booked environments

Web request URL:
https://golive.apwide.net/api/environments/search/paginated
Custom data:
{
"criteria": [
{
"name": "environmentId",
"values": {{environmentIds}}
}
],
"expand": true
}
7. Prepare query params to retrieve the dependent environments

Variable Name:
environmentIdsQueryParams
Smart value:
&environmentId=0&{{#webResponse.body.environments.outgoingDependencies}}{{#id}}&environmentId={{.}}{{/}}{{/}}
Adding $environmentId=0 at the beginning is important!
8. Log query params to retrieve dependent environments

EnvironmentIdsQueryParams: {{environmentIdsQueryParams}}
9. Fetch custom field options to set the “Dependent Environments” field

Web request URL:
https://golive.apwide.net/api/customfield/environment/selectable?projectKey={{issue.project.key}}&customfieldName={{#urlEncode}}Dependent Environments{{/}}{{environmentIdsQueryParams}}
10. Log the custom field options to set the “Dependent Environments” field

Log message:
Option id: {{webResponses.last.body.items.id}}
11. Set the “Dependent Environments” custom field

Addition fields:
{
"fields": {
"Dependent Environments": [{{webResponses.last.body.items.id}}]
}
}
12. Else (if no environment is booked)

13. Clear “Dependent Environments” field (if no environment is booked)

Additional fields:
{
"fields": {
"Dependent Environments": []
}
}
14. Update your Conflict Checker Automation Rule (optional)
If you have already implemented the Conflict Checker and would like to make dependent environments conflicts visible, refer to the last section of this documentation page: Conflict Checker