File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\model\BuildVariableContributor.java.html

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2010, CloudBees, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 package hudson.model;
25
26 import hudson.ExtensionList;
27 import hudson.ExtensionPoint;
28 import hudson.tasks.Builder;
29 import hudson.tasks.Publisher;
30 import jenkins.model.Jenkins;
31
32 import java.util.Map;
33
34 /**
35 * Contributes build variables to builds.
36 *
37 * <p>
38 * This extension point can be used to externally add build variables, which are then used for
39 * various parameter expansions by {@link Builder}s and {@link Publisher}s. Aside from adding variables
40 * of the fixed name, a typical strategy is to look for specific {@link JobProperty}s and other similar configurations
41 * of {@link Job}s to compute values.
42 *
43 * @author Kohsuke Kawaguchi
44 * @since 1.403
45 * @see EnvironmentContributor
46 */
47 public abstract class BuildVariableContributor implements ExtensionPoint {
48 /**
49 * Contributes build variables used for a build.
50 *
51 * <p>
52 * This method can be called repeatedly for the same {@link AbstractBuild}, thus
53 * the computation of this method needs to be efficient. If you have a time-consuming
54 * computation, one strategy is to take the hit once and then add the result as {@link InvisibleAction}
55 * to {@link AbstractBuild}, then reuse those values later on.
56 *
57 * <p>
58 * This method gets invoked concurrently for multiple {@link Run}s that are being built at the same time,
59 * so it must be concurrent-safe.
60 *
61 * @param build
62 * Build that's being performed. Never null.
63 * @param variables
64 * Partially built variable map. Implementation of this method is expected to
65 * add additional variables here. Never null.
66 */
67 public abstract void buildVariablesFor(AbstractBuild build, Map<String,String> variables);
68
69 /**
70 * Returns all the registered {@link EnvironmentContributor}s.
71 */
72 public static ExtensionList<BuildVariableContributor> all() {
73 return Jenkins.getInstance().getExtensionList(BuildVariableContributor.class);
74 }
75 }
76