Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a new overloaded version that works on a project. Updated CoreEnvironmentContributor accordingly.
- Loading branch information
Showing
5 changed files
with
93 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
test/src/test/groovy/hudson/model/EnvironmentContributorTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package hudson.model | ||
|
||
import hudson.EnvVars | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.jvnet.hudson.test.CaptureEnvironmentBuilder | ||
import org.jvnet.hudson.test.JenkinsRule | ||
import org.jvnet.hudson.test.TestExtension | ||
|
||
/** | ||
* | ||
* | ||
* @author Kohsuke Kawaguchi | ||
*/ | ||
class EnvironmentContributorTest { | ||
@Rule | ||
public JenkinsRule j = new JenkinsRule() | ||
|
||
/** | ||
* Makes sure that the project-scoped environment variables are getting consulted. | ||
*/ | ||
@Test | ||
public void testProjectScoped() { | ||
def p = j.createFreeStyleProject() | ||
def c = new CaptureEnvironmentBuilder() | ||
p.buildersList.add(c) | ||
p.description = "Issac Newton"; | ||
j.assertBuildStatusSuccess(p.scheduleBuild2(0)) | ||
|
||
assert c.envVars["ABC"]=="Issac Newton"; | ||
assert c.envVars["NODE_NAME"]=="master"; | ||
} | ||
|
||
@TestExtension("testProjectScoped") | ||
public static class JobScopedInjection extends EnvironmentContributor { | ||
@Override | ||
void buildEnvironmentFor(Job j, EnvVars envs, TaskListener listener) { | ||
envs.put("ABC",j.description) | ||
} | ||
} | ||
} |
6588f42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit causes some polling failures with the clearcase plugin. I opened JENKINS-19307 about it.