Examples

Action usage examples

Examples give users ideas on actual usage. We use automation to generate, test, and run these actions, so names and combinations may be odd or repetitive (wink). In many cases, other actions or environmental setup is required for the action to run, so you will need to adjust the action parameters and setup appropriate for your environment. 

Command line environments can be different, especially between Windows and non-Windows systems. Our Tips page talks about command line escaping differences and there are differences with respect to environment variable references ($ for non-Windows and %...% for Windows). These differences can impact examples, so recognize and adjust for your platform. In particular, all examples here are run with the standard bash shell on Linux.



addDownload

--action addDownload --repository "bobswift-test/test-repo" --file "/opt/atlassian/pipelines/agent/build/src/itest/bitbucketcloud/resources/test.txt"

addVariables

--action addVariables --repository "bobswift-test/test-repo" --propertyFile "/opt/atlassian/pipelines/agent/build/src/itest/bitbucketcloud/resources/example.properties" --replace
--action addVariables --workspace "bobswift-test" --field "Zv_b=value b" --field "Zv_a=value a" --field "Zv_1=value 1 0627753" --field "Zv_2=value 2 :;<>,.?/~#$%^&*()_+'" --field "ZWORKSPACEpassword=XXX:secured" --replace
--action addVariables --workspace "bobswift-test" --repository "test-repo" --field "Zv_a=value a" --field "Zv_b=value b" --field "Zv_1=value 1 0627753" --field "Zv_2=value 2 :;<>,.?/~#$%^&*()_+'" --field "ZWORKSPACEpassword=XXX:secured" --replace

createProject

--action createProject --workspace "bobswifttestteam" --project "AUT1" --name "AutomationTestProject1" --description "Automation Test Project 1"
--action createProject --workspace "bobswifttestteam" --project "AUT2" --name "AutomationTestProject2"

deleteProject

--action deleteProject --workspace "bobswifttestteam" --project "AUT1"
--action deleteProject --workspace "bobswifttestteam" --project "AutomationTestProject2"

getBranch

--action getBranch --workspace "@self" --repository "{c544c3d5-6941-456e-be8e-0ba8d2b4c491}" --branch "master"

getBranchList

--action getBranchList --repository "@all"
--action getBranchList --workspace "@self" --repository "@all"
--action getBranchList --workspace "bobswift-test" --repository "test-repo" --outputType "text" --options "tableNoWrap"

getBuildStatusList

--action getBuildStatusList --workspace "@self" --repository "{c544c3d5-6941-456e-be8e-0ba8d2b4c491}" --branch "master"

getClientInfo

--action getClientInfo
--action getClientInfo --outputFormat 2

getCommit

--action getCommit --workspace "@self" --repository "{c544c3d5-6941-456e-be8e-0ba8d2b4c491}" --commit "dbd93a47b17145543627edea5c61065d46e29582"
--action getCommit --workspace "{ecddc0da-f8fa-43aa-bc5f-72bad652fc56}" --repository "{ec85a580-b4b8-4d87-b355-5e7eabdea3d5}" --commit "f571f689166cb1cd177bc115be0c0a5d39757c0c" --dateFormat "yyyy-MM-dd"

getCommitList

--action getCommitList --workspace "@all" --repository "@all" --dateFormat "yyyy-MM-dd" --outputType "text" --limit 400 --columns "-1,2,3,4,5,6,7,8,9,10" --options "tableNoWrap"
--action getCommitList --workspace "@self" --repository "@all" --dateFormat "yyyy-MM-dd"
--action getCommitList --workspace "@self" --repository "test-repo" --columns "-1,2,3,4,5,6,7,8,9,10"
--action getCommitList --workspace "{ecddc0da-f8fa-43aa-bc5f-72bad652fc56}" --repository "{c544c3d5-6941-456e-be8e-0ba8d2b4c491}" --regex ".*AutomationTestFile1.*" --columns "commit,commitmessage"
--action getCommitList --workspace "{ecddc0da-f8fa-43aa-bc5f-72bad652fc56}" --repository "{c544c3d5-6941-456e-be8e-0ba8d2b4c491}" --regex "dbd93a47b17145543627edea5c61065d46e29582"

getDeploymentList

--action getDeploymentList --workspace "bobswift-test" --repository "test-repo" --dateFormat "yyyy-MM-dd HH:mm:ss.SSS" --columns "-1,2,3,4,5,6" --outputType "text" --options "tableNoWrap"
--action getDeploymentList --workspace "bobswift-test" --repository "test-repo" --dateFormat "yyyy-MM-dd HH:mm:ss.SSS" --limit 3
--action getDeploymentList --workspace "bobswift-test" --repository "testfiles"

getDownloadList

--action getDownloadList --repository "bobswift-test/test-repo" --dateFormat "yyyy-MM-dd HH:mm:ss" --columns "-1,2,3,4,5,6" --outputType "text" --options "tableNoWrap"

getEnvironmentList

--action getEnvironmentList --workspace "bobswift-test" --repository "test-repo" --dateFormat "yyyy-MM-dd HH:mm:ss.SSS" --columns "-1,2,3,4,5,6" --outputType "text" --options "tableNoWrap"
--action getEnvironmentList --workspace "bobswift-test" --repository "test-repo" --limit 4
--action getEnvironmentList --workspace "bobswift-test" --repository "testfiles"

getFileList

--action getFileList --repository "gint" --workspace "gint_org" --dateFormat "yyyy-MM-dd HH:mm:ss" --descendents
--action getFileList --workspace "bobswift" --repository "base-cli" --path ""
--action getFileList --workspace "bobswift" --repository "base-cli" --path "" --dateFormat "yyyy-MM-dd HH:mm:ss" --descendents
--action getFileList --workspace "bobswift" --repository "base-cli" --path "" --dateFormat "yyyy-MM-dd HH:mm:ss" --descendents --regex "src/itest.*"
--action getFileList --workspace "bobswift" --repository "base-cli" --path "license" --dateFormat "yyyy-MM-dd HH:mm:ss"
--action getFileList --workspace "bobswift" --repository "base-cli" --path "license" --dateFormat "yyyy-MM-dd HH:mm:ss" --outputFormat 999

getPipeline

--action getPipeline --workspace "bobswift-test" --repository "test-repo" --dateFormat "yyyy-MM-dd HH:mm:ss.SSS" --pipeline 1
--action getPipeline --workspace "bobswift-test" --repository "test-repo" --pipeline "@last" --dateFormat "yyyy-MM-dd HH:mm:ss.SSS"

getPipelineList

--action getPipelineList --workspace "bobswift-test" --repository "test-repo" --dateFormat "yyyy-MM-dd HH:mm:ss.SSS" --columns "-1,2,3,4,5,6,7,8,9,10,errorkey,message" --outputType "text" --options "tableNoWrap" --limit 200
--action getPipelineList --workspace "bobswift-test" --repository "test-repo" --dateFormat "yyyy-MM-dd HH:mm:ss.SSS" --limit 3

getProject

--action getProject --workspace "bobswifttestteam" --project "CLI" --dateFormat "yyyy-MM-dd HH:mm:ss"
--action getProject --workspace "bobswifttestteam" --project "cli" --dateFormat "yyyy-MM-dd HH:mm:ss"
--action getProject --workspace "bobswifttestteam" --project "{f3a863a4-a073-474c-8452-3d1927343042}"

getProjectList

--action getProjectList
--action getProjectList --outputFormat 999 --columns "-2,3" --outputType "text" --options "tableNoWrap" --dateFormat "yyyy-MM-dd HH:mm:ss"
--action getProjectList --workspace "@all" --regex "Bob.*Project" --dateFormat "yyyy-MM-dd HH:mm:ss"
--action getProjectList --workspace "@self" --limit 1 --outputFormat 2
--action getProjectList --workspace "bobswifttestteam" --regex "AUT.*"
--action getProjectList --workspace "bobswifttestteam" --regex "AUT.*" --dateFormat "yyyy-MM-dd HH:mm:ss"

getPullRequest

--action getPullRequest --workspace "@self" --repository "testfiles" --pullRequest 5 --dateFormat "yyyy-MM-dd"

getPullRequestList

--action getPullRequestList --workspace "@self" --repository "@all" --limit 2
--action getPullRequestList --workspace "@self" --repository "testfiles" --regex "AutomationTestFile1.*" --columns "pullrequest,name"
--action getPullRequestList --workspace "@self" --repository "{c544c3d5-6941-456e-be8e-0ba8d2b4c491}" --outputType "text" --columns "-1,2,3,4,5,6,7,8,9,10" --options "tableNoWrap" --dateFormat "yyyy-MM-dd"
--action getPullRequestList --workspace "@self" --repository "{c544c3d5-6941-456e-be8e-0ba8d2b4c491}" --state "DECLINED" --columns "pullrequest,state"

getRepository

--action getRepository --repository "Base CLI"
--action getRepository --repository "base-cli"
--action getRepository --repository "bobswift/base-cli"
--action getRepository --repository "gint" --workspace "gint_org"
--action getRepository --workspace "@self" --repository "abc/def"
--action getRepository --workspace "bobswift" --repository "base-cli" --dateFormat "yyyy-MM-dd HH:mm:ss"

getRepositoryList

--action getRepositoryList
--action getRepositoryList --workspace "@all" --columns "workspace,repository,project" --outputType "text"
--action getRepositoryList --workspace "@self" --columns "-1,2,3,4,5,6" --outputType "text" --options "tableNoWrap" --dateFormat "yyyy-MM-dd HH:mm:ss"
--action getRepositoryList --workspace "bobswift-test" --columns "-1,2,3,4,5,6" --outputType "text" --options "tableNoWrap"
--action getRepositoryList --workspace "bobswift-test" --query "is_private=true" --columns "repository,fullkey,name,description,uuid"
--action getRepositoryList --workspace "gint_org" --columns "repository,fullkey,name,uuid"
--action getRepositoryList --workspace "gint_org" --columns "repository,fullkey,name,uuid,scm,private,website"

getSource

--action getSource --repository "gint" --workspace "gint_org" --path "build.gradle"
--action getSource --workspace "bobswift" --repository "base-cli" --path "build.gradle"

getUser

--action getUser --dateFormat "yyyy-MM-dd"

getVariableList

--action getVariableList --workspace "bobswift-test"
--action getVariableList --workspace "bobswift-test" --outputType "text" --columns "workspace,key,value,secured" --options "tableNoWrap"
--action getVariableList --workspace "bobswift-test" --outputType "text" --columns "workspace,key,value,uuid,scope,secured,system" --options "tableNoWrap"
--action getVariableList --workspace "bobswift-test" --repository "test-repo"

getWorkspace

--action getWorkspace --workspace "bobswift-test" --dateFormat "yyyy-MM-dd"
--action getWorkspace --workspace "bobswiftautomationtest" --dateFormat "yyyy-MM-dd"
--action getWorkspace --workspace "{67bd5cbe-a9e5-4d46-a890-09f9b4a8aaa2}" --dateFormat "yyyy-MM-dd"

getWorkspaceList

--action getWorkspaceList --outputType "text" --dateFormat "yyyy-MM-dd" --options "tableNoWrap"

publishSource

--action publishSource --repository "gint" --workspace "gint_org" --path "build.gradle" --title "build.gradle" --replace --space "experiment" --parent "@home" --targetServer "confluence210"
--action publishSource --repository "gint" --workspace "gint_org" --path "build.gradle" --title "build.gradle" --replace --space "experiment" --parent "@home" --targetServer "confluence30"
--action publishSource --workspace "bobswift" --repository "base-cli" --path "build.gradle" --title "build" --replace --space "experiment" --parent "@home" --targetServer "confluence210"
--action publishSource --workspace "bobswift" --repository "base-cli" --path "build.gradle" --title "build" --replace --space "experiment" --parent "@home" --targetServer "confluence30"
--action publishSource --workspace "bobswift" --repository "base-cli" --path "license" --title "licenses" --options "name,h1" --replace --space "experiment" --parent "@home" --targetServer "confluence210"
--action publishSource --workspace "bobswift" --repository "base-cli" --path "license" --title "licenses" --options "name,h1" --replace --space "experiment" --parent "@home" --targetServer "confluence30"
--action publishSource --workspace "bobswift" --repository "base-cli" --path "src/main/java/org/swift/common/cli/CliClient.java" --title "Example.java with full path" --options "path,language=java,collapse" --replace --space "experiment" --parent "@home" --targetServer "confluence210"
--action publishSource --workspace "bobswift" --repository "base-cli" --path "src/main/java/org/swift/common/cli/CliClient.java" --title "Example.java with full path" --options "path,language=java,collapse" --replace --space "experiment" --parent "@home" --targetServer "confluence30"
--action publishSource --workspace "bobswift" --repository "base-cli" --path "src/main/java/org/swift/common/cli/CliClient.java" --title "Example.java" --options "name,lineNumbers,theme=midnight" --replace --space "experiment" --parent "@home" --targetServer "confluence210"
--action publishSource --workspace "bobswift" --repository "base-cli" --path "src/main/java/org/swift/common/cli/CliClient.java" --title "Example.java" --options "name,lineNumbers,theme=midnight" --replace --space "experiment" --parent "@home" --targetServer "confluence30"

removeVariables

--action removeVariables --workspace "bobswift-test" --field "@all"
--action removeVariables --workspace "bobswift-test" --repository "test-repo" --field "@all"

renderRequest

--action renderRequest --url "/2.0/workspaces" --pretty
--action renderRequest --url "https://api.bitbucket.org/2.0/workspaces" --pretty

run

--action run -i "-a getSource --workspace bobswift --project CLILEGACY --repository base-cli --path src/test/resources/run.txt --file @temp" -i "-a getReplacementVariableList" -i "-a run -f @temp"
--action run -i "-a run -f @bitbucketcloud_test:2.0/repositories/bobswift/base-cli/src/2ae34c6bc25b69d244709911f4616436eb1e5e20/src/test/resources/run.txt" -i "-a run -f @bitbucketcloud_test:https://api.bitbucket.org/2.0/repositories/bobswift/base-cli/src/2ae34c6bc25b69d244709911f4616436eb1e5e20/src/test/resources/run.txt"
--action run -i "-a startPipeline --workspace bobswift-test --repository test-repo --pullRequest 2" -i "-a getReplacementVariableList --outputType text" -i "-a getPipeline --workspace @workspace@ --repository @repository@ --pipeline @pipeline@"
--action run --common "--repository bobswift-test/test-repo" -i "-a addDownload -f /opt/atlassian/pipelines/agent/build/src/itest/bitbucketcloud/resources/test.txt" -i "-a addDownload -f /opt/atlassian/pipelines/agent/build/src/itest/bitbucketcloud/resources/test.txt --name \"test with blank in name.txt\"" -i "-a getReplacementVariableList --outputType text" -i "-a getDownloadList --limit 2 --outputType text --columns -1,2,3,4,5,6 --dateFormat \"yyyy-MM-dd HH:mm:ss\" --options tableNoWrap" -i "-a removeDownload --name \"test_with_blank_in_name.txt\"" -i "-a removeDownload --name \"test_with_blank_in_name.txt\" --continue"
--action run --common "--workspace bobswift-test --repository test-repo" -i "-a removeEnvironment --environment zdeploymentsxx --continue" -i "-a removeEnvironment --environment zdeployments --continue" -i "-a addEnvironment --environment zdeploymentsXX --type production" -i "-a addEnvironment --environment zdeployments --type Test" -i "-a getReplacementVariableList --outputType text" -i "-a getEnvironment --environment @environmentUuid@" -i "-a addVariables --environment @environment@ --replace --field key1=value1 --field key2=value2" -i "-a getVariableList --environment @environmentUuid@ --outputType text --columns key,value,uuid" -i "-a getVariableList --environment @environmentUuid@ --outputType text --columns key,value,uuid" -i "-a getVariableList --environment @environmentUuid@ --outputType text --columns key,value,uuid" -i "-a updateVariables --environment @environmentName@ --replace --field key1=update1 --field key2=update2" -i "-a getVariableList --environment @environmentUuid@ --outputType text --columns key,value,uuid" -i "-a getVariableList --environment @environmentUuid@ --outputType text --columns key,value,uuid" -i "-a getVariableList --environment @all --outputType text --columns environment,key,value,uuid" -i "-a updateVariables --environment @environmentName@ --field key1" -i "-a removeVariables --environment @environmentUuid@ --field key2" -i "-a removeEnvironment --environment @environmentName@" -i "-a removeEnvironment --environment \"zdeployments with blank\" --continue" -i "-a addEnvironment --environment \"zdeployments with blank\" --type STAGING --options adminOnly" -i "-a getEnvironment --environment @environmentUuid@" -i "-a removeEnvironment --environment @environment@"
--action run --common "--workspace bobswift-test --repository test-repo" -i "-a startPipeline --branch feature/JIRA-1 --selector test1" -i "-a getPipeline --pipeline @pipeline@" -i "-a setReplacementVariables --field first=@pipeline@" -i "-a startPipeline --branch feature/JIRA-1 --selector test1 --selectorType default -v" -i "-a getPipeline --pipeline @pipeline@" -i "-a startPipeline --commit e2cc79e --selector test1 --wait" -i "-a getPipeline --pipeline @pipeline@" -i "-a getPipeline --pipeline @first@ --wait" -i "-a getReplacementVariableList --outputType text"

runFromDeploymentList

--action runFromDeploymentList --workspace "bobswift-test" --repository "test-repo" --limit 2 --input "-a getReplacementVariableList --outputType text"

runFromDownloadList

--action runFromDownloadList --repository "bobswift-test/test-repo" --limit 2 --input "-a getDownload --repository @repository@ --name @downloadName@ -f /opt/atlassian/pipelines/agent/build/build/output/downloads" --input "-a getReplacementVariableList --outputType text --options tableNoWrap"

runFromEnvironmentList

--action runFromEnvironmentList --workspace "bobswift-test" --repository "test-repo" --limit 5 --input "-a getReplacementVariableList --outputType text"

runFromRepositoryList

--action runFromRepositoryList --workspace "@all" --continue --options "parallel" -i "-a getDeploymentList --workspace @workspace@ --repository @repository@" -i "-a getEnvironmentList --workspace @workspace@ --repository @repository@" -i "-a getBranchList --workspace @workspace@ --repository @repository@" -i "-a getPullRequestList --workspace @workspace@ --repository @repository@" -i "-a getCommitList --workspace @workspace@ --repository @repository@"

runFromWorkspaceList

--action runFromWorkspaceList --input "-a getWorkspace --workspace @workspace@ --dateFormat yyyy-MM-dd --outputFormat 2" --input "-a getReplacementVariableList --outputType text"

startPipeline

--action startPipeline --workspace "bobswift-test" --repository "test-repo" --branch "feature/JIRA-1"
--action startPipeline --workspace "bobswift-test" --repository "test-repo" --branch "feature/JIRA-1" --commit "e2cc79e"

updateProject

--action updateProject --workspace "bobswifttestteam" --project "AUT1" --description "Automation Test Project 1 updated"
--action updateProject --workspace "bobswifttestteam" --project "AUT2" --public
--action updateProject --workspace "bobswifttestteam" --project "AutomationTestProject2" --description "Automation Test Project 2 updated"

updateVariables

--action updateVariables --repository "test-repo" --append --field "Zv_a = ' APPENDED_TEXT WITH BLANK'" --field "Zv_1 = APPENDED_TEXT"
--action updateVariables --repository "test-repo" --append --field "Zv_a" --findReplace "value aaa:modified value aaa"
--action updateVariables --workspace "bobswift-test" --append --field "Zv_a = ' APPENDED_TEXT WITH BLANK'" --field "Zv_1 = APPENDED_TEXT"
--action updateVariables --workspace "bobswift-test" --append --field "Zv_a" --findReplace "value aaa:modified value aaa"