Skip to content

Commit

Permalink
[JENKINS-30885] Support variables for input fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Thierry Lacour authored and MadsNielsen committed Oct 12, 2015
1 parent ad7569e commit f93843a
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 58 deletions.
Expand Up @@ -13,6 +13,7 @@
import org.kohsuke.stapler.DataBoundConstructor;
import jenkins.model.Jenkins;
import hudson.DescriptorExtensionList;
import hudson.EnvVars;
import hudson.ExtensionPoint;
import hudson.Launcher;
import hudson.model.BuildListener;
Expand Down Expand Up @@ -44,6 +45,10 @@ public String getBranch() {
return branch;
}

public String getExpandedBranch(EnvVars environment) {
return environment.expand(branch);
}

public Descriptor<AbstractSCMBridge> getDescriptor() {
return (SCMBridgeDescriptor<?>) Jenkins.getInstance().getDescriptorOrDie(getClass());
}
Expand Down Expand Up @@ -124,7 +129,7 @@ public void isApplicable(AbstractBuild<?,?> build, BuildListener listener) throw
* @param listener
* @return
*/
protected Commit<?> determineIntegrationHead(AbstractBuild<?, ?> build, Launcher launcher, TaskListener listener) {
protected Commit<?> determineIntegrationHead(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) {
logger.entering("AbstractSCMBridge", "determineIntegrationHead", new Object[] { build, listener, launcher });// Generated code DONT TOUCH! Bookmark: 94e894e8dad5dfb0e85092e8e93ff296
logger.exiting("AbstractSCMBridge", "determineIntegrationHead");// Generated code DONT TOUCH! Bookmark: 19478dfa81d1cac69955a0cb6ee4ecdd
return null;
Expand Down
Expand Up @@ -68,7 +68,7 @@ public BuildWrapper.Environment setUp(AbstractBuild build, Launcher launcher, Bu
scmBridge.isApplicable(build, listener);

//Updates workspace to the integration branch
scmBridge.ensureBranch(build, launcher, listener, scmBridge.getBranch());
scmBridge.ensureBranch(build, launcher, listener, scmBridge.getExpandedBranch(build.getEnvironment(listener)));

//Create the action. Record the state of integration branch
action = new PretestedIntegrationAction(build, launcher, listener, scmBridge);
Expand Down
Expand Up @@ -51,7 +51,7 @@ public void integrate(AbstractBuild<?,?> build, Launcher launcher, BuildListener
GitBridge gitbridge = (GitBridge)bridge;

ByteArrayOutputStream out = new ByteArrayOutputStream();
BuildData gitBuildData = gitbridge.checkAndDetermineRelevantBuildData(build.getActions(BuildData.class));
BuildData gitBuildData = gitbridge.checkAndDetermineRelevantBuildData(build, listener);
String commit = gitBuildData.lastBuild.revision.getSha1String();

//TODO: Implement robustness, in which situations does this one contain
Expand All @@ -61,9 +61,9 @@ public void integrate(AbstractBuild<?,?> build, Launcher launcher, BuildListener
boolean found = false;


logger.log(Level.INFO, String.format("Preparing to merge changes in commit %s on development branch %s to integration branch %s", commit, gitDataBranch.getName(), gitbridge.getBranch()));
listener.getLogger().println(String.format(LOG_PREFIX + "Preparing to merge changes in commit %s on development branch %s to integration branch %s", commit, gitDataBranch.getName(), gitbridge.getBranch()));
try {
logger.log(Level.INFO, String.format("Preparing to merge changes in commit %s on development branch %s to integration branch %s", commit, gitDataBranch.getName(), gitbridge.getExpandedBranch(build.getEnvironment(listener))));
listener.getLogger().println(String.format(LOG_PREFIX + "Preparing to merge changes in commit %s on development branch %s to integration branch %s", commit, gitDataBranch.getName(), gitbridge.getExpandedBranch(build.getEnvironment(listener))));
logger.fine("Resolving and getting git client from workspace:");
client = Git.with(listener, build.getEnvironment(listener)).in(gitbridge.resolveWorkspace(build, listener)).getClient();
logger.fine("Finding remote branches:");
Expand Down Expand Up @@ -107,7 +107,7 @@ public void integrate(AbstractBuild<?,?> build, Launcher launcher, BuildListener
// based on other commits than the actual merge commit consist of.
logger.log(Level.INFO, String.format(LOG_PREFIX + "Collecting commit messages on development branch %s", gitDataBranch.getName()));
listener.getLogger().println(String.format(LOG_PREFIX + "Collecting commit messages on development branch %s", gitDataBranch.getName()));
String commits = client.withRepository(new GetAllCommitsFromBranchCallback(listener, gitDataBranch.getSHA1(), gitbridge.getBranch()));
String commits = client.withRepository(new GetAllCommitsFromBranchCallback(listener, gitDataBranch.getSHA1(), gitbridge.getExpandedBranch(build.getEnvironment(listener))));
String headerLine = String.format("Accumulated commit of the following from branch '%s':%n", gitDataBranch.getName());
logger.log(Level.INFO, String.format(LOG_PREFIX + "Done collecting commit messages"));
listener.getLogger().println(String.format(LOG_PREFIX + "Done collecting commit messages"));
Expand Down

0 comments on commit f93843a

Please sign in to comment.