Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Automation Rules backup/version control

This is a Bitbucket pipeline that you can utilize to schedule backups and version your Automation Rules. Additionally, you can employ 'sed' to replace tokens, URLs, etc., in order to prepare the JSON for importing into your sandbox/production tenant.

Define DOMAIN and USERTOKEN within the deployment environment scope of the pipeline.

 

<<bitbucket-pipelines.yml>>

 

image: atlassian/default-image:3

pipelines:

  branches:

    master:

      - step:

            name: Backup

            deployment: production

            script:

              - bash download.sh

              - COMMIT_MESSAGE=`git log --format=%B -n 1 $BITBUCKET_COMMIT`

              - echo $COMMIT_MESSAGE

              - git add *

              - git commit -m "[skip ci] $COMMIT_MESSAGE"

              - git push --force

<<download.sh>>

 

#!/bin/bash

export cloudId

function getCloudId() {

    echo "get cloud ID"

   

    HTTP_RESPONSE=$(

        curl --silent --write-out "HTTPSTATUS:%{http_code}" \

        -H "Content-Type: application/json" \

        -H "Authorization: Basic $USERTOKEN" \

        -X GET https://$DOMAIN.atlassian.net/_edge/tenant_info 2>&1 \

    )

       

    HTTP_BODY=$(

        echo "$HTTP_RESPONSE" | sed -e 's/HTTPSTATUS\:.*//g'

    )

       

    HTTP_STATUS=$(

        echo "$HTTP_RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://'

    )

   

    if [  "$HTTP_STATUS" = "200" ]; then

        cloudId=$(echo $HTTP_BODY | jq -r '.cloudId')

    else

        error $HTTP_BODY $HTTP_STATUS

        exit 1

    fi

   

}

function getAutomationRules() {

    echo "get Automation Rules of $cloudId in $DOMAIN"

 

    HTTP_RESPONSE=$(

        curl --silent --write-out "HTTPSTATUS:%{http_code}" \

        -H "Content-Type: application/json" \

        -H "Authorization: Basic $USERTOKEN" \

        --anyauth \

        -X GET  "https://$DOMAIN.atlassian.net/gateway/api/automation/internal-api/jira/$cloudId/pro/rest/GLOBAL/rule/export" 2>&1 \

    )

       

    HTTP_BODY=$(

        echo "$HTTP_RESPONSE" | sed -e 's/HTTPSTATUS\:.*//g'

    )

       

    HTTP_STATUS=$(

        echo "$HTTP_RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://'

    )

   

    if [  "$HTTP_STATUS" = "200" ]; then

        echo "$HTTP_BODY"  | jq > AutomationRule.json 2>/dev/null

        ls -l AutomationRule.json

    else

        echo $HTTP_BODY $HTTP_STATUS

        exit 1

    fi

   

}

getCloudId

getAutomationRules

1 comment

devpartisan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Nov 28, 2023

For anyone not carefully reading Bash, this uses an API indicated to be internal (by the path "internal-api"), which means it is undocumented, not supported by Atlassian, and subject to change at any time without notice. Use at your own risk.

For an official, documented, and supported API, please watch, vote, and comment on AUTO-51.

Like Rick Westbrock likes this

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events