Integration Script Explained

About the script file

You can create automation tasks, run them and push test results to Zephyr Squad directly from your CI/CD workflow. To do this, you can create a special script file that works with Zephyr Squad through API.

Windows (.bat in .zip)

bat-script.zip

Linux and MacOS (.sh in .zip)

sh-script.zip

Before using these files, you need to replace values in them – access key, user ids, project key, result file name, and others – with values relevant to your project and tests. Below is a detailed explanation of what you need to change. For quick reference, search for the pay-attention.gif icon – it indicates the code parts that need to be updated.

You can modify these files in any text editor.

Prologue comment

The script starts with a comment describing the script file:

Zephyr URL constant

The constant below specifies the Zephyr base URL:

Important

Keep this value exactly as it is in the sample script. Don’t change it!

Connection keys and ID

The following access and secret keys are needed for connection to Zephyr Squad, and the ID of the user account is needed to create or update automation tasks:

Important

Replace these values with the values relevant to your Jira project and user account. You can find all these values in Jira.

JWT generation

The block below generates a JSON Web Token (JWT) that is needed to access Zephyr Squad through API. To create this token, the script sends an API request to Zephyr Squad:

This block doesn’t require changes, you can use it as it is.

Important

The created JWT token is time-limited. The expirationTime parameter in the curl command specifies the expiration period in milliseconds: ..., "expirationTime":360000}' ...

Task properties

The following block specifies properties of the automation task to be created or edited. These properties are scripting analogues to task properties you see in the Create Automation Task dialog box:

Important

Replace these values with your values.

Task info

Variable

Description

taskName

The name of the automation task.

taskDescription

An arbitrary descriptive text for the task.

automationFramework

String that specifies the framework used for the test run. Case-insensitive. Create Automation Task dialog box:

  • Cucumber

  • Egg Plant

  • JUNIT

  • Selenium

  • SoapUI

  • TestNG

  • Tricentis Tosca

  • UFT

projectKey

ID of your Jira project:

Jira project id

versionName

A string that specifies the version of the test run. Default: Unscheduled.

Cycle info

Variable

Description

cycleName

The name of the test execution cycle in Zephyr.

createNewCycle

true or false. Specifies whether Zephyr will create the specified cycle if it doesn’t exist.

appendDateTimeInCycleName

true or false. Specifies if Zephyr will add the date and time of the cycle creation to the cycle name.

Folder info

Variable

Description

folderName

The name of the folder to which the execution cycle will be added in Zephyr.

createNewFolder

true or false. Specifies if Zephyr will create the specified folder if it doesn’t exist.

appendDateTimeInFolderName

true or false. Specifies, if Zephyr will add the date and timestamp of the folder creation to the folder name.

Other values

Variable

Description

assigneeId

ID of the user account to whom the automation task will be assigned. For information on how to get this ID, see above.

resultFile

Fully-qualified name of the file storing test results.

If the file name has spaces, enclose it in quotes.

Task creation

The code below sends a request to Zephyr Squad to create an automation task with the specified properties. Zephyr will run this task and import the testing results from the specified file:

You can use this code as it is. It doesn’t require changes.

Task update

The script file ends with the code that demonstrates how to update an existing automation task.

The code uses variables for the task info, cycle, folder and results file defined above.

The new variable here is taskId. It specifies the ID of the automation task to be updated. You get this ID in the response to the request that created the task.

Important

Replace the taskId variable in the example script with the value that matches your automation task.

The rest of the code doesn’t require changes. You can use it as it is.

Troubleshooting

The curl command might return the following error:

Please provide Jira mandatory field details.

This means that the Create issue screen in Jira has mandatory fields, but the curl request contains no information for those fields. In this case, you need to either pass information for the mandatory fields, or make those fields optional. The example below demonstrate how to pass data of mandatory fields in a curl command:

Suppose you have the Components and Reporter Jira mandatory fields. To pass data for them, you need to do the following:

1. Declare the mandatoryFields variable in the properties of your automation task:

2. Specify the mandatoryFields variable in the curl request:

If you want to pass mandatory field values via API, specify them in the request body of the API operation that creates an automation task.

See Also

Continuous Integration

Jenkins Integration

Bamboo Integration

Publication date: