How to determine fields for addTask

How to determine fields for addTask

On this page

Summary

The addTask action can be used to add arbitrary tasks to a job. However, you must know the parameter fields that each task uses and needs. Normally, the task provider doesn't document this. However, they can be discovered. We have documented some examples already - see Examples for AddTask action. If the task you want is not already documented, then you need to discover the fields needed.  There are 2 ways to discover these fields.

  1. Using exportPlan on an existing plan that has been created manually through the UI.

  2. Using browser tools to discover fields from the UI. I use Crome → Developer Tools to look at the request details when you save a task from the UI.

Steps using exportPlan

Step

Discussion 

Find or create a plan using the UI that has a task that you would like to

Go to the command line and run the exportPlan action on the plan and find the task in the exported data

You are mostly interested in the fields that are exported.

If there are more than 8 fields, you may need to convert some of the fields to use the fields parameter.

Steps using UI 

Step

Discussion 

In Chrome, to to View → Developer → Developer Tools → Network tab

Or similar tool that captures interactions between your browser and the server.

Go to the UI to add a task manually

Either add or update a task that you want to automate

Save the task

Try to fill in or select most fields you are interested in so they will show up as being set.

Look for a POST and a line under that contains fields and values looking like your task input

Look for field names that match fields on the screen. There are lots of other fields that should be ignored.

Example: selectedRepository_0=defaultRepository&cleanCheckout=true

Add the fields to the addTask action using the various field parameters

Example: --field "myfield=myvalue" or similarly with field1, value1, etc ...

Alternative for getting field names

An alternative approach you can use is to use your browsers Inspect Element support to get the name of fields from the UI. Click on the input field, right click -> Inspect Element and look for the name of the field.

Examples