Versions Compared

Key

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

...

0. Get the Projectrak Status field id

First of all is necessary to obtain the Projectrak “Status” and “End date” field ids from the Projectrak Field manager.

In the following example the id are: 42288 and 42286

Image Added
Image Added

1. Create an Automation rule

Go to: Settings \ System \ Global Automation, and create a new rule.

You can also access 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

Image Modified

...

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.
If you have already got it, you can reuse it.

Add the last 2 steps described at 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 id

Add component → New action → Send web request

  • 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

Image Added

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}}{{/}}

Image Added

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 generate it.
If you have already

...

one, you can reuse it.

3. Get all projects

Generate a base64 authentication for the Jira user

Generate a string in base64 with the text "<JIRA_USER>:<JIRA_API_TOKEN>"

...

Use a Linux terminal:

Code Block
echo -n 

...

JIRA_USER_EMAIL:

...

JIRA_API_TOKEN | base64
  1. Store the result (something like this):

...

* For Windows terminal, please refer this link.

Image Added

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>

  • HTTP method:

...

  • GET

  • Web request body:

...

Custom data (ℹ️ Replace DUMMYAUTO for your project key)

...

  • Empty

  • Check: Delay execution of subsequent rule actions until we've received a response for this web request

...

Image Added

...

8. Rule step: iterate each project

Add component → New branch → Advanced branching

  • Smart value: {{webResponse.body}}

  • Variable name: project

...

Image Added

...

9. Rule step: get each Projectrak “end date” field value

Add component → New action → Send a web request

Info

For this example, our End date field from Projectrak has the id: 10

(warning) Replace using your id

Note

Replace <field_id> using your field id. You can get this id from the Field manager.

  • 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)

...

Image Added

...

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

Image Modified

...

11. 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")}}

Image Modified

...

12. Rule step: get all issues from a project and unresolved

Add component → New action → Lookup issues

  • JQL: project={{project.id}} and resolution is empty

Image Modified

...

13. Rule step: compare the numbers of issues in unresolved

Add component → New condition → Advanced compare condition

  • First value: {{lookupIssues.size}}

  • Condition: does not equal

  • Second value: 0

Image Modified

...

For this example, our status field from Projectrak has the id: 150166

...

14. Rule step: update project status field

Add component → New action → Send a web request

...

Note

Replace <field_id> using your field id. You can get this id from the Field manager.

  • Web request URL:

...

  •  https://profields-cloud.deiser.com/values/projects/{{project.id}}/fields/

...

  • <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)

...

Image Added