archive file zips when doing an Artifacts in Jenkins - jenkins

The problem is the folowing:
I have two jenkins jobs A and B.
In the A job, I use the post-build Action: Archive the artifacts, to Archive 4 .jar files: the problem is that, unlike only archiving one file, the folder archive zips: so archive is archive.zip and inside that zip I have the 4 jars.
The in B I use the Copy Artifact Plugin to copy the artifacts from A to B and the error is the folowing:
Unable to access upstream artifacts area C:\***\builds\15\archive. Does source project archive artifacts?
ERROR: Failed to copy artifacts from 1PrepareAndCompileSquemas with filter: *.jar
The *** are folders in the middle.
If I take the archive.zip file, i unzip it and Y put in a folder called archive in the same path, the jobs works correctly so the problem is that when at A I save the artifacts those are saved to a .zip file
there is any way to save this artifacts without ziping the archive folder?

The problem was because I have configurated an option to compress the artifacts at Global confiiguration

Related

zip artifacts in Jenkins

I would like to get a zip file with artifacts.
The archiveArtifacts directive in Jenkinsfile will save each artifact,
but when you download it you will get a zip files with original paths in it.
Is it possible to avoid original paths with a directive or am I obliged to
run a script that callects all artifacts in one single folder in the workspace and zip the folder then?

Archive only the latest .png files in a katalon jenkins job

I need to archive any .png screenshots of the latest katalon test run in Jenkins as a post-build step of the same test run.
Using the "archive the artifacts" post-build action in Jenkins, I currently have the file path set to Reports/**/[test run name]/**/*.png where Reports is in the workspace directory. However this will just pull every .png file from the current and all previous test runs stored there, of which are kept stored in the workspace for a week before being cleaned out.
I've tried using the "Exclude" field but haven't been able to figure out a way to exclude older files with only being able to use a file path with wildcards.
Is there a way in Jenkins, using archive the artifacts or something else, to archive just the .png files generated by the same job without deleting all previously generated .png files?
From our experience, it's better to keep the artifacts archived with the job and not rely on files residing in the workspace together with a separate job to clean them. You can tell Jenkins to discard old builds (and artifacts) with something like this:
pipeline {
options {
buildDiscarder(logRotator(daysToKeepStr: '7', artifactDaysToKeepStr: '7'))
}
}
And any jobs (and their artifacts) will be cleaned after 7 days.
If you go with that path, you can safely remove any png files after archiving them as artifacts, and you won't need to find out which are new and which are old.
Alternatively, you can order your png-producing step to name the files starting with the job number (available as env.BUILD_NUMBER) and only archive the files starting with this number.
Finally, you can run find command with -name '*png' and -mtime predicate to produce the list of recently modified png files, and use that as an input to the archive step.

How can I use Artifact Deployer to copy from the archived artifacts, instead of the workspace?

We've been using Jenkins for a while, now, and have used the ArtifactDeployer plugin to copy build artifacts out of the working directory to our artifact repository fileshares.
I'm working on a new deployment promotion job, that needs to obtain the artifacts of a given build, and I thought I might use the Copy Artifact plugin. But that expects that the artifacts be saved using Jenkin's artifact archive feature, which we've not been using.
There are some nice features, in the Copy Artifact plugin - we can configure it to specify the upstream build that triggered the job, rather than having to pass a specific build number as a parameter. But to use it, we'd need to configure archive.
But we still need to copy artifacts to our artifact repository fileshares, which means we have to specify the files we want to archive twice - once in the archive config and once in the ArtifactDeployer config.
Unless we can configure the ArtifactDeployer plugin to copy the contents of the archive directory.
Is this possible?
What would be the path?

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.

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.

Resources