Sign inSign up

apwide/golive-bitbucket

By apwide

•Updated 2 days ago

Bitbucket Pipe for Golive

Image
Integration & delivery
Developer tools
Monitoring & observability
0

217

apwide/golive-bitbucket repository overview

⁠Bitbucket Pipelines Pipe: Apwide Golive

Send environment status changes and deployments to Apwide Golive⁠ Cloud. send-deployment attaches the Jira issue keys found in the commits deployed since the previous release tag.

⁠YAML definition

- pipe: apwide/golive-bitbucket:1.0.0
  variables:
    ACTION: "<string>"            # set-status | send-deployment
    GOLIVE_API_TOKEN: "<string>"
    ENVIRONMENT_ID: "<string>"
    # STATUS: "<string>"                # set-status only
    # VERSION: "<string>"
    # BUILD_NUMBER: "<string>"
    # TAG_PATTERN: "<string>"
    # SINCE_REF: "<string>"
    # ISSUE_KEYS: "<string>"
    # JIRA_PROJECT_KEYS: "<string>"
    # FALLBACK_COMMIT_DEPTH: "<int>"
    # DEPLOYMENT_ATTRIBUTES: "<json>"
    # GOLIVE_BASE_URL: "<string>"
    # DRY_RUN: "<boolean>"
    # DEBUG: "<boolean>"

⁠Variables

VariableUsage
ACTION (*)set-status or send-deployment.
GOLIVE_API_TOKEN (*)Golive Cloud API token. Store it as a secured repository variable.
ENVIRONMENT_ID (*)Id of the Golive environment.
STATUSStatus name to set. Required for set-status.
VERSIONVersion name sent to Golive. Default: $BITBUCKET_TAG itself (e.g. staging-11.18.0) when it matches TAG_PATTERN.
BUILD_NUMBERDefault: $BITBUCKET_BUILD_NUMBER.
TAG_PATTERNRelease tag naming, with {version} exactly once, e.g. v{version} or staging-{version}. {version} matches 1, 1.2, 1.2.3 or 1.2.3.4.
SINCE_REFRead issue keys from SINCE_REF..HEAD instead of looking up the previous tag.
ISSUE_KEYSComma-separated keys to send as is. Disables git lookup.
JIRA_PROJECT_KEYSComma-separated project keys to keep, e.g. ECOM,PAY. Recommended: removes false positives such as UTF-8.
FALLBACK_COMMIT_DEPTHCommits read when no previous tag is found. Default: 50.
DEPLOYMENT_ATTRIBUTESJSON object of Golive deployment attributes, e.g. '{"initiator": "Marvin"}'. Keys must exist in Golive.
GOLIVE_BASE_URLMust start with https:// and contain no credentials. Default: https://golive.apwide.net/api.
DRY_RUNPrint the request without sending it. Default: false.
DEBUGVerbose logging. Default: false.

(*) = required variable.

⁠How issue keys are found

First match wins:

  1. ISSUE_KEYS is set: sent as is.
  2. SINCE_REF is set: keys in SINCE_REF..HEAD.
  3. TAG_PATTERN is set: keys since the nearest earlier tag matching the pattern that HEAD can reach. Tags on HEAD itself are ignored, so a v2.1.1 hotfix compares against v2.1.0, not against a v2.2.0 on main.
  4. Otherwise: keys in the last FALLBACK_COMMIT_DEPTH commits, with a warning.

Merge commit messages are included.

⁠Examples

Tag pipeline: the tag (e.g. staging-11.18.0) is the version sent to Golive, and the change range runs from the previous staging-* tag.

pipelines:
  tags:
    'staging-*':
      - step:
          name: Deploy to staging
          deployment: staging
          clone:
            depth: full
          script:
            - ./deploy.sh
            - pipe: apwide/golive-bitbucket:1.0.0
              variables:
                ACTION: send-deployment
                GOLIVE_API_TOKEN: $GOLIVE_API_TOKEN
                ENVIRONMENT_ID: "6"
                TAG_PATTERN: "staging-{version}"
                JIRA_PROJECT_KEYS: "ECOM,PAY"

Branch pipeline: explicit version, keys since the last v* release.

pipelines:
  branches:
    main:
      - step:
          name: Deploy to dev
          clone:
            depth: full
          script:
            - ./deploy.sh
            - pipe: apwide/golive-bitbucket:1.0.0
              variables:
                ACTION: send-deployment
                GOLIVE_API_TOKEN: $GOLIVE_API_TOKEN
                ENVIRONMENT_ID: "4"
                VERSION: "1.4.$BITBUCKET_BUILD_NUMBER"
                TAG_PATTERN: "v{version}"
                JIRA_PROJECT_KEYS: "ECOM"

Environment status from the step result:

      - step:
          name: Deploy to staging
          script:
            - ./deploy.sh
          after-script:
            - if [ "$BITBUCKET_EXIT_CODE" = "0" ]; then export GOLIVE_STATUS=Up; else export GOLIVE_STATUS=Down; fi
            - pipe: apwide/golive-bitbucket:1.0.0
              variables:
                ACTION: set-status
                GOLIVE_API_TOKEN: $GOLIVE_API_TOKEN
                ENVIRONMENT_ID: "6"
                STATUS: $GOLIVE_STATUS

⁠Versions

Pin the full version in your pipeline, and upgrade by changing the number:

- pipe: apwide/golive-bitbucket:1.0.0

apwide/golive-bitbucket is the pipe's Bitbucket repository and 1.0.0 is a git tag in it. Pipelines reads pipe.yml at that tag and runs the Docker image declared in its image: line, which has the same version. To run an image directly, e.g. to test an unreleased build, use pipe: docker://apwide/golive-bitbucket:<tag>. Every push to develop and main publishes apwide/golive-bitbucket:develop and apwide/golive-bitbucket:main for that purpose. These images move with each push: never use them in production pipelines.

Versions follow semantic versioning⁠: a new optional variable is a minor release, a renamed or removed variable is a major release.

⁠Troubleshooting

  • "Shallow clone" warning, or keys from older releases: Pipelines clones 50 commits by default, which can cut off the previous tag. Add clone: depth: full to the step.
  • "The clone has no tags": add - git fetch --tags before the pipe.
  • "No previous tag matches TAG_PATTERN": check the pattern against git tag --list. staging-1.0.0-rc1 and staging-old do not match staging-{version}.
  • 401: the token is wrong or revoked. 404: check ENVIRONMENT_ID.
  • Run with DRY_RUN: "true" to see the exact request.

Tag summary

Content type

Image

Digest

sha256:125f9d72b…

Size

82.4 MB

Last updated

2 days ago

docker pull apwide/golive-bitbucket:main