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

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?

Related

Copy artifacts from other job only if there is new version of file

We have a master and two slaves.
On Master there is a job which checks if there is new version on Nexus and if yes downloads latest jar and updates latest version (i.e. xxx-0.012.jar) in text file VERSION.TXT. (It is possible to access nexus only from master).
We need to run downloaded jar on slaves so we need to copy it from master.
We have a job which triggers few other jobs:
1)CHECK_LATEST_JAR: job which runs on master and checks if there is new version of jar on nexus, downloads it.
2)GET_JAR_TO_SLAVE: job which runs on slaves and should copy latest jar from master
3)RUN_JAR: job which gets latest jar name from file VERSION.TXT and runs jar with such name.
In CHECK_LATEST_JAR if newer version is found on nexus we download it to workspace and archive artifacts (jar + text file with latest version).
Now in GET_JAR_TO_SLAVE we wanted to use "Copy artifacts from another job" plugin - but here we need to add a condition to run this step only if there is newer version as if there are no artifacts in CHECK_LATEST_JAR this job fails..
Is there a way to compare file which is located on master with file which is located on slave?
Tried to use conditional step with groovy script - but cannot figure out how to tell it to access file on master if job runs on slave.
Just came across FSTrigger plugin which probably can be used - but same problem here how to tell it to monitor file VERSION.TXT on master and if there is a change to run job on slave.
would be grateful for any ideas how we can achieve our goal.
thanks
We found plugin Copy Data to Workspace and used it to copy file containing latest version from folder on Master to workspace of job running on one of slaves.
After that we compare content of files using Conditional BuildStep plugin strings comparison with Token macro and if files content is different we copy artifacts of the job where jar is downloaded.

Jenkins: Copy data from slave to slave

let's say we have got the following scenario:
I have two slaves on Jenkins: S-1 und S-2.
I have two Build Jobs BJ-1 und BJ-2. (BJ-1 is running on S-1, BJ-2 on S-2.)
BJ-1 generates data in his workspace
BJ-2 needs the data created bey BJ-1 in his own workspace
How can i solve this problem WITHOUT copy all the data to my master. I know i can copy the data of BJ-1 on S-1 to my master server, once the job is done and i also know i can download the data to S-2 before BJ-2 runs. But as you see i have to copy them to my Master.
The question: Is there a way to directly copy the data from S-1 to S-2?
Best way to achieve this is to archive your generated data in the post build steps in BJ-1 and copy then artifact to BJ-2 workspace.
BJ-1
Archiving artifacts is built in to Jenkins and allows you to define a file set to be available as part of the build results. Extend BJ-1 to configure what data should be archived . With that the archived data is available for further use.
BJ-2
In order to pick up the archived artifacts from another job you will need to install the Copy Artifact Plugin. In BJ-2 you add a new build step to copy artifact from a named build - with that any files matching the configured pattern will be copied into the current job's workspace. With that you can access any kind of artifacts across jobs/slave nodes etc.

Resolving Artifacts using Jenkins job with the parent directory

I am looking to download the artifacts using Jenkins job to resolve the artifacts from Artifactory. Specifying the file type and the path to the artifact works, However, unable to resolve all artifacts from the root directory.
Actual Artifactory Path:
repo_key:Group/Artifact/Version/path/to/artifact1/file.zip
repo_key:Group/Artifact/Version/path/to/artifact2/file.zip
Below Configuration in Jenkins job to Resolved Artifacts doesn't works:
repo_key:Group/Artifact/*=>Output
How do I download all files under the Artifact directory to the Output directory.
You need to use the format JBaruch mentioned and add the build metadata as matrix params, to support wildcard resolution for multiple files.
For instance:
repo_key:Group/Artifact/**/*#publishing_build_name#LATEST
Will get you the latest artifacts published by the job "publishing_build_name".
There's some helpful information and examples when clicking on the Question Mark next to the "Resolved Artifacts" field.
Artifact/* will resolve files, directly located under Artifact directory (and there are none). What you need is Artifact/**/*.

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.

teamcity ant multuple project build

I hope you guys can help me.
my problem is the following:
i have 2 projects that depend on each other each of them in different svn root.
what i do toady is build the first , take its artifact and copy it manually to where ever i want in second project and than run the second build.
i want to be able to run 1 build it can be either with a new ant build.xml file who will run the first build , copy its product to where ever i want it and than will run the second build.
second option run those 2 project with dependency in teamcity. i'm not sure how to do so and how to pass the first project artifact to be placed in the right folder i need it in the second project.
maybe someone know's how to do that.
thanks.
TeamCity's Artifact Dependencies seems to be the best option.
Suppose you have ProjectA and ProjectB:
Configure TeamCity to publish files from ProjectA:
Open General Settings configuration step of ProjectA.
Fill in Artifact paths field with relative paths to published files. TeamCity will collect these files after build finishes.
Build ProjectA to make sure artifacts are collected properly. Artifacts must become available on build results page (see Artifacts tab).
See documentation for artifacts for more details
Configure Artifact dependency for ProjectB:
Open Dependencies configuration step of ProjectB, add new artifact dependency
Depend on - select ProjectA
Get artifacts from: - use whatever you need. Possibly, last successful build.
Artifacts - enter artifacts paths from ProjectA. You can use popup to choose artifacts with UI.
Destination path - enter destination path, where artifacts will be copied to. Path is relative to checkout directory
See documentation for artifact dependencies for more details
Now each time you start build for ProjectB, it will download artifacts from last successful build of ProjectA. If you want these builds to start simultaneously, add Snapshot dependency (on ProjectA) to ProjectB. With snapshot dependency, each time you start ProjectB, it will first trigger ProjectA, wait for ProjectA build to finish and (if has artifact dependency on "last successful build" of ProjectA) download fresh artifacts.

Resources