~ubuntu-branches/ubuntu/trusty/jenkins/trusty

« back to all changes in this revision

Viewing changes to core/src/main/java/hudson/tasks/ArtifactArchiver.java

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-13 12:35:19 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20130813123519-tizgfxcr70trl7r0
Tags: 1.509.2+dfsg-1
* New upstream release (Closes: #706725):
  - d/control: Update versioned BD's:
    * jenkins-executable-war >= 1.28.
    * jenkins-instance-identity >= 1.3.
    * libjenkins-remoting-java >= 2.23.
    * libjenkins-winstone-java >= 0.9.10-jenkins-44.
    * libstapler-java >= 1.207.
    * libjenkins-json-java >= 2.4-jenkins-1.
    * libstapler-adjunct-timeline-java >= 1.4.
    * libstapler-adjunct-codemirror-java >= 1.2.
    * libmaven-hpi-plugin-java >= 1.93.
    * libjenkins-xstream-java >= 1.4.4-jenkins-3.
  - d/maven.rules: Map to older version of animal-sniffer-maven-plugin.
  - Add patch for compatibility with guava >= 0.14.
  - Add patch to exclude asm4 dependency via jnr-posix.
  - Fixes the following security vulnerabilities:
    CVE-2013-2034, CVE-2013-2033, CVE-2013-2034, CVE-2013-1808
* d/patches/*: Switch to using git patch-queue for managing patches.
* De-duplicate jars between libjenkins-java and jenkins-external-job-monitor
  (Closes: #701163):
  - d/control: Add dependency between jenkins-external-job-monitor ->
    libjenkins-java.
  - d/rules: 
    Drop installation of jenkins-core in jenkins-external-job-monitor.
  - d/jenkins-external-job-monitor.{links,install}: Link to jenkins-core
    in /usr/share/java instead of included version.
* Wait longer for jenkins to stop during restarts (Closes: #704848):
  - d/jenkins.init: Re-sync init script from upstream codebase.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
import java.io.IOException;
42
42
 
43
43
import net.sf.json.JSONObject;
 
44
import javax.annotation.Nonnull;
44
45
 
45
46
/**
46
47
 * Copies the artifacts into an archive directory.
63
64
     * Just keep the last successful artifact set, no more.
64
65
     */
65
66
    private final boolean latestOnly;
66
 
    
67
 
    private static final Boolean allowEmptyArchive = 
68
 
        Boolean.getBoolean(ArtifactArchiver.class.getName()+".warnOnEmpty");
 
67
 
 
68
    /**
 
69
     * Fail (or not) the build if archiving returns nothing.
 
70
     */
 
71
    @Nonnull
 
72
    private Boolean allowEmptyArchive;
 
73
 
 
74
    public ArtifactArchiver(String artifacts, String excludes, boolean latestOnly) {
 
75
        this(artifacts, excludes, latestOnly, false);
 
76
    }
69
77
 
70
78
    @DataBoundConstructor
71
 
    public ArtifactArchiver(String artifacts, String excludes, boolean latestOnly) {
 
79
    public ArtifactArchiver(String artifacts, String excludes, boolean latestOnly, boolean allowEmptyArchive) {
72
80
        this.artifacts = artifacts.trim();
73
81
        this.excludes = Util.fixEmptyAndTrim(excludes);
74
82
        this.latestOnly = latestOnly;
 
83
        this.allowEmptyArchive = allowEmptyArchive;
 
84
    }
 
85
 
 
86
    // Backwards compatibility for older builds
 
87
    public Object readResolve() {
 
88
        if (allowEmptyArchive == null) {
 
89
            this.allowEmptyArchive = Boolean.getBoolean(ArtifactArchiver.class.getName()+".warnOnEmpty");
 
90
        }
 
91
        return this;
75
92
    }
76
93
 
77
94
    public String getArtifacts() {
85
102
    public boolean isLatestOnly() {
86
103
        return latestOnly;
87
104
    }
 
105
 
 
106
    public boolean getAllowEmptyArchive() {
 
107
        return allowEmptyArchive;
 
108
    }
88
109
    
89
110
    private void listenerWarnOrError(BuildListener listener, String message) {
90
111
        if (allowEmptyArchive) {
101
122
            build.setResult(Result.FAILURE);
102
123
            return true;
103
124
        }
104
 
        
 
125
 
105
126
        File dir = build.getArtifactsDir();
106
127
        dir.mkdirs();
107
128
 
136
157
            Util.displayIOException(e,listener);
137
158
            e.printStackTrace(listener.error(
138
159
                    Messages.ArtifactArchiver_FailedToArchive(artifacts)));
 
160
            build.setResult(Result.FAILURE);
139
161
            return true;
140
162
        }
141
163