Skip to main content
Skip table of contents

Java API

The Golive Java API is a powerful tool that empowers your teams to effortlessly manage deployments in your Atlassian environment. Whether you're using Groovy scripts with ScriptRunner or custom-made Atlassian plugins, this API provides a fluent and intuitive way to interact with deployment processes, saving you time and reducing the risk of errors.

ScriptRunner Integration

You can access Golive Java API from ScriptRunner with the following snippet:

CODE
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.apwide.env.api.GoliveAccessor

@WithPlugin("com.holydev.env.plugin.jira-holydev-env-plugin")
@PluginModule
GoliveAccessor goliveAccessor

def golive = goliveAccessor.golive()

From there, you can use golive instance to interact with Golive.

Usage

Golive Java API is a fluent api organized into different domains for ease of use and to provide a structured approach to interacting with various aspects of the environment management:

  • environments: find environments by id, name, application and category, updated environment details…

  • deployments: search deployments, deploy new versions…

  • environmentFields: find field from an issue by name, get/set values for a given issue field…

  • applications: find applications.

  • environmentCategories: find categories.

Example to get an environment by application and category name:

CODE
def ecomStagingEnvironment = golive.environments.getByAppCat("eCommerce", "Staging")

To streamline operations on your environments, fluent api expose available operations directly on the returned objects. If we want to deploy a new version on the returned environment, we can do it directly on the instance by building a deployment request:

CODE
def deployment = ecomStagingEnvironment.deploy(com.apwide.env.api.Deployments.DeploymentRequest
    .builder()
    .versionName("1.4.5")
    .buildNumber("#345")
    .description("""
      Release Notes:
        - bugs fixed: BUG-123, BUG-344
        - new features: FEAT-34, FEAT-56
      """)
    .attribute("Team", "red-team@example.com")
    .build())

Security

By default, the Golive API acts on behalf of the authenticated user who is making the API calls. This ensures that proper permissions and access controls are enforced.

In certain scenarios, you may need to bypass user authentication and perform actions on behalf of the system. To achieve this, you can call the golive.bypassSecurity method, which returns an instance of the API that bypasses security checks but supports exact same protocol:

CODE
def noSecurityGolive = golive.bypassSecurity()
def ecomProdEnvironment = noSecurityGolive.environments.getByAppCat("eCommerce", "Production")

Use this with caution, as it can have security implications.

Additional Examples

Explore a range of sample scripts that can be utilized as-is, or adapted to suit your particular requirements:

ScriptRunner for Jira

Support

If you encounter any issues, need assistance or would like to see additional capabilities in the Java API, our dedicated support team is here to help. Contact us at support@apwide.com.

JavaScript errors detected

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

If this problem persists, please contact our support.