Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lindt committed Aug 11, 2016
1 parent ea822fb commit 8d0ba44
Show file tree
Hide file tree
Showing 38 changed files with 179 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vars/buildr.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def call(task) {
shStage(task, "buildr ${task}")
}
1 change: 1 addition & 0 deletions vars/buildr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Executes a buildr task.
6 changes: 6 additions & 0 deletions vars/catchStage.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def call(String name, Closure body) {
stage name
mayFail(name) {
body()
}
}
1 change: 1 addition & 0 deletions vars/catchStage.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Executes a stage, catches it's error and continues.
5 changes: 5 additions & 0 deletions vars/checkoutScm.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def call() {
gitClean()
checkout scm
gitEnv()
}
1 change: 1 addition & 0 deletions vars/checkoutScm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Checks out from the source control management system
12 changes: 12 additions & 0 deletions vars/developer.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def call(Closure body) {
node('developer') {
try {
withEnv(["BUILD_NODE=${env.NODE_NAME}"]) {
body()
}
} catch(error) {
echo "Error: ${error}"
throw error
}
}
}
1 change: 1 addition & 0 deletions vars/developer.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Executes the statements on a developer node.
9 changes: 9 additions & 0 deletions vars/errors.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def add(String name) {
if (currentBuild.description == null) {
currentBuild.description = ""
}
if (currentBuild.description != "") {
currentBuild.description += ", "
}
currentBuild.description += "${name} failed"
}
1 change: 1 addition & 0 deletions vars/errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Handles the errors during the build process.
14 changes: 14 additions & 0 deletions vars/gitClean.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def call() {
timeout(time: 600, unit: 'SECONDS') {
if (fileExists('.git')) {
echo 'Found Git repository: using Git to clean the tree.'
sh 'git reset --hard'
sh 'git clean -ffdx -e ".*/"'
sh 'git submodule foreach --recursive git reset --hard'
sh 'git submodule foreach --recursive git clean -ffdx'
} else {
echo 'No Git repository found: using deleteDir() to wipe clean'
deleteDir()
}
}
}
1 change: 1 addition & 0 deletions vars/gitClean.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cleans the git workspace.
6 changes: 6 additions & 0 deletions vars/gitEnv.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def call() {
sh 'git rev-parse HEAD > git-revision.tmp'

env.REVISION = readFile('git-revision.tmp').trim()
env.BRANCH = "${env.BRANCH_NAME}"
}
1 change: 1 addition & 0 deletions vars/gitEnv.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sets the git environment variables.
3 changes: 3 additions & 0 deletions vars/grunt.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def call(task) {
shStage(task, "grunt ${task}")
}
1 change: 1 addition & 0 deletions vars/grunt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Executes a grunt task.
7 changes: 7 additions & 0 deletions vars/ignoreErrors.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def call(Closure body) {
try {
body()
} catch(error) {
// ignore error
}
}
1 change: 1 addition & 0 deletions vars/ignoreErrors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Executes a block and ignore errors.
3 changes: 3 additions & 0 deletions vars/junit_report.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def call(report) {
step([$class: 'JUnitResultArchiver', testResults: report])
}
1 change: 1 addition & 0 deletions vars/junit_report.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reports the JUnit Results.
35 changes: 35 additions & 0 deletions vars/mailOnError.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// TODO: call with map...so that cc: [email protected]

def call(name='') {
if (currentBuild.result != 'FAILURE') {
return
}
def to = emailextrecipients([
[$class: 'CulpritsRecipientProvider'],
[$class: 'DevelopersRecipientProvider'],
[$class: 'RequesterRecipientProvider']])

stage 'failure'

print "Culprits: ${to}\n\n"

def body = "Failing Stages:\n";
body += currentBuild.description
body += "\n\n"
body += "Changesets:\n"
for (changeSet in currentBuild.changeSets) {
body += " - ${changeSet}\n"
}
body += "\n"
body += "Please go to ${env.BUILD_URL}.\n\n";
body += "Culprits: ${to}\n\n"
for (cause in currentBuild.rawBuild.getCauses()) {
body += " - ${cause.getShortDescription()}\n"
}

mail(
to: to,
cc: name,
subject: "${env.JOB_NAME} - Build ${env.BUILD_NUMBER} Failed!",
body: body)
}
1 change: 1 addition & 0 deletions vars/mailOnError.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Mail in case of an error to the culprits.
17 changes: 17 additions & 0 deletions vars/mayFail.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
def call(Closure body) {
call('unnamed stage', body)
}

def call(String name, Closure body) {
timeStamped {
catchError {
try {
body()
} catch(error) {
errors.add name

throw error
}
}
}
}
1 change: 1 addition & 0 deletions vars/mayFail.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Executes a block, that may fail and reports it's error.
3 changes: 3 additions & 0 deletions vars/notifyStash.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def call() {
step([$class: 'StashNotifier'])
}
1 change: 1 addition & 0 deletions vars/notifyStash.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Notifies Stash about the Build.
8 changes: 8 additions & 0 deletions vars/parallelize.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def call(list, closure) {
variants = [:]

for (item in list) {
variants[item] = { closure(item) }
}
parallel variants
}
1 change: 1 addition & 0 deletions vars/parallelize.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Execute tasks parallel. First argument are the parameters passed each time to the closure, which is the second argument.
3 changes: 3 additions & 0 deletions vars/rake.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def call(name) {
shStage(name, "rake ${name}")
}
1 change: 1 addition & 0 deletions vars/rake.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Executes a rake task.
5 changes: 5 additions & 0 deletions vars/sequential.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def call(list, closure) {
for (item in list) {
closure(item)
}
}
1 change: 1 addition & 0 deletions vars/sequential.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Executes tasks sequential.
11 changes: 11 additions & 0 deletions vars/shStage.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def call(command) {
catchStage(command) {
sh command
}
}

def call(name, command) {
catchStage(name) {
sh command
}
}
1 change: 1 addition & 0 deletions vars/shStage.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Executes a shell command within a stage.
5 changes: 5 additions & 0 deletions vars/timeStamped.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def call(Closure body) {
wrap([$class: 'TimestamperBuildWrapper']) {
body()
}
}
1 change: 1 addition & 0 deletions vars/timeStamped.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adds timestamps to the output.
5 changes: 5 additions & 0 deletions vars/xvfb.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def call(Closure body) {
wrap([$class: 'Xvfb']) {
body()
}
}
1 change: 1 addition & 0 deletions vars/xvfb.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Wraps into an xvfb session.

0 comments on commit 8d0ba44

Please sign in to comment.