zephyr how to update test description - jenkins

I have test running in Jenkins and I have integrated the test to display in JIRA using Zephyr
The test looks something like this -
#Test(enabled=true, description="check for OS Anomaly ")
public void testOS4() {
....
}
and in the JIRA why dont I see any test description - the test description shows as "Creating the Test via Jenkins" (pls see the attachment). Does anybody know whats wrong here?

Just verify the JSON you are PUTTING to Zephyr URL. If there is a "Description" Key with value "Created the Test via Jenkins", then you can update the key value in the JSON object. something like
obj.put("status", status );
obj.put("summary", summary);
obj.put("description",description);

Related

Jenkins Xray Integration - Jira Issue Type with wrong character

In my Jennkins pipeline I have a Jira/Xray integration step :
step([$class: 'XrayImportBuilder',
endpointName: '/xunit',
fixVersion: '1.0',
importFilePath: '/MyFirstUnitTests/TestResults.xml',
importToSameExecution: 'true',
testExecKey: 'TSTLKS-753',
serverInstance: '9146a388-e399-4e55-be28-8c65404d6f9d',
credentialId:'75287529-134d-4s91-9964-7h740d8d2i63'])
Currently I'm having the following error :
ERROR: Unable to confirm Result of the upload..... Upload Failed!
Status:400 Response:{"error":"Issue with key
\u0027TSTLKS-753\u0027 does not exist or is not of type Test
Execution."}
But my issue (TSTLKS-753) is of type "Test Execution":
It appears that the string "\u0027" is being added both as a prefix
and as a suffix on my issue when building the pipeline.
I've searched for this string and it appears to be a Quotation Mark:
I tried out replacing it by double quotes. But I end up with the same error. Also tried to remove them.
In any case, if someone already got this error please let me know. Thank you very much
Can you confirm that the user that you have configured in Jenkins for the Xray instance has access to that Jira project where you have your Test Execution issue?
Can you try to import it without specifying testExecKey field, with importToSameExecution: 'false', and specifying the projectKey field using something like projectKey: 'TSTLKS' ?
If this last option returns an error (e.g. "project does not exist") then it's for sure a permission issue, so you'll either need to use a different Jira user/pass or fix the permissions on Jira side.

How to pass pipeline variables to post build gerrit message?

I have a Pylint running in a Jenkins pipeline. To implement it, I used Gerrit trigger plugin and Next Generation Warnings plugin. Everything is working as expected - Jenkins is joining the review, checks change with pylint and generates report.
Now, I'd like to post pylint score in a custom "Build successful" message. I wanted to pass the pylint score to a environment variable and use it in dedicated window for Gerrit plugin message.
Unfortunately no matter what I try, I cannot pass any "new" variable to the message. Passing parameters embedded in pipeline works (e.g. patchset number).
I created new environment variable in Configure Jenkins menu, tried exporting to shell, writing to it (via $VAR and env. syntax) but nothing works - that is, build message displays raw string like $VAR instead of what variable contains.
What should I do to pass local pylint score (distinct for every pipeline occurence) to the custom build message for Gerrit?
I don't think the custom message can be used for this. This is just supposed to be a static message.
They way I do this is to use the SSH command to perform the review. You can also achieve the same using the REST API.
First I run my linting and white space checking script that will generate a json file with the information I would like to pass to Gerrit. Next I send it to Gerrit using SSH. See below my pipeline script and an example json file.
As a bonus I have added the robot comments. This will now show up in your review as a remark from Jenkins that line 8 of my Jenkins file has a trailing white space. You can easily replace this with your lint result of you like or just ignore it and only put the message. It is easier to use a json file as it will make it easier to create multi line messages
node('master') {
sh """
cat lint_change.json | ssh -p ${env.GERRIT_PORT} ${env.GERRIT_HOST} gerrit review ${env.GERRIT_PATCHSET_REVISION} --json
"""
}
Example json file:
{
"labels": {
"Code-Style": "-1"
},
"message": "Lint Bot Review\nLint Results:\n Errors: 0\n Warnings: 0\n\nWhitespace results:\n Errors: 1",
"robot_comments": {
"Jenkinsfile": [
{
"robot_id": "lint-bot",
"line": "8",
"message": "trailing whitespace."
}
]
}
}
Alternatively, you may want to look at a new gerrit-code-review-plugin that should make this things even easier. However, I have not tried this yet.

How to get log messages to display in Spock Reports?

I am using the Spock Reports extension in a Geb test. I am trying to find if there is any way to get the logging messages to display in the Spock report.
I have something roughly like this:
#Slf4j
class SpockReportExample extends GebReportingSpec {
def expectedVar = "5"
when: "I click the button."
button.click()
then: "The new value is displayed."
def value = formElement.value()
value==expectedValue
log.info("The new value is $value")
}
I'd like to see the the log stating the actual value to be output in my spock report, but I can't find a way. I've tried sending the log at info, warning, debug, error, and trace levels but no luck. Is this possible?
If you happen to use Athaydes Spock Reports you can write messages to the report by using
reportInfo "This is a message"
See https://github.com/renatoathaydes/spock-reports#how-to-use-it
This is possible since V1.4.0
Don't use #Slf4j just use println. spock, junit, and so on capture standard out and add it to the test results.

How to associate a test result posted to VSTS with a testcase residing in VSTS?

We have an automation test framework written in Java.
At present, I can post a new test run to VSTS.
I can then post a new test result to the test run, eg:
{'testCaseTitle':'vstsPostTest',
'automatedTestName':'myAutomatedTestName',
'outcome':'Passed',
'errorMessage':'successfully completed vstsPostTest'}
However, when viewing the test result entry in VSTS, the testCaseTitle always seems to be overridden with value: 'myTestCaseTitle'.
Thinking this may be because I haven't associated the posted result with a testcase that resides in VSTS, I have added the testCase id parameter, and specified the ID of a random existing testCase in VSTS, eg,
{'testCaseTitle':'is title now necessary?',
'testCase'{'id':283},
'automatedTestName':'myAutomatedTestName',
'outcome':'Passed',
'errorMessage':'successfully completed vstsPostTest'}
My posted result still has the generic title 'myTestCaseTitle' - and I have seen nothing yet in VSTS which illustrates a link between the posted result and the specified testcase which resides in VSTS.
What else is necessary to:
a) Ensure that a posted result uses the specified testCaseTitle value (or receives it from the ID of the associated testCase)
b) See that either a testCase or story in VSTS is flagged as failing/passed, based on the latest testrun results. (ie, identify where stories are failing as a result of automated regression testing)
Many thanks
Try to specify test point ID:
POST: https://[team project url]/_apis/test/runs/[test run id]/results?api-version=3.0-preview
[
{
"testPoint":{
"id":XX
},
"priority": 1,
"outcome": "Passed"
}
]
You can get test point id by using Test points REST API
With thanks to Starains help. As commented: I ended up carefully following this MS post: social.msdn.microsoft.com/Forums/sqlserver/en-US/… To others reading: after a VSTS test plan, suite, case is created: post a new test run (specify plan ID), then post a new test result (specify testPoint ID, outcome, etc) then get the testResult ID and update that test result to state: Completed. This is the minimum to affect the outcome of a test case in VSTS.

jenkins nightwatch email report

Has anyone created a simple email report that Jenkins sends out when nightwatch builds fail? or event converted junit reports to email reports?
I would like the following information in a concise report:
Failures
List of code changes
Who was the last people to commit
I don't have a public version, but let me try to offer some assistance how you can combine nodemailer with nightwatch-html-reporter.
I have a working nightwatch located at https://github.com/shane-reaume/nightwatch-bones
You should be able to see where the nightwatch-html-reporter code lives in the globals.js as...
var reporter = new HtmlReporter({
openBrowser: true,
reportsDirectory: __dirname + '/reports/',
themeName: 'default',
reportFilename: os.split(' ').join('-') + '-report.html'
});
Here you are creating an html file. With that you can extract the html for your nodemailer (see https://community.nodemailer.com/).
It seems to be relatively easy if you follow the directions on each, but let me know if you have trouble and I can try to throw something together.
i suggest you to go with the email-extension plugin.
follow the documentation https://wiki.jenkins.io/display/JENKINS/Email-ext+plugin
you can mail the reports as attachements to respective emails sepperating by commas

Resources