File tree Expand file tree Collapse file tree 3 files changed +41
-23
lines changed
groovy/com/lesfurets/jenkins/unit/declarative Expand file tree Collapse file tree 3 files changed +41
-23
lines changed Original file line number Diff line number Diff line change @@ -450,15 +450,22 @@ class TestDeclarativePipeline extends DeclarativePipelineTest {
450
450
}
451
451
452
452
@Test void should_environment () throws Exception {
453
- addEnvVar(" labelVar" ," varWorks" )
454
453
runScript(' Environment_Jenkinsfile' )
455
454
printCallStack()
456
455
assertCallStack(). contains(' echo(LEVAR1 LE NEW VALUE)' )
457
- assertCallStack(). contains(' echo(LEVAR1 LE NEW VALUE)' )
456
+ assertCallStack(). contains(' echo(LEVAR1 LE NEW VALUE without pefixing env )' )
458
457
assertCallStack(). contains(' echo(LEVAR2 A COPY OF LE NEW VALUE in build#1)' )
459
458
assertJobStatusSuccess()
460
459
}
461
460
461
+ @Test void should_be_able_to_access_upper_score_var () throws Exception {
462
+ String envVarValue = " envVarValue"
463
+ addEnvVar(" envVar" , envVarValue)
464
+ runScript(' Scoping_Jenkinsfile' )
465
+ assertCallStack(). contains(" echo(Upperscoped string : UpperScope string with envVar: $envVarValue )" )
466
+ printCallStack()
467
+ }
468
+
462
469
@Test void not_running_stage_after_failure () throws Exception {
463
470
runScript(' StageFailed_Jenkinsfile' )
464
471
printCallStack()
Original file line number Diff line number Diff line change 1
- def call() {
2
- String label = "SomePrefix-${labelVar}"
3
-
4
- pipeline {
5
- agent label
6
- environment {
7
- LEVAR1 = "LE VALUE 1"
8
- }
9
- stages {
10
- stage('Example') {
11
- environment {
12
- LEVAR1 = "LE NEW VALUE"
13
- LEVAR2 = "A COPY OF ${env.LEVAR1} in build#${currentBuild.number}"
14
- }
15
- steps {
16
- echo "LEVAR1 ${env.LEVAR1}"
17
- echo "LEVAR2 ${env.LEVAR2}"
18
- }
1
+ pipeline {
2
+ agent any
3
+ environment {
4
+ LEVAR1 = "LE VALUE 1"
5
+ }
6
+ stages {
7
+ stage('Example') {
8
+ environment {
9
+ LEVAR1 = "LE NEW VALUE"
10
+ LEVAR2 = "A COPY OF ${env.LEVAR1} in build#${currentBuild.number}"
11
+ }
12
+ steps {
13
+ echo "LEVAR1 ${LEVAR1}"
14
+ echo "LEVAR1 ${LEVAR1} without pefixing env"
15
+ echo "LEVAR2 ${env.LEVAR2}"
19
16
}
20
17
}
21
18
}
22
- }
23
-
24
- call()
19
+ }
Original file line number Diff line number Diff line change
1
+ def call() {
2
+ String upperscopeSTring = "UpperScope string with envVar: ${envVar}"
3
+
4
+ pipeline {
5
+ agent upperscopeSTring
6
+ stages {
7
+ stage('Echo stage') {
8
+ steps {
9
+ echo "Upperscoped string : $upperscopeSTring"
10
+ }
11
+ }
12
+ }
13
+ }
14
+ }
15
+
16
+ call()
You can’t perform that action at this time.
0 commit comments