@@ -409,9 +409,9 @@ protected Depot getDepot(Launcher launcher, FilePath workspace, AbstractProject
409409 Depot depot = new Depot (p4Factory );
410410
411411 if (build != null ) {
412- depot .setClient (MacroStringHelper .substituteParameters (p4Client , build ));
413- depot .setUser (MacroStringHelper .substituteParameters (p4User , build ));
414- depot .setPort (MacroStringHelper .substituteParameters (p4Port , build ));
412+ depot .setClient (MacroStringHelper .substituteParameters (p4Client , build , null ));
413+ depot .setUser (MacroStringHelper .substituteParameters (p4User , build , null ));
414+ depot .setPort (MacroStringHelper .substituteParameters (p4Port , build , null ));
415415 depot .setPassword (getDecryptedP4Passwd (build ));
416416 } else if (project != null ) {
417417 depot .setClient (MacroStringHelper .substituteParameters (p4Client , getDefaultSubstitutions (project )));
@@ -476,10 +476,10 @@ protected Depot getDepot(Launcher launcher, FilePath workspace, AbstractProject
476476 public void buildEnvVars (AbstractBuild build , Map <String , String > env ) {
477477 super .buildEnvVars (build , env );
478478 try {
479- env .put ("P4PORT" , MacroStringHelper .substituteParameters (p4Port , build ));
480- env .put ("P4USER" , MacroStringHelper .substituteParameters (p4User , build ));
479+ env .put ("P4PORT" , MacroStringHelper .substituteParameters (p4Port , build , env ));
480+ env .put ("P4USER" , MacroStringHelper .substituteParameters (p4User , build , env ));
481481 } catch (ParameterSubstitutionException ex ) {
482- LOGGER .log (Level . SEVERE , "Can't substitute P4USER or P4PORT" , ex );
482+ LOGGER .log (MacroStringHelper . SUBSTITUTION_ERROR_LEVEL , "Can't substitute P4USER or P4PORT" , ex );
483483 //TODO: exit?
484484 }
485485
@@ -495,9 +495,9 @@ public void buildEnvVars(AbstractBuild build, Map<String, String> env) {
495495 }
496496
497497 try {
498- env .put ("P4CLIENT" , getConcurrentClientName (build .getWorkspace (), getEffectiveClientName (build )));
498+ env .put ("P4CLIENT" , getConcurrentClientName (build .getWorkspace (), getEffectiveClientName (build , env )));
499499 } catch (ParameterSubstitutionException ex ) {
500- LOGGER .log (Level . SEVERE , "Can't substitute P$CLIENT " ,ex );
500+ LOGGER .log (MacroStringHelper . SUBSTITUTION_ERROR_LEVEL , "Can't substitute P4CLIENT " ,ex );
501501 //TODO: exit?
502502 }
503503
@@ -637,7 +637,7 @@ private String getEffectiveProjectPath(AbstractBuild build, AbstractProject proj
637637 if (useClientSpec ) {
638638 projectPath = getEffectiveProjectPathFromFile (build , project , log , depot );
639639 } else if (build != null ) {
640- projectPath = MacroStringHelper .substituteParameters (this .projectPath , build );
640+ projectPath = MacroStringHelper .substituteParameters (this .projectPath , build , null );
641641 } else {
642642 projectPath = MacroStringHelper .substituteParameters (this .projectPath , getDefaultSubstitutions (project ));
643643 }
@@ -647,15 +647,15 @@ private String getEffectiveProjectPath(AbstractBuild build, AbstractProject proj
647647 private String getEffectiveProjectPathFromFile (AbstractBuild build , AbstractProject project , PrintStream log , Depot depot ) throws PerforceException , ParameterSubstitutionException {
648648 String clientSpec ;
649649 if (build != null ) {
650- clientSpec = MacroStringHelper .substituteParameters (this .clientSpec , build );
650+ clientSpec = MacroStringHelper .substituteParameters (this .clientSpec , build , null );
651651 } else {
652652 clientSpec = MacroStringHelper .substituteParametersNoCheck (this .clientSpec , getDefaultSubstitutions (project ));
653653 }
654654 log .println ("Read ClientSpec from: " + clientSpec );
655655 com .tek42 .perforce .parse .File f = depot .getFile (clientSpec );
656656 String projectPath = f .read ();
657657 if (build != null ) {
658- projectPath = MacroStringHelper .substituteParameters (projectPath , build );
658+ projectPath = MacroStringHelper .substituteParameters (projectPath , build , null );
659659 } else {
660660 projectPath = MacroStringHelper .substituteParametersNoCheck (projectPath , getDefaultSubstitutions (project ));
661661 }
@@ -803,13 +803,13 @@ public boolean checkout(AbstractBuild build, Launcher launcher,
803803 PrintStream log = listener .getLogger ();
804804 changelogFilename = changelogFile .getAbsolutePath ();
805805 // HACK: Force build env vars to initialize
806- MacroStringHelper .substituteParameters ("" , build );
806+ MacroStringHelper .substituteParameters ("" , build , null );
807807
808808 // Use local variables so that substitutions are not saved
809- String p4Label = MacroStringHelper .substituteParameters (this .p4Label , build );
810- String viewMask = MacroStringHelper .substituteParameters (this .viewMask , build );
809+ String p4Label = MacroStringHelper .substituteParameters (this .p4Label , build , null );
810+ String viewMask = MacroStringHelper .substituteParameters (this .viewMask , build , null );
811811 Depot depot = getDepot (launcher ,workspace , build .getProject (), build , build .getBuiltOn ());
812- String p4Stream = MacroStringHelper .substituteParameters (this .p4Stream , build );
812+ String p4Stream = MacroStringHelper .substituteParameters (this .p4Stream , build , null );
813813
814814 // Pull from optional named parameters
815815 boolean wipeBeforeBuild = overrideWithBooleanParameter (
@@ -849,7 +849,7 @@ public boolean checkout(AbstractBuild build, Launcher launcher,
849849 String p4config ;
850850 WipeWorkspaceExcludeFilter wipeFilter ;
851851 try {
852- p4config = MacroStringHelper .substituteParameters ("${P4CONFIG}" , build );
852+ p4config = MacroStringHelper .substituteParameters ("${P4CONFIG}" , build , null );
853853 wipeFilter = new WipeWorkspaceExcludeFilter (".p4config" ,p4config );
854854 } catch (ParameterSubstitutionException ex ) {
855855 wipeFilter = new WipeWorkspaceExcludeFilter ();
@@ -895,7 +895,7 @@ public boolean checkout(AbstractBuild build, Launcher launcher,
895895 if (useStreamDepot ) {
896896 if (dirtyWorkspace ) {
897897 // Support for concurrent builds
898- String p4Client = getConcurrentClientName (workspace , getEffectiveClientName (build ));
898+ String p4Client = getConcurrentClientName (workspace , getEffectiveClientName (build , null ));
899899 p4workspace = depot .getWorkspaces ().getWorkspace (p4Client , p4Stream );
900900 }
901901 projectPath = p4workspace .getTrimmedViewsAsString ();
@@ -938,7 +938,7 @@ public boolean checkout(AbstractBuild build, Launcher launcher,
938938 if (p4Counter != null && !updateCounterValue ) {
939939 //use a counter
940940 String counterName ;
941- counterName = MacroStringHelper .substituteParameters (this .p4Counter , build );
941+ counterName = MacroStringHelper .substituteParameters (this .p4Counter , build , null );
942942 Counter counter = depot .getCounters ().getCounter (counterName );
943943 newestChange = counter .getValue ();
944944 } else {
@@ -1067,14 +1067,14 @@ public boolean checkout(AbstractBuild build, Launcher launcher,
10671067 // Add tagging action that enables the user to create a label
10681068 // for this build.
10691069 build .addAction (new PerforceTagAction (
1070- build , depot , newestChange , projectPath , MacroStringHelper .substituteParameters (p4User , build )));
1070+ build , depot , newestChange , projectPath , MacroStringHelper .substituteParameters (p4User , build , null )));
10711071
10721072 build .addAction (new PerforceSCMRevisionState (newestChange ));
10731073
10741074 if (p4Counter != null && updateCounterValue ) {
10751075 // Set or create a counter to mark this change
10761076 Counter counter = new Counter ();
1077- String counterName = MacroStringHelper .substituteParameters (this .p4Counter , build );
1077+ String counterName = MacroStringHelper .substituteParameters (this .p4Counter , build , null );
10781078 counter .setName (counterName );
10791079 counter .setValue (newestChange );
10801080 log .println ("Updating counter " + counterName + " to " + newestChange );
@@ -1133,7 +1133,7 @@ private synchronized int getOrSetMatrixChangeSet(AbstractBuild build, Depot depo
11331133 // no changeset on parent, set it for other
11341134 // matrixruns to use
11351135 log .println ("No change number has been set by parent/siblings. Using latest." );
1136- parentBuild .addAction (new PerforceTagAction (build , depot , newestChange , projectPath , MacroStringHelper .substituteParameters (p4User ,build )));
1136+ parentBuild .addAction (new PerforceTagAction (build , depot , newestChange , projectPath , MacroStringHelper .substituteParameters (p4User ,build , null )));
11371137 }
11381138 }
11391139 }
@@ -1516,7 +1516,7 @@ private Workspace getPerforceWorkspace(AbstractProject project, String projectPa
15161516
15171517 String p4Client ;
15181518 if (build != null ) {
1519- p4Client = getEffectiveClientName (build );
1519+ p4Client = getEffectiveClientName (build , null );
15201520 } else {
15211521 p4Client = getDefaultEffectiveClientName (project , buildNode , workspace );
15221522 }
@@ -1539,7 +1539,7 @@ else if (dontRenameClient) {
15391539 }
15401540
15411541 depot .setClient (p4Client );
1542- String p4Stream = (build == null ? MacroStringHelper .substituteParameters (this .p4Stream , getDefaultSubstitutions (project )) : MacroStringHelper .substituteParameters (this .p4Stream , build ));
1542+ String p4Stream = (build == null ? MacroStringHelper .substituteParameters (this .p4Stream , getDefaultSubstitutions (project )) : MacroStringHelper .substituteParameters (this .p4Stream , build , null ));
15431543
15441544 // Get the clientspec (workspace) from perforce
15451545 Workspace p4workspace = depot .getWorkspaces ().getWorkspace (p4Client , p4Stream );
@@ -1633,11 +1633,11 @@ else if (localPath.trim().equals(""))
16331633 return p4workspace ;
16341634 }
16351635
1636- private String getEffectiveClientName (AbstractBuild build ) throws ParameterSubstitutionException {
1636+ private String getEffectiveClientName (AbstractBuild build , Map < String , String > env ) throws ParameterSubstitutionException {
16371637 Node buildNode = build .getBuiltOn ();
16381638 FilePath workspace = build .getWorkspace ();
16391639 String p4Client = this .p4Client ;
1640- p4Client = MacroStringHelper .substituteParameters (p4Client , build );
1640+ p4Client = MacroStringHelper .substituteParameters (p4Client , build , env );
16411641 try {
16421642 p4Client = getEffectiveClientName (p4Client , buildNode );
16431643 } catch (Exception e ) {
@@ -2532,7 +2532,7 @@ public String getDecryptedP4Passwd() {
25322532 }
25332533
25342534 public String getDecryptedP4Passwd (AbstractBuild build ) throws ParameterSubstitutionException {
2535- return MacroStringHelper .substituteParameters (getDecryptedP4Passwd (), build );
2535+ return MacroStringHelper .substituteParameters (getDecryptedP4Passwd (), build , null );
25362536 }
25372537
25382538 public String getDecryptedP4Passwd (AbstractProject project ) {
0 commit comments