Jenkins CLI get test result - command-line

I am trying to find out if there is a command in the Jenkin's CLI, that provides you with an xml, txt, html or some file with test results from a job that was just executed. Does any one know of such command or way to do this?
The reason I'm asking is that I'm creating a job from an xml file via Jenkin's CLI. Then, I'm executing the job I just created and once the job is complete, I'd like to use a command and get the test results.
Thank you in advanced
David

You can just save the results of your test as artifact, and download it, as the url is known to be something like http://jenkins.yourcompany.com/job/yourjob/buildId/artifact/testResults.xml

Related

Is there a way to search across all scripts in a deployment?

I have a PowerShell script module in a deployment, which defines a function that seems to be going wrong. Unfortunately, because it's in a script module, I don't know where the call to it is coming from, and it's a very large and complicated deploy with many steps.
Is there any way to run a text search for the name of this function across all scripts used in the entire deployment?
If you are using inline scripts in your deployment process you can download the entire process to a JSON file, via the overflow menu on the process edit page.
The script body for each step is contained within the property:
Octopus.Action.Script.ScriptBody.
If you are using scripts sourced from packages you will need to check in your source repositories for references to the script module function, the JSON for the step will contain the following properties:
"Octopus.Action.Script.ScriptSource": "Package",
"Octopus.Action.Script.ScriptFileName": "script1.ps1",
"Octopus.Action.Package.PackageId": "packageId",

Is there a way to pass Jenkins credentials to automation test execution command?

I have created some global credentials in Jenkins, and I want to pass them to a powershell command that starts the execution of a protractor test suite.
The credentials are created properly, the bindings are also done as you can see int he image below:
The thing is, I need these credentials to use them when running the automation tests. The powershell command that I execute is the next one:
npm run test -- --userName=${env:ECASUSER} --password=${env:ECASPWD}
After I start the job the command is called inside the windows agent as expected, triggering the tests. When the test are using those credentials to authenticate it seems they are empty strings.
In the job console log, both credentials appear to be there but displayed like this (****).
I have tried a lot of solution none of them work. Am I doing something wrong here?
After some time spent to this, I reached the conclusion that this never worked. Or maybe it did at some point but, yeah it simply stopped.
Basically, Jenkins is not passing credentials to Windows batch or Power shell commands. My automation tests were running on blanks.
The only solution, that I found to this problem, is this one:
Create a new binding: Username and Password(conjoined) - here create a new job parameter containing the credentials. Let's say the parameter is named USERPASS;
Create a new 'Windows batch command' section where you save the credentials to a file in you test project (amazingly this one works) - your credentials will be saved to the file like this: "username:password". This is how you save the credentials:
echo %USERPASS% > "%WORKSPACE%\password.txt"
Change the automation test project to retrieve the credentials from the file;
Delete the file after the tests are completed.
I believe it should have been
npm run test --userName=${ECASUSER} --password=${ECASPWD}
and make sure you don't pass unnecessary --
Let me know if that doesn't work, I have other ideas

Can I make Rundeck read a log file on the remote node as job output?

I'm using Rundeck to run remote jobs through the SSH executor. Some of the jobs I run log to specific files on the host, rather than STDOUT, and I don't have the ability to change this.
Is there any way to tell Rundeck to read those files as they get written (using something like tail -f), and treat what appears there as the job output?
Adding tail -f itself as a step wouldn't work, since it will never terminate.
If need be, a 'hacky' solution will do (like adding extra job steps for copying and reading logs) but ideally I'd like it to be neater. So if you could give me some guidelines how to build a plugin that will take the filename as a parameter and read the output from there, that would be better.
If you just want a file to read and print on STDOUT, then just use this inline script as additional step in workflow.
#!/usr/bin/python
import os,sys
file_name=sys.argv[1]
if os.path.isfile(file_name):
with open(file_name) as file:
for line in file:
print line
else:
print 'file doesnt exists'
Give file name as argument

NUnit console - when attempting to redirect output /err seems to have no effect

I've got an Nunit project with some tests and they all run as expected. Now I want to incorporate the running of these scripts automatically.
I'm trying to use some of the redirect options so I can separate the test output, but whatever combination I use, all I seem to get is the standard TestResult.xml. I can use /out:AnnotherOut.txt OK, but I'm really interested in capturing the error output using /err:TestErrors.txt.
Command line is:
(NunitConsole App) /nologo /framework:net-4.0 MyTestProject.nunit /include=Integration /err=TestErrors.txt

Where the TeamCity service messages should be written?

I'm a beginner on TeamCity, so forgive my dump question.
For some reason the coverage reporting for my solution is not working. So, to run the tests I run nunit-console in a command line step and then use the xml output file in a build feature of type [XML report processing]. Test results appear on the TeamCity GUI but no coverage statistics.
It seems to be that there a way to configure the tests reporting manually https://confluence.jetbrains.com/display/TCD8/Manually+Configuring+Reporting+Coverage but I don't know where to put these service messages:
teamcity[dotNetCoverage ='' ='' ...]
Just write them to standard output. It is captured by TeamCity and service messages from it will be processed.
Pay attention, however, to the syntax. Service message should begin with ##
As Oleg already stated you can dump them in standard output
Console.WriteLine(...) from C#
echo from command prompt or powershell,
...
Here is an example http://log.ld.si/2014/10/20/build-log-in-teamcity-using-psake
There is a psake helper module, https://github.com/psake/psake-contrib/wiki/teamcity.psm1 and source is available on https://github.com/psake/psake-contrib/blob/master/teamcity.psm1 (you can freely use this from powershell as well)
It has already implemented alot of Service Messages