Skip to content

Instantly share code, notes, and snippets.

@wilsonmar
Forked from larrycai/complete.groovy
Created June 24, 2017 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilsonmar/b183a7c5eb4d34e4e6d82c4ec1a11dee to your computer and use it in GitHub Desktop.
Save wilsonmar/b183a7c5eb4d34e4e6d82c4ec1a11dee to your computer and use it in GitHub Desktop.
CodingWithMe Learn JobDSL for Jenkins in 90 minutes
freeStyleJob("Hello3") {
logRotator(2, 30)
scm {
git('https://github.com/larrycai/docker-images.git')
}
triggers {
scm('H/15 * * * *')
}
wrappers {
preBuildCleanup()
}
steps {
shell('echo "build success" >> status.txt')
}
publishers {
archiveArtifacts("status.txt")
}
}
freeStyleJob("Hello5") {
logRotator(2, 30)
scm {
git('https://github.com/larrycai/docker-images.git')
}
triggers {
scm('H/15 * * * *')
}
wrappers {
preBuildCleanup()
}
steps {
shell('echo "build success" >> status.txt')
}
publishers {
archiveArtifacts("status.txt")
configure { project ->
project / publishers << "hudson.plugins.testng.Publisher" {
reportFilenamePattern("**/testng-results.xml")
escapeTestDescp(true)
escapeExceptionMsg(true)
}
}
}
}
def giturl = "https://github.com/larrycai/docker-images.git"
json = readFileFromWorkspace("HelloWorld","views.json")
views = new groovy.json.JsonSlurper().parseText(json)["views"]
views.each { view ->
(0..9).each { i ->
job("${view}-DSL-Tutorial-${i}") {
scm {
git(giturl)
}
steps {
shell('echo "this is job${i}"')
}
}
}
listView(view) {
jobs {
regex("${view}-.*")
}
columns {
status()
weather()
name()
lastSuccess()
lastFailure()
lastDuration()
buildButton()
}
}
}
{
"views" : ["Compile","Package","Release"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment