What do I use for summary file when publishing code coverage results in TFS 2015? - tfs

Unfortunately imgur is blocked here at my workplace, so instead of screenshots of my build definition I will have to explain my build definition settings to the best of my ability.
I have two build steps, the first is a maven build step that runs the "package" goal. Under the code coverage section of the maven settings I have the CodeCoverage Tool set as "Cobertura", which is what we use on our local boxes when maven building.
My second build step is "Publish Code Coverage Results". I am not sure exactly what to put for my summary file in the settings of this build step. I think that the problem is that the build agent takes the cobertura folder off of the build machine and puts it somewhere else not on the build machine. This is the log entry for what it is doing:
Uploaded artifact 'C:\TFS_BUILD_AGENTS\agent-1\_work\3\s\target\site\cobertura' to container folder 'Code Coverage Report_35241' of build 35241.
So I either need the Summary File location for wherever it is uploading to, or I need to have it not upload the folder like it is currently doing.
This is what I have as the summary file right now, which does not work:
Code Coverage Report_$(Build.BuildId)\coverage.xml

You could check in this file to TFS and map it down to the build agent server. Then you could some build variables(like $(Build.SourcesDirectory) which represents 'C:\TFS_BUILD_AGENTS\agent-1_work\3\s') to get the file.
So you need to put C:\TFS_BUILD_AGENTS\agent-1\_work\3\...\***.xml. Make sure the file is located at the path your specified.
If the file you want to upload is generated after the step1, please check which path is locates and point it in the Summary file blanket.

Related

Download full workspace from Jenkins build

I am new to jenkins and I have tried downloading a zip archive of this workspace in jenkins, but I only get a part of it. Source folders like tensorflow or tools are not present inside the archive. Is this normal ?
If so, how do I get all of them inside a zip file ?
Use Archive Artifact plugin, to add your workspace into archive folder which will make it easily down-loadable.
But be aware that, an artifact in the Jenkins sense is the result of a build - the intended output of the build process.
A common convention is to put the result of a build into a build, target or bin directory.
The Jenkins archiver can use globs (target/*.jar) to easily pick up the right file even if you have a unique name per build.
putting a complete workspace into it will take lot of time.

Creating artifacts in jenkins

I have been tasked with looking into using Jenkins as a build server. So far I have managed to pull a project from git, restore the Nuget packages, build the project and run the unit tests. However I am struggling to find out how to generate the artifact.
The way the business would like to have the build server generate a zip file to a directory on the build server or a remote server for the systems team then to pick up and deploy to the relevant location. E.g. given a windows service project the built bin directory would be zipped up and put in the relevant artifact directory.
I thought that in order to do this I add an archive the artifacts post-build action. However I am getting the below error:
‘Watchdog.WinService.Monitor/bin/Release/*.zip’ doesn’t match anything:
‘Watchdog.WinService.Monitor’ exists but not
‘Watchdog.WinService.Monitor/bin/Release/*.zip’
If I look in the workspace for this project I can browse to the bin directory and see all the files so I unsure what I have done wrong.
Can someone please let me know if what I am trying to accomplish is possible, and also if our approach to using Jenkins is correct?
The problem is that you try to create the artifact using the archive artifatcs step.
But the step is to collect artifacts and show them on the job page.
That means you need to create the artifact first e.g. using a shell or batch script.
You can combine this with the Flexible Publish Plugin.
When you select this as post build step you can create a conditional action that runs the artifact archive task and as condition executes the script that creates the zip file.
So if that fails the task won't be executed. Also it may causes your job to 'fail' but that may not be the case in your job.

Where is the copied artifact from the previous build saved

I have two jenkins jobs which are chained. The first job will run some testNG tests , in which we may get some failures. (A testng-failed.xml file will be generated that has all the tests that failed). In my second job, I need to run using that testng-failed.xml as my suite file. So I am using jenkins copy artifact plugin and saving the testng-failed.xml file. I am able to retrive it in the second job , where it says "Copied 1 artifact from "rerun_exp" build number 7".
But the problem is I dont know where it is saved to be used as my suite file.
You can easily check where the file is by looking in the workspace.
This can even be done directly from the Jenkins web UI, via the "Workspace" link in the sidebar of the job page.
Files matched by the "Artifacts to copy" field are copied to the same directory structure as the source build had.
You can use the "Flatten directories" option if you want the file(s) to be copied to the root of the build workspace. If you click the (?) help icon to the right of that checkbox, you can see documentation for this and for your original question.

Can a Jenkins build access the archived artifacts from itself?

I'm using Jenkins and have the "Archive the Artifacts" step at the end of my builds to archive them into a zip file.
Instead of using this step, I'd like to use a script to push the artifacts to a remote server at the end of the build. The server I'm pushing to uses a REST API / HTTP PUT request in a script to upload files.
Note that I'm looking to access the artifact created in the same build. So if I'm on build #5, I want the artifacts from build #5, not build #4.
Is there any way to access this zip file with a script, in the same build that it was created in?
I need to upload this zip remotely and don't want to create another job to do so.
You can install one of the "Publish Over..." plugins to upload your artifacts at the end of a build.
The goal of the Publish Over plugins is to provide a consistent set of
features and behaviours when sending build artifacts ... somewhere.
See also the full list of "upload" plugins for other methods of publishing your artifacts.
Like #Christopher said, you can use any of the Publish Over plugins on the Jenkins Plugins page to upload the artifact to any of the
If you want to access the archived zip file from within the build itself, you can use the following link to access it:
http://<server>/job/${JOB_NAME}/lastSuccessfulBuild/artifact/<artifact name w/folder>
For example:
server = myserver.com
job name = myproject
artifact = del/project.zip
Your URL would be:
http://myserver.com/job/myproject/lastSuccessfulBuild/artifact/del/project.zip
EDIT: Question was changed. In any case, this would work for accessing the artifact of the previous build in the current one.
There is no way that I have found to access the "Archive the Artifacts" package of the build that generates it. This step always occurs last in the build. Accessing the URL prior to the build ending (during the build via script for example) results in a blank zip file. To get around this limitation, I'm making a second linked build job to grab the zip and run my script to deploy it.

Hudson/Jenkins PMD Configuration

I am new to Jenkins and just started configuring it. This is what i have done till now:
Installed and configured Jenkins to display the home page. Added PMD plugin.
Set the HUDSON_HOME to a specific directory > C:\Work\Jenkins
Configured a test build to run a simple do-nothing ant script. It runs successfully
Written an independent pmdbuild.xml to run checks on a set of files in C:\myview (I am using clearcase). This xml also copies the output pmd_results.xml to the workspace directory in $HUDSON_HOME/[job-name]/workspace
Now I added the pmdbuild.xml as a step in my primary build. So my build has 2 steps:
a. Run a simple script, do-nothing.
b. Run pmdbuild.xml which generate pmd_results.xml and place it in $HUDSON_HOME/[job-name]/workspace (HARD-CODED as Jenkins PMD plugin expects the file there)
Jenkins picks up the pmd_results.xml automatically with the plugin and displays warnings and everything.
Now the problem:
If I click on a filename in the PMD results, it gives a filenotfound exception as it is looking for the source file in $HUDSON_HOME/[job-name]/workspace.
My java code files are placed in C:\myview (a clearcase snapshot view)
My question is, do I need all my code files to be present inside $HUDSON_HOME/[job-name]/workspace ?? Meaning can't I tell Jenkins to look for the PMD input files in C:\myview or any other directory instead of $HUDSON_HOME/[job-name]/workspace ??
Sorry for the extremely long description.
Jenkins expects that all the code is in the workspace. Usually Jenkins is used to check out a copy of the code into the workspace, and then runs all build steps on the Sources in the Workspace.
Might seem restraining at first, but it saves you a lot of trouble if you need to move Jenkins to another server, or create a slave instance.
So I would suggest you let Jenkins check out your code (there should be a clearcase plugin) into the workspace, and run the analysis on the checked out code.
If there are compelling reasons why your code has to stay where it is (C:\myview in your case) you can still set the workspace of your build to that directory (find this in the job configuration page, you need to click on the 'extended' button to see the option).

Resources