mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-08 01:26:03 +00:00
Don't fail the build when there is nothing to archive -- just warn -- provided system property hudson.tasks.ArtifactArchiver.warnOnEmpty=true
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@21652 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
2a34cdafe6
commit
7c2d1e9455
1 file changed
+16
-3
@@ -64,6 +64,9 @@ public class ArtifactArchiver extends Recorder {
|
||||
* Just keep the last successful artifact set, no more.
|
||||
*/
|
||||
private final boolean latestOnly;
|
||||
|
||||
private static final Boolean allowEmptyArchive =
|
||||
Boolean.getBoolean(ArtifactArchiver.class.getName()+".warnOnEmpty");
|
||||
|
||||
@DataBoundConstructor
|
||||
public ArtifactArchiver(String artifacts, String excludes, boolean latestOnly) {
|
||||
@@ -83,6 +86,14 @@ public class ArtifactArchiver extends Recorder {
|
||||
public boolean isLatestOnly() {
|
||||
return latestOnly;
|
||||
}
|
||||
|
||||
private void listenerWarnOrError(BuildListener listener, String message) {
|
||||
if (allowEmptyArchive) {
|
||||
listener.getLogger().println(String.format("WARN: %s", message));
|
||||
} else {
|
||||
listener.error(message);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException {
|
||||
if(artifacts.length()==0) {
|
||||
@@ -106,12 +117,14 @@ public class ArtifactArchiver extends Recorder {
|
||||
if(build.getResult().isBetterOrEqualTo(Result.UNSTABLE)) {
|
||||
// If the build failed, don't complain that there was no matching artifact.
|
||||
// The build probably didn't even get to the point where it produces artifacts.
|
||||
listener.error(Messages.ArtifactArchiver_NoMatchFound(artifacts));
|
||||
listenerWarnOrError(listener, Messages.ArtifactArchiver_NoMatchFound(artifacts));
|
||||
String msg = ws.validateAntFileMask(artifacts);
|
||||
if(msg!=null)
|
||||
listener.error(msg);
|
||||
listenerWarnOrError(listener, msg);
|
||||
}
|
||||
if (!allowEmptyArchive) {
|
||||
build.setResult(Result.FAILURE);
|
||||
}
|
||||
build.setResult(Result.FAILURE);
|
||||
return true;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
Reference in new issue
Block a user