diff --git a/changelog.html b/changelog.html index c713474821312ed70dd81a6b1a4cec486aa23ac8..34f6822ab7a0f9163b1ac86d618bfc3b2f025d24 100644 --- a/changelog.html +++ b/changelog.html @@ -63,6 +63,9 @@ Upcoming changes
+ * When building environment variables for a build, Jenkins will also invoke + * {@link #buildEnvironmentFor(Job, EnvVars, TaskListener)}. This method only needs to add + * variables that are scoped to builds. + * * @param r * Build that's being performed. Never null. * @param envs @@ -81,7 +86,29 @@ public abstract class EnvironmentContributor implements ExtensionPoint { * @param listener * Connected to the build console. Can be used to report errors. Never null. */ - public abstract void buildEnvironmentFor(Run r, EnvVars envs, TaskListener listener) throws IOException, InterruptedException; + public void buildEnvironmentFor(Run r, EnvVars envs, TaskListener listener) throws IOException, InterruptedException {} + + /** + * Contributes environment variables used for a job. + * + *
+ * This method can be called repeatedly for the same {@link Job}, thus + * the computation of this method needs to be efficient. + * + *
+ * This method gets invoked concurrently for multiple {@link Job}s,
+ * so it must be concurrent-safe.
+ *
+ * @param j
+ * Job for which some activities are launched.
+ * @param envs
+ * Partially built environment variable map. Implementation of this method is expected to
+ * add additional variables here. Never null.
+ * @param listener
+ * Connected to the build console. Can be used to report errors. Never null.
+ * @since 1.527
+ */
+ public void buildEnvironmentFor(Job j, EnvVars envs, TaskListener listener) throws IOException, InterruptedException {}
/**
* Returns all the registered {@link EnvironmentContributor}s.
diff --git a/core/src/main/java/hudson/model/Job.java b/core/src/main/java/hudson/model/Job.java
index cdd6edb367ed1603e3e6539069d32f06f189a400..c444c2d2a19b33cd3a2f4ea40183359e7fca24ec 100644
--- a/core/src/main/java/hudson/model/Job.java
+++ b/core/src/main/java/hudson/model/Job.java
@@ -369,6 +369,11 @@ public abstract class Job