Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Description

This article shows how to answer the question: How do I find all jobs using a specific task? 

Example - For a Single Project

Tip

This requires CLI release 7.6.

...

Code Block
titleExample
-a runFromPlanList --project CLI --common "-a runFromJobList --plan @plan@ --common \"-a getTaskList --plan @plan@ --job @job@ --regex \"\"Maven 3.x\"\" --file tasks.csv --append \" " --clearFileBeforeAppend

Example - For All Projects

This will take a while to complete on larger sites.

Code Block
titleExample
-a runFromPlanList --project @all --common "-a runFromJobList --plan @plan@ --common \"-a getTaskList --plan @plan@ --job @job@ --regex \"\"Maven 3.x\"\" --file tasks.csv --append \" " --clearFileBeforeAppend

Example Output - Raw

No Format
"Plan","Job","Id","Name","Description","Task Key","Task Key Alias","Enabled","Final","Position"
"CLI-BAMBOO630","JOB1","3","Maven 3.x","","com.atlassian.bamboo.plugins.maven:task.builder.mvn3","MAVEN3","Yes","No","3"
"CLI-BASE","JOB1","3","Maven 3.x","","com.atlassian.bamboo.plugins.maven:task.builder.mvn3","MAVEN3","Yes","No","3"
...

Example Output - CSV Macro

Csv
"Plan","Job","Id","Name","Description","Task Key","Task Key Alias","Enabled","Final","Position"
"CLI-BAMBOO630","JOB1","3","Maven 3.x","","com.atlassian.bamboo.plugins.maven:task.builder.mvn3","MAVEN3","Yes","No","3"
"CLI-BASE","JOB1","3","Maven 3.x","","com.atlassian.bamboo.plugins.maven:task.builder.mvn3","MAVEN3","Yes","No","3"

What if I want to run an action for each task found?

The There is a general answer to this type of question. If you have a CSV list of items, you can use a small script process each line or you can use runFromCsv to run an action for each line provided the CSV file has the correct headers for the action you are trying to run. You can modify the CSV file by hand or automate with the CSVCLI. In most cases, I recommend using the columns parameter on the list generation to only generate the columns needed for a subsequent runFromCSV action.

More specifically, for tasks you can use the runFromTaskList action directly in place of the getTaskList action above to simply do the request.

Example - Run An Action

Code Block
titleExample
-a runFromPlanList --project CLI --common "-a runFromJobList --plan @plan@ --common \"-a runFromTaskList --plan @plan@ --job @job@ --continue --regex \"\"Maven 3.x\"\" --common \"\"-a getTask --plan @plan@ --job @job@ --task @task@   \"\"  \" "

...