Skip to content

Commit

Permalink
[FIXED JENKINS-15053] add parameter substitution support for P4USER a…
Browse files Browse the repository at this point in the history
…nd P4PORT
  • Loading branch information
rpetti committed Sep 6, 2012
1 parent 0e5b7c4 commit 0772873
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main/java/hudson/plugins/perforce/PerforceSCM.java
Expand Up @@ -415,17 +415,21 @@ protected Depot getDepot(Launcher launcher, FilePath workspace, AbstractProject
HudsonP4ExecutorFactory p4Factory = new HudsonP4ExecutorFactory(launcher,workspace);

Depot depot = new Depot(p4Factory);
depot.setUser(p4User);
depot.setPort(p4Port);


if (build != null) {
depot.setClient(substituteParameters(p4Client, build));
depot.setUser(substituteParameters(p4User, build));
depot.setPort(substituteParameters(p4Port, build));
depot.setPassword(getDecryptedP4Passwd(build));
} else if (project != null) {
depot.setClient(substituteParameters(p4Client, getDefaultSubstitutions(project)));
depot.setUser(substituteParameters(p4User, getDefaultSubstitutions(project)));
depot.setPort(substituteParameters(p4Port, getDefaultSubstitutions(project)));
depot.setPassword(getDecryptedP4Passwd(project));
} else {
depot.setClient(p4Client);
depot.setUser(p4User);
depot.setPort(p4Port);
depot.setPassword(getDecryptedP4Passwd());
}

Expand Down Expand Up @@ -453,8 +457,8 @@ protected Depot getDepot(Launcher launcher, FilePath workspace, AbstractProject
@Override
public void buildEnvVars(AbstractBuild build, Map<String, String> env) {
super.buildEnvVars(build, env);
env.put("P4PORT", p4Port);
env.put("P4USER", p4User);
env.put("P4PORT", substituteParameters(p4Port, build));
env.put("P4USER", substituteParameters(p4User, build));

// if we want to allow p4 commands in script steps this helps
if (exposeP4Passwd) {
Expand Down Expand Up @@ -1003,7 +1007,7 @@ public boolean checkout(AbstractBuild build, Launcher launcher,
// Add tagging action that enables the user to create a label
// for this build.
build.addAction(new PerforceTagAction(
build, depot, newestChange, projectPath, p4User));
build, depot, newestChange, projectPath, substituteParameters(p4User, build)));

build.addAction(new PerforceSCMRevisionState(newestChange));

Expand Down Expand Up @@ -1054,7 +1058,7 @@ private synchronized int getOrSetMatrixChangeSet(AbstractBuild build, Depot depo
// no changeset on parent, set it for other
// matrixruns to use
log.println("No change number has been set by parent/siblings. Using latest.");
parentBuild.addAction(new PerforceTagAction(build, depot, newestChange, projectPath, p4User));
parentBuild.addAction(new PerforceTagAction(build, depot, newestChange, projectPath, substituteParameters(p4User,build)));
}
}
}
Expand Down

0 comments on commit 0772873

Please sign in to comment.