Some questions on ArtifactArchiver for a pipeline script

1,996 views
Skip to first unread message

Kristian

unread,
Jan 11, 2017, 5:27:05 AM1/11/17
to jenkins...@googlegroups.com
Hey,

I have some questions on the ArtifactArchiver. I have several
projects, where the artifacts are copied into a special directory,
which is not a subfolder of the directory where the source code lies /
where the compilation is done.

For example, my source code lies at /home/user/project and after the
compilation and linking is done, the artifacts (in sometimes they are
already zipped) are copied into /home/user/artifacts.

Now, I want Jenkins pipeline to search there for the artifacts / zip
files. I already tried several ways of finding that directory.

stage('archive') {
step([$class: 'ArtifactArchiver', artifacts:
"**/../artifacts/*", fingerprint: true])

step([$class: 'ArtifactArchiver', artifacts:
"../artifacts/*", fingerprint: true])

step([$class: 'ArtifactArchiver', artifacts:
"**/artifacts/*", fingerprint: true])

step([$class: 'ArtifactArchiver', artifacts:
"artifacts/*", fingerprint: true])

step([$class: 'ArtifactArchiver', artifacts:
"/home/user/artifacts/*", fingerprint: true])
}

None of them worked i.e. the build always failed. What I am doing wrong here?

Another question is: Is there a way to give me some verbose output
when using ArtifactArchiver for debugging purposes?

jer...@bodycad.com

unread,
Jan 11, 2017, 10:38:55 AM1/11/17
to Jenkins Users

Use:
println(pwd());
that should help you determine current working directory.

If the /home/user/project is the current working directory where the project is checkout and you are looking at /home/user/artifacts for the zip files:

archiveArtifacts artifacts: "../artifacts/**/*.zip", excludes: "../artifacts/notIncluded/**/*.zip", fingerprint: true, allowEmptyArchive: false, onlyIfSuccessful: true;

Note, you don't need the step(([$class:]) wrapper anymore, make it easier to read into recent Jenkins. you can also change the path before calling archive (I haven't test it but it should work, make it more compact and easier to maintain and understand):
dir("../artifacts")
{
 
archiveArtifacts artifacts: "**/*.zip" ...
}



Kristian

unread,
Jan 12, 2017, 5:08:31 AM1/12/17
to jenkins...@googlegroups.com
Thank you for your answer. This worked very well!
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-use...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/ee8e98cd-6527-4e67-9da4-7d47f657b76e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages