@@ -16,23 +16,26 @@ public class StashAditionalParameterEnvironmentContributor extends EnvironmentCo
16
16
public void buildEnvironmentFor (
17
17
@ Nonnull Run r , @ Nonnull EnvVars envs , @ Nonnull TaskListener listener )
18
18
throws IOException , InterruptedException {
19
+ Run <?, ?> rootRun ;
19
20
if (r instanceof AbstractBuild ) {
20
- AbstractBuild build = (AbstractBuild ) r ;
21
- AbstractBuild rootBuild = build .getRootBuild ();
21
+ AbstractBuild <?, ?> build = (AbstractBuild ) r ;
22
+ rootRun = build .getRootBuild ();
23
+ } else {
24
+ rootRun = (Run <?, ?>) r ;
25
+ }
22
26
23
- StashCause cause = (StashCause ) rootBuild .getCause (StashCause .class );
24
- if (cause != null ) {
25
- putEnvVar (envs , "sourceBranch" , cause .getSourceBranch ());
26
- putEnvVar (envs , "targetBranch" , cause .getTargetBranch ());
27
- putEnvVar (envs , "sourceRepositoryOwner" , cause .getSourceRepositoryOwner ());
28
- putEnvVar (envs , "sourceRepositoryName" , cause .getSourceRepositoryName ());
29
- putEnvVar (envs , "pullRequestId" , cause .getPullRequestId ());
30
- putEnvVar (envs , "destinationRepositoryOwner" , cause .getDestinationRepositoryOwner ());
31
- putEnvVar (envs , "destinationRepositoryName" , cause .getDestinationRepositoryName ());
32
- putEnvVar (envs , "pullRequestTitle" , cause .getPullRequestTitle ());
33
- putEnvVar (envs , "sourceCommitHash" , cause .getSourceCommitHash ());
34
- putEnvVar (envs , "destinationCommitHash" , cause .getDestinationCommitHash ());
35
- }
27
+ StashCause cause = (StashCause ) rootRun .getCause (StashCause .class );
28
+ if (cause != null ) {
29
+ putEnvVar (envs , "sourceBranch" , cause .getSourceBranch ());
30
+ putEnvVar (envs , "targetBranch" , cause .getTargetBranch ());
31
+ putEnvVar (envs , "sourceRepositoryOwner" , cause .getSourceRepositoryOwner ());
32
+ putEnvVar (envs , "sourceRepositoryName" , cause .getSourceRepositoryName ());
33
+ putEnvVar (envs , "pullRequestId" , cause .getPullRequestId ());
34
+ putEnvVar (envs , "destinationRepositoryOwner" , cause .getDestinationRepositoryOwner ());
35
+ putEnvVar (envs , "destinationRepositoryName" , cause .getDestinationRepositoryName ());
36
+ putEnvVar (envs , "pullRequestTitle" , cause .getPullRequestTitle ());
37
+ putEnvVar (envs , "sourceCommitHash" , cause .getSourceCommitHash ());
38
+ putEnvVar (envs , "destinationCommitHash" , cause .getDestinationCommitHash ());
36
39
}
37
40
38
41
super .buildEnvironmentFor (r , envs , listener );
0 commit comments