提交 7c2d1e94 编写于 作者: P pgweiss

Don't fail the build when there is nothing to archive -- just warn -- provided...

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
上级 2a34cdaf
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册