forked from spring-attic/aws-maven
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
55 lines (52 loc) · 1.6 KB
/
Jenkinsfile
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
#!/usr/bin/env groovy
MAVEN_BUILD = 'mvn clean package assembly:single -Dmaven.test.skip=true'
COPY_JAR_UNIX = 'cp -vf target/aws-maven-*.jar $M2_HOME/lib/'
COPY_JAR_WINDOWS = 'copy /y target\\aws-maven-*.jar %M2_HOME%\\lib\\'
def createJob(nodeName) {
return {
node(nodeName) {
checkout scm
def mavenHome = tool type: 'maven', name: params.MAVEN_VERSION
withEnv(["PATH+MAVEN=${mavenHome}/bin", "M2_HOME=${mavenHome}"]) {
if (isUnix()) {
sh MAVEN_BUILD
sh COPY_JAR_UNIX
} else {
bat MAVEN_BUILD
bat COPY_JAR_WINDOWS
}
}
}
}
}
pipeline {
agent none
options {
skipDefaultCheckout()
ansiColor('xterm')
}
parameters {
string(name: 'JENKINS_SLAVE_LABEL',
defaultValue: 'none',
description: 'Specify the label of jenkins slave to run.')
string(name: 'MAVEN_VERSION',
defaultValue: '3.3.9',
description: 'Maven version to use.')
}
stages {
stage('Maven Package') {
steps {
script {
assert params.JENKINS_SLAVE_LABEL
assert params.MAVEN_VERSION
def jobs = [:]
def nodeNames = nodesByLabel params.JENKINS_SLAVE_LABEL
for (name in nodeNames) {
jobs[name] = createJob(name)
}
parallel jobs
}
}
}
}
}