jenkins + ghprbhook - how to set status message? - github

I've installed the ghprbhook plugin to my jenkins system. It triggers when I send a PR but isn't setting the result text properly. The 'success' / 'failure' message is working but the rest is Build finished. No test results found.
The disconnect seems to be between the gradle build plugin and the ghprbhook service. In the ghprbhook source it's checking for hudson.tasks.junit.TestResultAction to be set and apparently it isn't.
Question:
Is it possible to have gradle set the appropriate values? If so, how?

Turns out that I was looking in the wrong place. The way to get useful values to show up in github is to add the Publish JUnit Test Result Report post-build step to your jenkins job. Assuming that you have gradle and junit outputting xml you should see the output in github when you build.

Related

VS Code Extension tests not found on Azure Pipeline

I have an extension, initially created using the standard yo code template, and successfully uploaded to the market place. I have created a test suite, which works correctly when running locally (i.e. pressing F5), and I now wanted to add CI testing to the Github repo.
I followed the instructions on Continuous Integration and created a config file. The extension now builds successfully, however it appears that no tests are discovered.
For example, in this build I intentionally introduced a failing test, but it still passes.
Is there a step I'm missing or a good way to debug the problem?
See the Issue I opened for the answer. Currently, the tests fail silently if you do not have the required dependencies listed.

How to send REST request with build parameters in Jenkins Post Build Actions?

I am working on a CI system with Jenkins. But now I got a problem. I need to do the following steps.
1:Jenkins build
2:Deploy to Tomcat
3:find a way to send the build parameters (Job Name, build number...) to a web server (I am using REST now).
4:Web Server trigger testing system.
5:Jenkins get the result from testing system.
6:update build status
7:send emails.
I have problem with the step 3. I need to send those info after the deploy. I am thinking a way as following.
write those parameters to a file during build step, then call a script or Java problem to process the file and send out those info by REST.
But that is ugly. Is there any better ways to do it?
Side questions
Can groovy do this?
How to import groovy http-builder library to Jenkins?
I found a walk around solution.
1: ran echo command during the build to get the build ID and print to log.
2:wrote a small Java program to get the JSON response of the build then sent the necessary info as rest request to the server you set. The program is like a message forwarder.
3:in post build actions, use groovy post build to fetch the log then call the Java program.

Why don't my artifacts published during the build using the publishArtifacts service message show up in TeamCity?

I am creating a screenshot when my NUnit end-to-end test fails and I am trying to publish it with TeamCity (build agent and server both running on Windows) using the following service message (as described here) which I am writing with Console.WriteLine from an NUnit test:
##teamcity[publishArtifacts 'C:\BuildAgent\work\xxxxxxxxxxxxxxxx\Path\To\My\Stuff\fail.png']
I see the line in the build log:
------- Stdout: -------
##teamcity[publishArtifacts 'C:\BuildAgent\work\xxxxxxxxxxxxxxxx\Path\To\My\Stuff\fail.png']
But TeamCity is not picking up the file, or at least it is not showing up in the build artifacts. How do I make this work?
Try using relative paths. Teamcity should resolve them against build working directory.
You can try Console.Write instead of Console.WriteLine (see below).
Anyway, I guess TeamCity don't trap these messages because they are 'test reports' and appended in the buildlog as text output.
My feeling is they are not parsed and then not interpreted by the Build Script Interaction behavior because of the way they are flushed into the build log.
From the Build Script Interaction (TC 7) :
Service messages are used to pass commands/build information to
TeamCity server from the build script. In order to be processed by
TeamCity they should be printed into standard output stream of the
build (otherwise, if the output is not in the service message syntax,
it should appear in the build log). A single service message should
not contain a newline character inside it, it should not span across
multiple lines.
You should put your test artifacts in a specific folder and delay the publish after the tests.
Note that if you don't need to resolve artifact dynamically, you should use the simpliest way : the Artifact paths in the build configuration general settings.
Use the NuGet package provided by JetBrains, this takes care of all the subtleties
NuGet Install TeamCity.ServiceMessages
On GitHub: https://github.com/JetBrains/TeamCity.ServiceMessages

Fail build via REST API with TeamCity, from another build config, after build is already finished

I have some integration tests that get kicked off by TeamCity on a successful build. I have had success using the TeamCity REST API in order to tag the build as passed or failed, but would actually like to mark the build status as passed or failed (in the same way builds are failed due to compilation or unit test failures).
The documentation for the REST API is pretty sparse. Is it just not possible to do this through the REST API or is it undocumented?
Clarification:
Current process is as follows:
"App" TC Build configuration actually builds the application and runs the unit tests.
"Test" TC Build configuration depends on "App" configuration completing successfully. If "App" builds successfully (no compile or unit test failures), "Test" configuration kicks off, which pulls down the build artifacts and runs the live integration tests on the application. Prior to these tests being run, "App" configuration has a status of passing, since it compiled successfully and there were no unit test failures.
What I am trying to do is to change "App" config status to failed, if the "Test" configuration failed. Currently I am merely tagging "App" as passed or failed, but the actual build status is always passing. Essentially I am trying to get the change log or history to show the red X icon for a failed build, rather than the green check mark.
"App" and "Test" are 2 separate TeamCity build configurations. Since they are separate, Build Script Interaction, as suggested by #sharma, will not do the trick, since Build Script Interaction can be used to fail/update the currently running build configuration, whereas I am trying to update/fail a separate and already completed build configuration.
Why do we have 2 separate configs and not just run the tests from the main build? Speed of course! The integration tests take up to 10 minutes to run, and we don't want to slow down the compile cycle just because the integration tests are running.
Actually you can change build status even after build finished with the following non-documented request (you need buildId of build you want to change):
curl -v --request POST "http://your-teamcity-url/ajax.html" -u login:password --data "comment=Your reason to fail build" --data "status=FAILURE" --data "changeBuildStatus=buildId"
You should be able to do it through build Interaction scripts.
UPDATE: Look here, It should have "reporting messages for build logs". If you have following message printed to console in which ever application build you are running. The teamcity build will fail and show as error. If you change status to Failure it will still fail. You have more information on the link I provided. An example message you may want to printout:
"##teamcity[message text='Exception text' errorDetails='stack trace' status='ERROR']"
Look at this
So the answer to my original question, is it possible to use REST API to mark build as failed from another build configuration, is that it is not possible.
Per TeamCity support: There is no way to change a build status after it has been finished. This is not a limitation of REST API, this is just not implemented feature of TeamCity.
Here is a related feature request in our tracker: http://youtrack.jetbrains.net/issue/TW-2529
(I upvoted #sharma's answer and comments, as they were definitely informative, but ultimately not a solution to my problem.)

Problem Publishing NUnit Testing Result Reports with Hudson

I am facing a problem with Hudson and NUnit testing. When trying to publish the Test Result Report for NUnit, the option in Hudson, i.e., "Publish NUnit Test Result Reports", is creating a problem. I am unable to provide the Path of the already-created XML file under the workspace folder of the Job. When I set the path of my file, i.e., "nunit-result.xml" and run the job, it throws an error:
"No test report files were found. Configuration error?"
Can anyone please help me out?
Thanks in advance.
Check the the beginning of the log where the clone is made. Sometimes when you have the "Enable concurrent builds" option it triggers another build in a different workspace called your-project-name#2/source and that's why it can't find the reports