Knowledge Base Article

TestComplete URL for the Jenkins TestComplete report page

I want to offer a way to-get-URL-of-TestComplete-Test-Results-of-a-Jenkins-Build without accessing the Jenkins controller.  Outside of those with an admin role for the Jenkins instance, granting teams access to the Jenkins controller is a security risk.  TestComplete uses an epoch timestamp as part of the report page URL. This makes it a challenge to use the URL unless you know how to get the timestamp.  Fortunately there is an easy way to get it.  Once the test plan completes, the results become available using the Jenkins-TestComplete API.  Any Jenkins ID that has read access to view the job will have access to use the API.  In your job, once the test is completed, use the API to parse the xml for the URL.  This allows you to keep your Jenkins instance safe and obtain the report URL for use in your job (such var passed to outgoing email).

Here is an example of using a windows batch build step in a freestyle job, after the TestComplete build step.

 

 

Echo off
curl -X GET "http://jenkins:8080/job/folder/job/name/%BUILD_NUMBER%/TestComplete/api/xml" --user %ID%:%pwd%>Test_Results.txt
powershell -c "((((gc Test_Results.txt) -replace '<url>','@') -replace '</report>','@') | ForEach-Object { $_.split('@') } | Select-String -Pattern '</url>' -SimpleMatch ) -replace '</url>','' | set-content TestComplete_URL.txt"
if exist TestComplete_URL.txt set /p TestComplete_URL=<TestComplete_URL.txt

 

 

Once you have the URL, you can use the inject plugin to use it in other steps of your job.  For example, you can create a var to be used in an outgoing email.

 

 

echo Line_1=$JOB_BASE_NAME ^<a href^=^"%TestComplete_URL%^"^>test results^</a^>: >>email.properties

 

 

Hope this information is of use.

Updated 3 years ago
Version 2.0
No CommentsBe the first to comment