npm inpm run devnpm run build
node ./dist/index.jsOr:
docker compose build
docker compose up -d- In the Allure TestOps administration section, add an integration of the custom type. Specify its name and the endpoint: the URL where this service is available to Allure TestOps.
- In the settings of the project, add the integration and fill in Auth header. Allure TestOps sends this value as is in the
Authorizationheader of every request to the service, for exampleBearer <token>orBasic <base64>.
The template doesn't check the Authorization header. Add the check before you expose the service.
| # | Method | Route | Params | Response |
|---|---|---|---|---|
| 1 | GET |
/server/info |
— | ExtServerInfo |
| 2 | GET |
/me |
— | ExtUser |
| # | Method | Route | Params | Response |
|---|---|---|---|---|
| 3 | GET |
/job |
?query= |
ExtJob[] |
| 4 | GET |
/job/:id |
:id |
ExtJob |
| 5 | POST |
/job/:id/start |
:id, body: ExtJobStartRequest |
ExtJobRun |
| 6 | GET |
/job/:id/:buildNumber |
:id, :buildNumber |
ExtJobRun |
| 7 | POST |
/job/:id/:buildNumber/stop |
:id, :buildNumber |
ExtJobRun |
| # | Method | Route | Params | Response |
|---|---|---|---|---|
| 8 | GET |
/issue |
?search= |
ExtIssueLink[] |
| 9 | GET |
/issue/:key |
:key |
ExtIssueLink |
| 10 | GET |
/project |
?search= |
ExtProject[] |
| 11 | GET |
/issuetype |
?projectKey= |
ExtIssueType[] |
| 12 | GET |
/issuefield |
?projectKey=, ?issueTypeId= |
unknown[] |
| 13 | POST |
/issue |
?projectKey=, ?issueTypeId=, body: ExtIssueCreate |
ExtIssueLink |
| # | Method | Route | Params | Response |
|---|---|---|---|---|
| 14 | GET |
/testcase/:testCaseKey |
:testCaseKey |
ExtTestLink |
These are the API calls Allure TestOps sends towards the custom CI.
On the integration side, it is necessary to implement API to transfer data between TestOps and Custom Integration.
Invoked when clicking the Test Connection button.
GET /server/info
{
"name": "My custom CI"
}It is important that the request is executed and a response with status code 200 is received.
Invoked when clicking the Test Connection button.
GET /me
{
"id": "Identifier in your system",
"name": "Username in your system"
}It is important that the request is executed and a response with status code 200 is received, and the username will be displayed in the integration.
Optional. Used when creating a new job from TestOps.
GET /job
You can pass the query parameter in the request.
Example: <endpoint>/job?query=part_of_job_name
A list of job objects is returned.
[
{
"externalId": "Job identifier in custom integration",
"name": "Job name",
"url": "http://hello.world/123",
"parameters": [
{
"name": "Name of internal job parameter",
"value": "Value of internal parameter"
},
{
"name": "branch",
"value": "master"
}
]
}
]GET /job/{id}
Example: <endpoint>/job/externalId
{
"externalId": "Job identifier in custom integration",
"name": "Job name",
"url": "http://hello.world/123",
"parameters": [
{
"name": "Name of internal job parameter",
"value": "Value of internal parameter"
},
{
"name": "branch",
"value": "master"
}
]
}Triggers the pipeline execution.
POST /job/{id}/start
The request body contains an object for starting:
{
"jobRunId": 123,
"launchId": 123,
"tests": [
{
"id": 1658,
"selector": "io.qameta.allure.IssuesWebTest.shouldCloseIssue"
},
{
"id": 1657,
"selector": "io.qameta.allure.PullRequestsWebTest.shouldClosePullRequest"
},
{
"id": 1656,
"selector": "io.qameta.allure.IssuesWebTest.shouldAddLabelToIssue"
}
],
"parameters": {
"name1": "value1",
"name2": "value2",
"name3": "value3"
},
"username": "jdoe"
}The object contains:
jobRunId- job run identifier in Allure TestOps. With this parameter, allurectl can download the test plan and upload the results (see Uploading test results).launchId- launch identifier in Allure TestOps.tests- list of tests for launch:id- test case ID from Allure TestOps (a number).selector- alternative ID, which by default equals Full Name.
parameters- job run parameters. When you start a job run from Allure TestOps, you can pass input parameters to the run, such as browser and base URL.username- the Allure TestOps user who started the job run.
Allure TestOps accepts any 2xx code. The template stub returns 200.
In the response, we need to receive:
id- of the run for subsequent requests.name- of the run to display it nicely.url- link to the run. Allure TestOps doesn't use it, see Links to jobs and runs.stage- status of the run:RUN_FAILURE,SCHEDULED,IN_PROGRESS,FINISHED.status- execution status:CANCELLED,PASSED,FAILED,UNKNOWN.
{
"id": "123",
"name": "hello, world",
"url": "http://hello.world/123",
"stage": "SCHEDULED",
"status": "UNKNOWN"
}Checks the triggered pipeline execution status. The id parameter from the previous section will be used.
GET /job/{jobId}/{id}
{
"id": "123",
"name": "hello, world",
"url": "http://hello.world/123",
"stage": "FINISHED",
"status": "PASSED"
}Tries to stop execution of a running pipeline. The id parameter from the previous section will be used.
POST /job/{jobId}/{id}/stop
{
"id": "123",
"name": "hello, world",
"url": "http://hello.world/123",
"stage": "FINISHED",
"status": "CANCELLED"
}Allure TestOps doesn't use the url field from the job and run responses. It builds the links itself from the endpoint of the integration:
- job:
<endpoint>/job/{id}; - run:
<endpoint>/job/{jobId}/{id}.
These are the same paths as the API calls above, so a user who clicks a link in Allure TestOps opens this service. To send the user to your CI instead, answer browser requests to these paths (with Accept: text/html) with a redirect to the job or run page of your CI.
These parameters need to be available on the Custom CI side and accessible from the pipeline execution context (e.g. as a variable). Some of these can be hard-coded.
- Name of the CI - Name of the CI as pipeline run context variable. Optional, can be hard-coded to allurectl.
- ID of the CI project - Unique identifier of CI project.
- URL of the CI project - URL that an end user can open to see the details of CI project.
- Name of the CI project - Name of the project. Optional.
- Unique identifier of the pipeline - When a pipeline is executed, it should have a unique identifier, preferably across the whole CI, not on the project level.
- URL of the CI pipeline - URL an end user could use to access the pipeline execution and see the details.
- Branch used for the pipeline execution - Information on the VCS branch used to run the pipeline.
These are the calls the pipeline makes to Allure TestOps. All requests need the Authorization: Api-Token <token> header, where the token is an API token of an Allure TestOps user.
When Allure TestOps starts a job (POST /job/{id}/start), it has already created the job run and the launch. Pass jobRunId from the start request to the pipeline and let allurectl upload the results to this job run:
export ALLURE_ENDPOINT=https://testops.example.com
export ALLURE_TOKEN=<api-token>
export ALLURE_PROJECT_ID=1
export ALLURE_JOB_RUN_ID=<jobRunId from the start request>
allurectl watch --results build/allure-results -- <command that runs the tests>allurectl also downloads the test plan of the job run, so that only the selected tests run.
Use this sequence for pipelines that were not started from Allure TestOps.
-
Start a job run:
POST /api/rs/upload/start{ "projectId": 1, "ci": { "type": "my-ci" }, "job": { "uid": "my-job", "name": "My job", "url": "https://ci.example.com/job/my-job" }, "jobRun": { "uid": "my-job-127", "name": "#127", "url": "https://ci.example.com/job/my-job/127" }, "launch": { "name": "Regression" } }jobandjobRunare required.job.uidmust be the same for all runs of the job; the job is shown on the Jobs page of the project.jobRun.uidmust be unique for each run; the run is shown on the Job run tab of the launch.ciandlaunchare optional.The response contains
projectId,launchId,jobIdandjobRunId. -
Create an upload session:
POST /api/rs/upload/session{ "projectId": 1, "jobUid": "my-job", "jobRunUid": "my-job-127" }Instead of
jobUidandjobRunUid, you can passjobRunId. The response contains the sessionid. -
Upload the files:
POST /api/rs/upload/file?id=<session id>, a multipart request with onefilepart per result file. Repeat as many times as needed. Zip archives go toPOST /api/rs/upload/archive?id=<session id>. -
Stop the job run after all files are uploaded:
POST /api/rs/upload/stop{ "projectId": 1, "jobUid": "my-job", "jobRunUid": "my-job-127", "status": "passed" }statusis optional:passed,failed,cancelledorunknown.
To read the results of a launch, for example the one from launchId of the start request, use the Allure TestOps API with the same Authorization: Api-Token <token> header.
GET /api/rs/testresult/__search
Query parameters:
projectId- ID of the project.rql- query in the Allure TestOps query language, for examplelaunch = 7.page- page number, starting from 0.size- page size, for example 100.
The response is a page: the results are in content, the number of pages is in totalPages.
export ENDPOINT=https://testops.example.com
export TOKEN=<api-token>
curl -s -G "${ENDPOINT}/api/rs/testresult/__search" \
--header "Accept: application/json" \
--header "Authorization: Api-Token ${TOKEN}" \
--data-urlencode "projectId=1" \
--data-urlencode 'rql=launch = 7 and status = "failed"' \
--data-urlencode "page=0" \
--data-urlencode "size=100"GET /api/rs/launch/{id}/env