Jenkins Build fails when artifacts are not there
Asked Answered
C

2

8

I use Jenkins to run some integration tests on a web appilcation (using cucumber, capybara and selenium)

Everytime a test fails, a screenshot, the HTML source and a video of the process is saved.

the path structure looks like this:

results/output/<test_name>/<files>

I use the archive artifacts feature of Jenkins to provide the files (pattern: results/output/*/*). It works great.

However as soon as a build succeeds, there are no screenshots/videos etc... and the build fails because Jenkins cannot find the files for the pattern.

Is there a way to tell Jenkins to succeed without having the files present?

I don't want to do a dirty hack which involves creating an empty folder structure like result/output/success/hooray.txt.

Curnin answered 23/12, 2011 at 14:11 Comment(1)
Good question; I was wondering about the exact same thing!Dogy
D
4

I ran into a similar issue on a couple of our projects. There are two different ways we have resolved it (on two different builds).

1) Added a command to the build steps that creates a bogus temporary file if no files already existed.

In this case, it was meant to collect an output.pdf file that would be generated if the tests failed. I added a build step where if that file did not exist we created a "missing.pdf" file. Then what I collect as artifacts is '*.pdf' from the given directory. This seems to work out pretty well.

2) On another build we needed to collect a set of files using a glob.

What we did here was made it so the build step always creates a single empty file in the destination area. That way the glob always matches something.

Those are the best solutions we have found so far. If you find something better I would love to hear about it.

Doner answered 23/12, 2011 at 14:17 Comment(1)
I added a step that created a success.txt when the folder was empty after the buildCurnin
U
13

There's an open issue on for that: https://issues.jenkins-ci.org/browse/JENKINS-10502

The behavior is controlled by the system property hudson.tasks.ArtifactArchiver.warnOnEmpty, as explained on https://wiki.jenkins-ci.org/display/JENKINS/Features+controlled+by+system+properties

Uncomfortable answered 21/3, 2012 at 13:6 Comment(2)
+1, I think this is the correct answer. (If anyone else is wondering how to get this working with Jenkins running on Debian/Ubuntu, edit /etc/default/jenkins and put -Dhudson.tasks.ArtifactArchiver.warnOnEmpty=true in JAVA_ARGS (or possibly JENKINS_JAVA_OPTIONS). JENKINS_ARGS won't work, at least if you have more than one -D property!Dogy
Still, as someone comments in the issue you linked to, shame that this can't be configured with a checkbox in Jenkins UI on a per-job basis.Dogy
D
4

I ran into a similar issue on a couple of our projects. There are two different ways we have resolved it (on two different builds).

1) Added a command to the build steps that creates a bogus temporary file if no files already existed.

In this case, it was meant to collect an output.pdf file that would be generated if the tests failed. I added a build step where if that file did not exist we created a "missing.pdf" file. Then what I collect as artifacts is '*.pdf' from the given directory. This seems to work out pretty well.

2) On another build we needed to collect a set of files using a glob.

What we did here was made it so the build step always creates a single empty file in the destination area. That way the glob always matches something.

Those are the best solutions we have found so far. If you find something better I would love to hear about it.

Doner answered 23/12, 2011 at 14:17 Comment(1)
I added a step that created a success.txt when the folder was empty after the buildCurnin

© 2022 - 2024 — McMap. All rights reserved.