-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f64c48
commit cd42e2b
Showing
6 changed files
with
86 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package net.wooga.jenkins.pipeline.check | ||
|
||
import net.wooga.jenkins.pipeline.check.steps.PackedStep | ||
import net.wooga.jenkins.pipeline.config.Platform | ||
import net.wooga.jenkins.pipeline.model.Docker | ||
|
||
class Nodes { | ||
|
||
private Object jenkins | ||
private Docker docker | ||
private EnclosureCreator enclosureCreator | ||
|
||
Nodes(Object jenkins, Docker docker, EnclosureCreator enclosureCreator) { | ||
this.jenkins = jenkins | ||
this.docker = docker | ||
this.enclosureCreator = enclosureCreator | ||
} | ||
|
||
def withDocker(Platform platform, PackedStep mainCls, Closure catchCls = {throw it}, PackedStep finallyCls = {}) { | ||
return enclosureCreator.atlasNode(platform.name, | ||
platform.generateTestLabelsString(), | ||
platform.testEnvironment, | ||
withCheckout(platform.checkoutDirectory, { docker.runOnImage(mainCls) }), | ||
catchCls, | ||
withCleanup(platform.clearWs, finallyCls) | ||
) | ||
} | ||
|
||
def simple(Platform platform, PackedStep mainClosure, Closure catchCls = {throw it}, PackedStep finallyCls = {}) { | ||
return enclosureCreator.atlasNode(platform.name, | ||
platform.generateTestLabelsString(), | ||
platform.testEnvironment, | ||
withCheckout(platform.checkoutDirectory, mainClosure), | ||
catchCls, | ||
withCleanup(platform.clearWs, finallyCls) | ||
) | ||
} | ||
|
||
private PackedStep withCheckout(String checkoutDir, PackedStep step) { | ||
return { | ||
jenkins.dir(checkoutDir) { | ||
jenkins.checkout(jenkins.scm) | ||
} | ||
step() | ||
} | ||
} | ||
|
||
private PackedStep withCleanup(boolean hasCleanup, PackedStep step) { | ||
return { | ||
step() | ||
if(hasCleanup) { | ||
jenkins.cleanWs() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters