Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
fixes agent label on publish stage (#119)
Browse files Browse the repository at this point in the history
Solved bug on JS pipeline where a complex object was on the publish stage label instead of a string.
  • Loading branch information
Joaquimmnetto authored Jun 15, 2022
1 parent 9b853a9 commit 796e6c0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
19 changes: 19 additions & 0 deletions test/groovy/scripts/BuildWDKJSSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,23 @@ class BuildWDKJSSpec extends DeclarativeJenkinsSpec {
env["GITHUB_PASSWORD"] == "gitpwd" //"${GRGIT_PSW}"
}

@Unroll
def "publish step is executed on #mainPlatform label"() {
given: "pipeline loaded with publish parameters"
def buildWDKJS = loadSandboxedScript(SCRIPT_PATH) {
params.RELEASE_TYPE = "not-snapshot"
params.RELEASE_SCOPE = "any"
}

when: "running pipeline"
inSandbox { buildWDKJS(platforms: platforms) }

then: "publish step is executed with expected label"
pipeline.stages["publish"].agent.label == "$mainPlatform && atlas"

where:
platforms << [["macos", "windows"], ["linux"]]
mainPlatform = platforms?.get(0)
}

}
7 changes: 7 additions & 0 deletions test/groovy/tools/DeclarativeJenkinsSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tools


import com.lesfurets.jenkins.unit.PipelineTestHelper
import com.lesfurets.jenkins.unit.declarative.DeclarativePipeline
import com.lesfurets.jenkins.unit.declarative.DeclarativePipelineTest
import com.lesfurets.jenkins.unit.declarative.GenericPipelineDeclaration
import com.lesfurets.jenkins.unit.declarative.PostDeclaration
Expand Down Expand Up @@ -33,6 +34,7 @@ abstract class DeclarativeJenkinsSpec extends Specification {
@Shared FakeEnvironment environment
@Shared Map<String, Map> jenkinsStash
@Shared String currentDir
@Shared GenericPipelineDeclaration pipeline

def setupSpec() {
jenkinsStash = new HashMap<>()
Expand All @@ -41,6 +43,11 @@ abstract class DeclarativeJenkinsSpec extends Specification {
new PackageWhitelist("com.lesfurets.jenkins"),
new PackageWhitelist("net.wooga.jenkins.pipeline")
))
jenkinsTest.pipelineInterceptor = { Closure cls ->
GenericPipelineDeclaration.binding = binding
this.pipeline = GenericPipelineDeclaration.createComponent(DeclarativePipeline, cls)
this.pipeline.execute(delegate)
}
jenkinsTest.setUp()
credentials = new FakeCredentialStorage()
environment = new FakeEnvironment(jenkinsTest.binding)
Expand Down
2 changes: 1 addition & 1 deletion vars/buildWDKJS.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def call(Map configMap = [:]) {
configMap.clearWs = configMap.get("clearWs", params.CLEAR_WS as boolean)
def config = JSConfig.fromConfigMap(configMap, this)
def platforms = config.platforms
def mainPlatform = platforms[0]
def mainPlatform = platforms[0].name

pipeline {
agent none
Expand Down

0 comments on commit 796e6c0

Please sign in to comment.