Skip to content

Commit

Permalink
[JENKINS-38936] Control property injection
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Rodriguez committed Oct 12, 2016
1 parent 8b79df4 commit b18afcc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
@@ -1,6 +1,7 @@
package org.jenkinsci.test.acceptance.plugins.maven;

import org.jenkinsci.test.acceptance.po.*;
import org.openqa.selenium.NoSuchElementException;

/**
* @author Kohsuke Kawaguchi
Expand All @@ -22,9 +23,18 @@ public MavenBuildStep useLocalRepository() {
return this;
}

public MavenBuildStep properties(String properties) {
public MavenBuildStep properties(String properties, boolean inject) {
ensureAdvanced();
control("properties").set(properties);
if (inject) {
// After the fix for JENKINS-25416 (core >= 2.12) we must explicitly say if we want the variables injected
// as properties into maven process.
try {
control("injectBuildVariables").check(true);
} catch (NoSuchElementException e) {
// Nothing, we are in core < 2.12
}
}
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/plugins/JacocoPluginTest.java
Expand Up @@ -37,7 +37,7 @@ public void checkSuccessfulExecutionAndsummary() {
// starting with version 2.0.0 uses JaCoCo 0.7.5 and thus requires also this version to be used in your projects. Please stick to JaCoCo plugin
// 1.0.19 or lower if you still use JaCoCo 0.7.4 or lower
boolean old = jenkins.getPlugin("jacoco").getVersion().isOlderThan(new VersionNumber("2.0.0"));
maven.properties("jacoco.version=" + (old ? "0.7.4.201502262128" : "0.7.5.201505241946"));
maven.properties("jacoco.version=" + (old ? "0.7.4.201502262128" : "0.7.5.201505241946"), true);

JacocoPublisher publisher = job.addPublisher(JacocoPublisher.class);
publisher.changeBuildStatus.check();
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/plugins/MavenPluginTest.java
Expand Up @@ -145,7 +145,7 @@ public void preserve_backslash_in_property() {

MavenBuildStep step = job.addBuildStep(MavenBuildStep.class);
step.targets.set(GENERATE + " -Dcmdline.property=$CMD");
step.properties("property.property=$PROPERTY");
step.properties("property.property=$PROPERTY", true);
job.save();

Map<String, String> params = new HashMap<>();
Expand Down

0 comments on commit b18afcc

Please sign in to comment.