forked from svanoort/gerrit-workflow-demo
-
Notifications
You must be signed in to change notification settings - Fork 13
/
demoscript-rawgerrit.groovy
63 lines (56 loc) · 1.62 KB
/
demoscript-rawgerrit.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Run this with mvn args on each node
def mvn(args) {
sh "${tool 'Maven 3.x'}/bin/mvn ${args}"
}
def fetch_repo() {
// def changeBranch = "change-${GERRIT_CHANGE_NUMBER}-${GERRIT_PATCHSET_NUMBER}"
// sh 'git clone http://gerrit:8080/primary'
// sh 'git clone http://gerrit:8080/secondary'
sh 'repo init stuff'
sh "cd $GERRIT_PROJECT"
sh "git checkout git fetch origin ${GERRIT_REFSPEC}:${changeBranch}"
sh "git checkout ${changeBranch}"
sh "cd .."
}
// TOOD patchset use
// TODO supply branch name to script for easy customization
def builds = [:]
builds['workflowrun'] = {
node {
sh 'rm -rf source'
// Remove dir component in 1.11, replaced with deletedir
dir ('source') {
fetch_repo()
mvn("clean compile install -f primary/pom.xml")
mvn("clean compile install -Dmaven.test.skip -f secondary/pom.xml")
sh "mv */target/*.jar ."
stash includes: '*.jar', name: 'jars'
}
}
def slowtests = [:]
slowtests['Functional Tests'] = {
node {
// Fetch both artifacts
unstash name:'jars'
sleep 2
// Verify both jars can run successfully
sh 'java -jar primary*.jar -delay 1 --length 100'
sh 'java -jar secondary*.jar'
}
}
slowtests['Integration tests'] = {
node {
sleep 30
unstash name:'jars'
sh 'java -jar primary*.jar `java -jar secondary*.jar`'
}
}
slowtests['failFast'] = true
parallel slowtests
}
// PARALLEL BUILD STEP
builds['parallelbuild'] = {
build job: 'freestylebuild-sample', parameters: [[$class: 'StringParameterValue', name: 'sample', value: 'val']]
}
builds['failFast'] = true
parallel builds