Skip to content

Commit

Permalink
Reproduce issue jenkinsci#434.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Nov 19, 2021
1 parent e3673f9 commit 663a23e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.lesfurets.jenkins.unit.declarative

import org.junit.Before
import org.junit.Test

class TestVariableAssignment extends DeclarativePipelineTest {

@Before
@Override
void setUp() throws Exception {
scriptRoots += 'src/test/jenkins/jenkinsfiles'
super.setUp()
}

@Test
void test() {
runScript("VariableAssignment_Jenkinsfile")
assertJobStatusSuccess()
printCallStack()
assertCallStack().contains("docker:[image:docker-image, reuseNode:false, stages:[:], args:, alwaysPull:true, containerPerStageRoot:false, label:docker-label")
assertCallStack().contains("dockerImage=docker-image, dockerLabel=docker-label, dockerPull=true")
}
}
25 changes: 25 additions & 0 deletions src/test/jenkins/jenkinsfiles/VariableAssignment_Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
pipeline {
stages {
stage('Set variables') {
steps {
script {
dockerImage = 'docker-image'
dockerLabel = 'docker-label'
dockerPull = true
}
}
}
stage('Use variables') {
agent {
docker {
image dockerImage
label dockerLabel
alwaysPull dockerPull
}
}
steps {
echo "dockerImage=${dockerImage}, dockerLabel=${dockerLabel}, dockerPull=${dockerPull}"
}
}
}
}

0 comments on commit 663a23e

Please sign in to comment.