Skip to content

Commit

Permalink
stages are now lazy
Browse files Browse the repository at this point in the history
  • Loading branch information
Joaquimmnetto committed Jun 16, 2022
1 parent 4734050 commit df762cb
Showing 1 changed file with 45 additions and 39 deletions.
84 changes: 45 additions & 39 deletions vars/javaLibs.groovy
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env groovy
import net.wooga.jenkins.pipeline.check.NodeCreator
import net.wooga.jenkins.pipeline.stages.Stages
import net.wooga.jenkins.pipeline.config.JavaConfig

Expand All @@ -10,7 +11,6 @@ import net.wooga.jenkins.pipeline.config.JavaConfig
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

def call(Map configMap = [:], Closure stepsConfigCls) {
//organize configs inside neat object. Defaults are defined there as well
configMap.logLevel = configMap.get("logLevel", params.LOG_LEVEL ?: env.LOG_LEVEL as String)
configMap.showStackTrace = configMap.get("showStackTrace", params.STACK_TRACE as Boolean)
configMap.refreshDependencies = configMap.get("refreshDependencies", params.REFRESH_DEPENDENCIES as Boolean)
Expand All @@ -21,50 +21,56 @@ def call(Map configMap = [:], Closure stepsConfigCls) {
def nodes = config.pipelineTools.checks.nodeCreator

def stages = [
{stage(actions.check.name ?: "check") {
nodes.node([
when : { actions.check.runWhenOrElse { params.RELEASE_TYPE == "snapshot" } },
steps: {
actions.check.runActionOrElse {
withEnv(["COVERALLS_PARALLEL=true"]) {
def javaChecks = config.pipelineTools.checks.forJavaPipelines()
def checksForParallel = javaChecks.gradleCheckWithCoverage(config.platforms, config.checkArgs, config.conventions)
parallel checksForParallel
}
}
},
after: { exception ->
if (!exception && config.checkArgs.coveralls.token) {
httpRequest httpMode: 'POST', ignoreSslErrors: true, validResponseCodes: '100:599', url: "https://coveralls.io/webhook?repo_token=${config.checkArgs.coveralls.token}"
}
stageFactory(actions.check.name ?: "check") {
nodes.node([
when : { actions.check.runWhenOrElse { params.RELEASE_TYPE == "snapshot" } },
steps: {
actions.check.runActionOrElse {
withEnv(["COVERALLS_PARALLEL=true"]) {
def javaChecks = config.pipelineTools.checks.forJavaPipelines()
def checksForParallel = javaChecks.gradleCheckWithCoverage(config.platforms, config.checkArgs, config.conventions)
parallel checksForParallel
}
])
}
},
after: { exception ->
if (!exception && config.checkArgs.coveralls.token) {
httpRequest httpMode: 'POST', ignoreSslErrors: true, validResponseCodes: '100:599', url: "https://coveralls.io/webhook?repo_token=${config.checkArgs.coveralls.token}"
}
}
},
{stage(actions.check.name ?: "publish") {
])
},
stageFactory(actions.check.name ?: "publish") {
nodes.node([
label : "$mainPlatform && atlas",
credentials: [
usernamePassword(credentialsId: 'github_access',
usernameVariable: 'GRGIT_USER', passwordVariable: 'GRGIT_PASS'),
usernamePassword(credentialsId: 'github_access',
usernameVariable: 'GITHUB_LOGIN', passwordVariable: 'GITHUB_PASSWORD')
],
when : { actions.publish.runWhenOrElse { params.RELEASE_TYPE != "snapshot" } },
steps : {
actions.publish.runActionOrElse {
error "This pipeline has no publish action whatsoever, " +
"if you don't want to ever run publish, set 'when' to always return false"
}
},
after : { exception ->
if (config.mainPlatform.clearWs) {
cleanWs()
}
label : "$mainPlatform && atlas",
credentials: [
usernamePassword(credentialsId: 'github_access',
usernameVariable: 'GRGIT_USER', passwordVariable: 'GRGIT_PASS'),
usernamePassword(credentialsId: 'github_access',
usernameVariable: 'GITHUB_LOGIN', passwordVariable: 'GITHUB_PASSWORD')
],
when : { actions.publish.runWhenOrElse { params.RELEASE_TYPE != "snapshot" } },
steps : {
actions.publish.runActionOrElse {
error "This pipeline has no publish action whatsoever, " +
"if you don't want to ever run publish, set 'when' to always return false"
}
},
after : { exception ->
if (config.mainPlatform.clearWs) {
cleanWs()
}
}
])
}
}
]
declarativePipelineTemplate(config, stages)
}

def stageFactory(String name, Closure content) {
return {
stage(name) {
content(name)
}
}
}

0 comments on commit df762cb

Please sign in to comment.