Skip to content

Commit

Permalink
stages can be now extended by java pipelines implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
Joaquimmnetto committed Jun 15, 2022
1 parent 1c45f18 commit 86ff4e2
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 13 deletions.
4 changes: 3 additions & 1 deletion atlas-jenkins-pipeline-gradle/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
@Library('github.com/wooga/atlas-jenkins-pipeline@1.x') _

withCredentials([usernamePassword(credentialsId: 'github_integration', passwordVariable: 'ATLAS_GITHUB_INTEGRATION_PASSWORD', usernameVariable: 'ATLAS_GITHUB_INTEGRATION_USER')]) {
buildLocalGradlePlugin(platforms: ['macos'], checkDir: "atlas-jenkins-pipeline-gradle")
buildLocalGradlePlugin(platforms: ['macos'], checkDir: "atlas-jenkins-pipeline-gradle") {
it.check.name = "my check stage"
}
}
5 changes: 3 additions & 2 deletions src/net/wooga/jenkins/pipeline/stages/Stage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ class Stage {

static Stage fromClosure(Map jenkinsParams, PipelineConfig config, Closure cls) {
def clsClone = cls.clone() as Closure
def stage = new Stage(null, null)
def stage = new Stage(null, null, null)
clsClone.delegate = stage
clsClone(stage, jenkinsParams, config)
return stage
}

Stage(Closure when, Closure action) {
Stage(String name, Closure when, Closure action) {
this.name = name
this.when = when
this.action = action
}
Expand Down
4 changes: 2 additions & 2 deletions src/net/wooga/jenkins/pipeline/stages/Stages.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class Stages {

static Stages standard(Map jenkinsParams, PipelineConfig config) {
return new Stages(
new Stage(null, null),
new Stage(null, null),
new Stage(null, null, null),
new Stage(null, null, null),
{ Closure cls -> Stage.fromClosure(jenkinsParams , config, cls) })
}

Expand Down
2 changes: 1 addition & 1 deletion vars/buildGradlePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import net.wooga.jenkins.pipeline.config.JavaConfig
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

def call(Map configMap = [:]) {
def call(Map configMap = [:], Closure stagesConfigCls = {it -> }) {
javaLibs(configMap) { stages ->
stages.publish = { stage, params, JavaConfig config ->
stage.action = {
Expand Down
3 changes: 2 additions & 1 deletion vars/buildJavaLibrary.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import net.wooga.jenkins.pipeline.config.JavaConfig
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

def call(Map configMap = [:]) {
def call(Map configMap = [:], Closure stagesConfigCls = {it -> }) {
javaLibs(configMap) { stages ->
stages.publish = { stage, params, JavaConfig config ->
stage.action = {
def publisher = config.pipelineTools.createPublishers(params.RELEASE_TYPE, params.RELEASE_SCOPE)
publisher.bintray('bintray.publish')
}
}
stagesConfigCls(stages)
}
}
3 changes: 2 additions & 1 deletion vars/buildJavaLibraryOSSRH.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import net.wooga.jenkins.pipeline.config.JavaConfig
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

def call(Map configMap = [:]) {
def call(Map configMap = [:], Closure stagesConfigCls = {it -> }) {
javaLibs(configMap) { stages ->
stages.publish = { stage, params, JavaConfig config ->
stage.action = {
Expand All @@ -18,5 +18,6 @@ def call(Map configMap = [:]) {
'ossrh.signing.key_id', 'ossrh.signing.passphrase')
}
}
stagesConfigCls(stages)
}
}
3 changes: 2 additions & 1 deletion vars/buildLocalGradlePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import net.wooga.jenkins.pipeline.config.JavaConfig
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

def call(Map configMap = [:]) {
def call(Map configMap = [:], Closure stagesConfigCls = {it -> }) {
def checkDir = configMap.checkDir?: "."
javaLibs(configMap) { stages ->
stages.check = { check, params, config ->
Expand All @@ -24,5 +24,6 @@ def call(Map configMap = [:]) {
stages.publish = { publish, params, JavaConfig config ->
publish.when = { false }
}
stagesConfigCls(stages)
}
}
3 changes: 2 additions & 1 deletion vars/buildPrivateGradlePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import net.wooga.jenkins.pipeline.config.JavaConfig
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

def call(Map configMap = [:]) {
def call(Map configMap = [:], Closure stagesConfigCls = {it -> }) {
javaLibs(configMap) { stages ->
stages.publish = { stage, params, JavaConfig config ->
stage.when = { true } //always
Expand All @@ -20,5 +20,6 @@ def call(Map configMap = [:]) {
'ossrh.signing.passphrase')
}
}
stagesConfigCls(stages)
}
}
3 changes: 2 additions & 1 deletion vars/buildPrivateJavaLibrary.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import net.wooga.jenkins.pipeline.config.JavaConfig
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

def call(Map configMap = [:]) {
def call(Map configMap = [:], Closure stagesConfigCls = {it -> }) {
javaLibs(configMap) { stages ->
stages.publish = { stage, params, JavaConfig config ->
stage.when = { true } //always
Expand All @@ -20,5 +20,6 @@ def call(Map configMap = [:]) {
'ossrh.signing.passphrase')
}
}
stagesConfigCls(stages)
}
}
4 changes: 2 additions & 2 deletions vars/javaLibs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import net.wooga.jenkins.pipeline.config.JavaConfig
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

def call(Map configMap = [:], Closure stepsConfigCls) {
def call(Map configMap = [:], Closure stagesConfigCls) {
//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)
configMap.clearWs = configMap.get("clearWs", params.CLEAR_WS as boolean)
def config = JavaConfig.fromConfigMap(configMap, this)
def actions = Stages.fromClosure(params as Map, config, stepsConfigCls)
def actions = Stages.fromClosure(params as Map, config, stagesConfigCls)
def mainPlatform = config.mainPlatform.name

pipeline {
Expand Down

0 comments on commit 86ff4e2

Please sign in to comment.