Skip to main content
Skip table of contents

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:

TYPESCRIPT
https://golive.apwide.net/api/customfield/environment/selected?issueKey={{issue.key}}&customfieldName={{#urlEncode}}Environments{{/}}

Learn more about the Cloud Environment Custom Field API: here
The name of your custom field must be url encoded if it contains spaces or special characters
More about url encoding here

3. Store IDs of booked environments

Variable name:

CODE
environmentIds

Smart value:

CODE
{{webResponses.last.body.items.id.asJsonStringArray}}

4. Log IDs of booked environments

Log message:

CODE
EnvironmentIds: {{environmentIds}}

5. Check if booked environments is not empty

First value:

CODE
{{environmentIds}}

Second value

CODE
[]

6. Fetch dependency information of booked environments

Web request URL:

CODE
https://golive.apwide.net/api/environments/search/paginated

Custom data:

JSON
{
  "criteria": [
    {
      "name": "environmentId",
      "values": {{environmentIds}}
    }
  ],
  "expand": true
}

7. Prepare query params to retrieve the dependent environments

Variable Name:

CODE
environmentIdsQueryParams

Smart value:

CODE
&environmentId=0&{{#webResponse.body.environments.outgoingDependencies}}{{#id}}&environmentId={{.}}{{/}}{{/}}

Adding $environmentId=0 at the beginning is important!

8. Log query params to retrieve dependent environments

CODE
EnvironmentIdsQueryParams: {{environmentIdsQueryParams}}

9. Fetch custom field options to set the “Dependent Environments” field

Web request URL:

CODE
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:

CODE
Option id: {{webResponses.last.body.items.id}}

11. Set the “Dependent Environments” custom field

Addition fields:

JSON
{
    "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:

JSON
{
    "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

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.