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

« back to all changes in this revision

Viewing changes to core/src/main/java/jenkins/mvn/GlobalSettingsProvider.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:
 
1
package jenkins.mvn;
 
2
 
 
3
import hudson.ExtensionPoint;
 
4
import hudson.FilePath;
 
5
import hudson.model.AbstractBuild;
 
6
import hudson.model.AbstractDescribableImpl;
 
7
import hudson.model.Descriptor;
 
8
import hudson.model.TaskListener;
 
9
 
 
10
import javax.servlet.ServletException;
 
11
 
 
12
import net.sf.json.JSONObject;
 
13
 
 
14
import org.kohsuke.stapler.StaplerRequest;
 
15
 
 
16
/**
 
17
 * @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
 
18
 * @author Dominik Bartholdi (imod)
 
19
 * @since 1.491
 
20
 */
 
21
public abstract class GlobalSettingsProvider extends AbstractDescribableImpl<GlobalSettingsProvider> implements ExtensionPoint {
 
22
 
 
23
    /**
 
24
     * configure maven launcher argument list with adequate settings path
 
25
     * 
 
26
     * @param build
 
27
     *            the build to provide the settigns for
 
28
     * @return the filepath to the provided file. <code>null</code> if no settings will be provided.
 
29
     */
 
30
    public abstract FilePath supplySettings(AbstractBuild<?, ?> build, TaskListener listener);
 
31
 
 
32
    public static GlobalSettingsProvider parseSettingsProvider(StaplerRequest req) throws Descriptor.FormException, ServletException {
 
33
        JSONObject settings = req.getSubmittedForm().getJSONObject("globalSettings");
 
34
        if (settings == null) {
 
35
            return new DefaultGlobalSettingsProvider();
 
36
        }
 
37
        return req.bindJSON(GlobalSettingsProvider.class, settings);
 
38
    }
 
39
 
 
40
    /**
 
41
     * Convenience method handling all <code>null</code> checks. Provides the path on the (possible) remote settings file.
 
42
     * 
 
43
     * @param settings
 
44
     *            the provider to be used
 
45
     * @param build
 
46
     *            the active build
 
47
     * @param listener
 
48
     *            the listener of the current build
 
49
     * @return the path to the global settings.xml
 
50
     */
 
51
    public static final FilePath getSettingsFilePath(GlobalSettingsProvider settings, AbstractBuild<?, ?> build, TaskListener listener) {
 
52
        FilePath settingsPath = null;
 
53
        if (settings != null) {
 
54
            try {
 
55
                settingsPath = settings.supplySettings(build, listener);
 
56
            } catch (Exception e) {
 
57
                listener.getLogger().print("failed to get the path to the alternate global settings.xml");
 
58
            }
 
59
        }
 
60
        return settingsPath;
 
61
    }
 
62
 
 
63
    /**
 
64
     * Convenience method handling all <code>null</code> checks. Provides the path on the (possible) remote settings file.
 
65
     * 
 
66
     * @param settings
 
67
     *            the provider to be used
 
68
     * @param build
 
69
     *            the active build
 
70
     * @param listener
 
71
     *            the listener of the current build
 
72
     * @return the path to the global settings.xml
 
73
     */
 
74
    public static final String getSettingsRemotePath(GlobalSettingsProvider provider, AbstractBuild<?, ?> build, TaskListener listener) {
 
75
        FilePath fp = getSettingsFilePath(provider, build, listener);
 
76
        return fp == null ? null : fp.getRemote();
 
77
    }
 
78
 
 
79
}