Skip to main content
Skip table of contents

Auto-Book Dependent Environments

The scheduling configuration has been improved as part of Golive 9.23. If you are using Golive 9.23 or a newer version, please refer to the Scheduling Environments section. If you are using an older version of Golive, consider upgrading. Alternatively, you can refer to the documentation below for configurating your environment scheduling.

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

Automation Rule 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 (as Array)

Variable name:

CODE
environmentIds

Smart value:

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

4. Store IDs of booked environments (as String)

Variable name:

CODE
excludedEnvironmentIds

Smart value:

CODE
{{#webResponses.last.body.items.id}}{{.}},{{/}}

5. Log the variables (can help debugging)

Log message:

CODE
EnvironmentIds: {{environmentIds}} | excludedEnvironmentIds: {{excludedEnvironmentIds}}

6. Check if booked environments is not empty

First value:

CODE
{{environmentIds}}

Second value

CODE
[]

7. 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
}

The “api-key” is the same than step 2

8. 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 necessary!

9. Log the variable (can help debugging)

Log message:

CODE
EnvironmentIdsQueryParams: {{environmentIdsQueryParams}}

10. 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}}&excludedEnvironmentIds={{excludedEnvironmentIds}}

The “api-key” is the same than step 2

11. Log the variable (can help debugging)

Log message:

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

12. Set the “Dependent Environments” custom field

Additional fields:

JSON
{
    "fields": {
        "Dependent Environments": [{{webResponses.last.body.items.id}}]
    }
}

13. Else (if no environment is booked)

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

Additional fields:

JSON
{
    "fields": {
        "Dependent Environments": []
    }
}

15. 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.