Where is the copied artifact from the previous build saved - jenkins

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.

Related

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

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.

Can JENKINS create build by excluding particular files?

I am actually trying to ignore a particular file to be included in the build. Actually it is a thumb.db file which is automatically created whenever images are encountered in a folder. My solution contains the image folder. So basically, whenever the build is triggered from JENKINS, it will create the thumb.db file.
Is there any way, I can ignore the Thumb.db file from getting created via JENKINS?
I can switch off the thumb.db file from creation by switching it off from my windows, but I have to do it every time a build is created from JENKINS. So I want to ignore the thumb.db file from creation.
Below is the Job creation flow in my JENKINS from my current project:
SCM
I have used the Team Foundation Server Plugin and have mentioned my SERVER URL and PROJECT PATH
POST BUILD steps simply create the build to the staging location(folder Location)
Any help is appreciated.
Thanks,
AFAIK, on windows you can turn it off or on for the whole system and not for particular folders.
So you have to choose. On or off.
If you still want to keep it on, you'l have to handle this in your Jenkins build scripts. Remove any thumbs.db files after build is done.
If your output is an archive, make sure to exclude thumbs.db from it. All archives support an exclude flag.
I hope this helps.

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.

How to customize file name of Jenkins archive artifact plugin post build action?

Jenkins archive artifact plugin compress files into "archive.zip" file. It has always the same file name. Even more, Jenkins doesn't archive actually(there is no any "archive.zip" files in "builds" directories). Jenkins just map url
https://www.my-jenkins-server.com/jenkins/job/$job_name/$job_number/artifact/*zip*/archive.zip
and always return everything in job directory, those matches to pattern configured in post build action archive artifact plugin.
Problem is, that job itself generates ZIP archive, so I need to publish this archive under original name. It is important, since archive's name clarify owner of job, data inside, parameters used to run job. Let's say users ran job 10 times using different parameters and don't wait each job to finish before to run next. Later user will start download results and get
archive.zip
archive(1).zip
archive(2).zip
...
archive(10).zip
Now he needs to extract archives from those downloaded archives, to get 10 another archives with qualified names. Then delete those downloaded archive. After that, identify by qualified archive name those he needs actually and delete rest of then. Easy to make mistake here, delete or miss archive file.
Solutions for me are:
Publish generated by job archive under it's original name.
Generate my files and form file name of archive under with it should be served, skip zipping inside of job. Final step, pass this file name as parameter into archive artifact plugin post build action, so Jenkins will serve archive under special name configured by job itself.
The name of the zip file is determined from the directory that contains the artifacts (see Jenkins source).
Internally, the top-most artifact directory has the name archive, that's why you will always see archive.zip.
Conversely, this means that you can get a custom zip file xyz.zip by putting the artifacts in a (sub-)directory xyz.
There are no other options to change the name.
You can run any post-build script (shell/batch/powershell) after the archive step, and rename archive.zip to archive_${BUILD_NUMBER}.zip so that you can easily track of the archive by the last successful build number of the job. But to do this, first you need to clean the workspace to keep a track of the archive files based on the build number.

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