How to get where used information for tasks

Description

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

Example - For a Single Project

This requires CLI release 7.6.

This will create a file called tasks.csv that lists all Maven 3 tasks there by given all plans and jobs using this task type. This examples is show with non-Windows escaping (Windows use "" instead of \" for escaping).

Example
-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.

Example
-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

"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

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

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 CSV Command Line Interface (CLI). 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

Example
-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@   \"\"  \" "