This example describes the automatic change of the project status to “Off track”, if the project end date is over and the project has unresolved issues.
0. Get the Projectrak Status field id
First of all is , it's necessary to obtain the Projectrak “Status” and “End date” field ids from the Projectrak Field manager.
In the following example the id ids are: 42288 and 42286
1. Create an Automation rule
Go to: Settings \ System \ Global Automation, and create a new rule.
You can also access go there with a direct link, just replacing <your_instance> with yours:
https://<your_instance>.atlassian.net/jira/settings/automation
2 . Rule step: configure a trigger
Create a new trigger → Scheduled
Select the basic section
Choose your specific time: in this case every day at 06:00 AM
3. Rule steps: get the Projectrak authorization token and store it in a variable
Note |
---|
If you don’t have a Projectrak API token yet, follow the first steps (1 to 5) of the link below. |
Add to the rule the last 2 steps described at in this link: https://deiser-apps.atlassian.net/wiki/spaces/PROJECTRAKCLOUD/pages/1641490/How+to+create+a+Projectrak+authorization+in+Automation+for+Jira?src=search
“6. Get the Projectrak JWT”
“7. Store the JWT in a variable“
4. Rule step: get the “Off track” status idvalue id, from the Projectrak Status field
Add component → New action → Send web request
Info |
---|
Replace the <status_field_id> with the one obtained in step 0 |
Web request URL: https://profields-cloud.deiser.com/items/fields/<status_field_id>?query=Off track
* Replace the <status_field_id> with the one obtained in step 1.Headers:
Content-Type: application/json
Authorization: Bearer {{projectrakJwt}}
HTTP method: GET
Web request body: Empty
Check: Delay execution of subsequent rule actions until we've received a response for this web request
5. Rule step: store the Status id in a variable
Add component → New Action → Create variable
Variable name: projectrakOfftrackStatusId
Smart value: {{#webResponse.body.values}}{{id}}{{/}}
6. Rule step: generate a base64 authentication string for Jira
Note |
---|
If you don’t have a Jira API token yet, please go to this page to and generate it. |
Use Open a Linux terminal and execute this command:
Code Block |
---|
echo -n JIRA_USER_EMAIL:JIRA_API_TOKEN | base64 |
* For Windows terminalpowershell, please refer this link.
Copy the result string, please.
7. Rule step: get all Jira projects
Add component → New action → Send web request
Web request URL: https://<your_instance>.atlassian.net/rest/api/3/project
Headers:
Content-Type: application/json
Authorization: Basic <base64 authentication string from previous step>Basic <Jira base64 authentication string>
HTTP method: GET
Web request body: Empty
Check: Delay execution of subsequent rule actions until we've received a response for this web request
8. Rule step: iterate each project
Add component → New branch → Advanced branching
Smart value: {{webResponse.body}}
Variable name: project
9. Rule step: get each Projectrak project “end date” field valuefrom Projectrak
Add component → New action → Send a web request
Noteinfo |
---|
Replace <fieldthe <endDate_field_id> using your field id. You can get this id from the Field manager.with the one obtained in step 0 |
Web request URL: https://profields-cloud.deiser.com/values/projects/{{project.id}}/fields/<endDate_field_id>
* Replace the <endDate_field_id> with the one obtained in step 1.Headers:
Content-Type: application/json
Authorization: Bearer {{projectrakJwt}}
HTTP method: GET
Web request body: Empty
Check: Delay execution of subsequent rule actions until we've received a response for this web request
Check: Continue running the rule even if the request response is not successful (i.e. non-200 response)
10. Rule step: store the Projectrak field value in a variable
Add component → New action → Create variable
Variable name: endDateValue
Smart value: {{webResponse.body.value.value}}
11. Rule step: check not empty project end-date
Add component → New condition → Advanced compare condition
First value: {{endDateValue}}
Condition: does not equal
Second value: leave empty
12. Rule step: compare dates between the current date and end-date of Projectrak.
Add component → New condition → Advanced compare condition
First value: {{endDateValue}}
Condition: less than
Second value: {{now.format("yyyy-MM-dd")}}
1213. Rule step: get all unresolved project issues from a project and unresolved
Add component → New action → Lookup issues
JQL: project={{project.id}} and resolution is empty
1314. Rule step: compare the numbers number of unresolved issues in unresolved
Add component → New condition → Advanced compare condition
First value: {{lookupIssues.size}}
Condition: does not equal
Second value: 0
1415. Rule step: update project status field to “Off track”
Add component → New action → Send a web request
Noteinfo |
---|
Replace <fieldthe <status_field_id> using your field id. You can get this id from the Field managerwith the one obtained in step 0. |
Web request URL: https://profields-cloud.deiser.com/values/projects/{{project.id}}/fields/<field<status_field_id>
Headers:
Content-Type: application/json
Authorization: Bearer {{projectrakJwt}}
HTTP method: POST
Web request body: Custom data
Custom data: {{projectrakOfftrackStatusId}} is the item ID of status field from Projectrak
Code Block |
---|
{ "value": {{projectrakOfftrackStatusId}} } |
Check: Delay execution of subsequent rule actions until we've received a response for this web request
Check: Continue running the rule even if the request response is not successful (i.e. non-200 response)
And that’s all folks!