@@ -452,7 +452,7 @@ public static PerforceSCMDescriptor getInstance() {
452452 protected Depot getDepot (@ Nonnull Launcher launcher , @ Nonnull FilePath workspace ,
453453 @ CheckForNull AbstractProject project ,
454454 @ CheckForNull AbstractBuild build , @ CheckForNull Node node )
455- throws ParameterSubstitutionException {
455+ throws ParameterSubstitutionException , InterruptedException {
456456 HudsonP4ExecutorFactory p4Factory = new HudsonP4ExecutorFactory (launcher ,workspace );
457457
458458 Depot depot = new Depot (p4Factory );
@@ -519,28 +519,25 @@ public void buildEnvVars(@Nonnull AbstractBuild build, @Nonnull Map<String, Stri
519519 super .buildEnvVars (build , env );
520520 try {
521521 env .put ("P4PORT" , MacroStringHelper .substituteParameters (p4Port , this , build , env ));
522- env .put ("P4USER" , MacroStringHelper .substituteParameters (p4User , this , build , env ));
522+ env .put ("P4USER" , MacroStringHelper .substituteParameters (p4User , this , build , env ));
523+
524+ // if we want to allow p4 commands in script steps this helps
525+ if (isExposeP4Passwd ()) {
526+ PerforcePasswordEncryptor encryptor = new PerforcePasswordEncryptor ();
527+ env .put ("P4PASSWD" , encryptor .decryptString (p4Passwd ));
528+ }
529+ // this may help when tickets are used since we are
530+ // not storing the ticket on the client during login
531+ if (p4Ticket != null ) {
532+ env .put ("P4TICKET" , p4Ticket );
533+ }
534+
535+ env .put ("P4CLIENT" , getConcurrentClientName (build .getWorkspace (), getEffectiveClientName (build , env )));
523536 } catch (ParameterSubstitutionException ex ) {
524- LOGGER .log (MacroStringHelper .SUBSTITUTION_ERROR_LEVEL , "Can't substitute P4USER or P4PORT" , ex );
525- //TODO: exit?
526- }
527-
528- // if we want to allow p4 commands in script steps this helps
529- if (isExposeP4Passwd ()) {
530- PerforcePasswordEncryptor encryptor = new PerforcePasswordEncryptor ();
531- env .put ("P4PASSWD" , encryptor .decryptString (p4Passwd ));
532- }
533- // this may help when tickets are used since we are
534- // not storing the ticket on the client during login
535- if (p4Ticket != null ) {
536- env .put ("P4TICKET" , p4Ticket );
537- }
538-
539- try {
540- env .put ("P4CLIENT" , getConcurrentClientName (build .getWorkspace (), getEffectiveClientName (build , env )));
541- } catch (ParameterSubstitutionException ex ) {
542- LOGGER .log (MacroStringHelper .SUBSTITUTION_ERROR_LEVEL , "Can't substitute P4CLIENT" ,ex );
537+ LOGGER .log (MacroStringHelper .SUBSTITUTION_ERROR_LEVEL , "Cannot build environent variables due to unresolved macros" , ex );
543538 //TODO: exit?
539+ } catch (InterruptedException ex ) {
540+ LOGGER .log (MacroStringHelper .SUBSTITUTION_ERROR_LEVEL , "Cannot build environment vars. The method has been interrupted" );
544541 }
545542
546543 PerforceTagAction pta = build .getAction (PerforceTagAction .class );
@@ -660,7 +657,7 @@ private String getEffectiveProjectPath(
660657 @ CheckForNull Node node ,
661658 @ Nonnull PrintStream log ,
662659 @ Nonnull Depot depot )
663- throws PerforceException , ParameterSubstitutionException {
660+ throws PerforceException , ParameterSubstitutionException , InterruptedException {
664661 String effectiveProjectPath = useClientSpec
665662 ? getEffectiveProjectPathFromFile (build , project , node , log , depot )
666663 : MacroStringHelper .substituteParameters (this .projectPath , this , build , project , node , null );
@@ -672,7 +669,8 @@ private String getEffectiveProjectPathFromFile(
672669 @ CheckForNull AbstractBuild build ,
673670 @ CheckForNull AbstractProject project ,
674671 @ CheckForNull Node node ,
675- @ Nonnull PrintStream log , @ Nonnull Depot depot ) throws PerforceException , ParameterSubstitutionException {
672+ @ Nonnull PrintStream log , @ Nonnull Depot depot )
673+ throws PerforceException , ParameterSubstitutionException , InterruptedException {
676674 String effectiveClientSpec =
677675 MacroStringHelper .substituteParameters (this .clientSpec , this , build , project , node , null );
678676 log .println ("Read ClientSpec from: " + effectiveClientSpec );
@@ -1166,7 +1164,7 @@ private synchronized int getOrSetMatrixChangeSet(
11661164 @ Nonnull AbstractBuild build ,
11671165 @ Nonnull Depot depot , int newestChange , String projectPath ,
11681166 @ Nonnull PrintStream log )
1169- throws ParameterSubstitutionException
1167+ throws ParameterSubstitutionException , InterruptedException
11701168 {
11711169 int matrixLastChange = 0 ;
11721170 // special consideration for matrix builds
@@ -1427,7 +1425,7 @@ private SCMRevisionState getCurrentDepotRevisionState(
14271425 */
14281426 private boolean isChangelistExcluded (Changelist changelist ,
14291427 AbstractProject project , Node node , String view , PrintStream logger )
1430- throws ParameterSubstitutionException
1428+ throws ParameterSubstitutionException , InterruptedException
14311429 {
14321430 if (changelist == null ) {
14331431 return false ;
@@ -1695,7 +1693,8 @@ else if (localPath.trim().equals(""))
16951693 return p4workspace ;
16961694 }
16971695
1698- private String getEffectiveClientName (AbstractBuild build , Map <String ,String > env ) throws ParameterSubstitutionException {
1696+ private String getEffectiveClientName (AbstractBuild build , Map <String ,String > env )
1697+ throws ParameterSubstitutionException , InterruptedException {
16991698 Node buildNode = build .getBuiltOn ();
17001699 FilePath workspace = build .getWorkspace ();
17011700 String effectiveP4Client = this .p4Client ;
@@ -2559,14 +2558,15 @@ public String getDecryptedP4Passwd() {
25592558 return encryptor .decryptString (p4Passwd );
25602559 }
25612560
2562- public String getDecryptedP4Passwd (AbstractBuild build ) throws ParameterSubstitutionException {
2561+ public String getDecryptedP4Passwd (AbstractBuild build )
2562+ throws ParameterSubstitutionException , InterruptedException {
25632563 return MacroStringHelper .substituteParameters (getDecryptedP4Passwd (), this , build , null );
25642564 }
25652565
25662566 /**
25672567 * @deprecated Use {@link #getDecryptedP4Passwd(hudson.model.AbstractProject, hudson.model.Node)} instead.
25682568 */
2569- public String getDecryptedP4Passwd (AbstractProject project ) {
2569+ public String getDecryptedP4Passwd (AbstractProject project ) throws InterruptedException {
25702570 try {
25712571 return getDecryptedP4Passwd (project , null );
25722572 } catch (ParameterSubstitutionException ex ) {
@@ -2575,7 +2575,7 @@ public String getDecryptedP4Passwd(AbstractProject project) {
25752575 }
25762576
25772577 public String getDecryptedP4Passwd (@ CheckForNull AbstractProject project , @ CheckForNull Node node )
2578- throws ParameterSubstitutionException {
2578+ throws ParameterSubstitutionException , InterruptedException {
25792579 return MacroStringHelper .substituteParameters (getDecryptedP4Passwd (),
25802580 this , project , node , null );
25812581 }
0 commit comments