-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJenkinsfile
108 lines (91 loc) · 3.19 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
pipeline {
// use linux for ssh or switch from ssh-agent to plain ssh
agent { label 'linux' }
environment {
VERSION = '0.0.8.7'
GROUP_ID = 'program-ab'
ARTIFACT_ID = 'program-ab-kw'
}
options {
// This is required if you want to clean before build
// skipDefaultCheckout(true)
skipDefaultCheckout(false)
}
tools {
maven 'M3' // defined in global tools - maven is one of the only installers that works well for global tool
// jdk 'openjdk-11-linux' // defined in global tools
// git
}
stages {
stage('clean') {
steps {
echo '====== clean ======'
cleanWs()
}
}
stage('init') {
steps {
echo '======= init ======='
script {
if (isUnix()) {
echo sh(script: 'env|sort', returnStdout: true)
} else {
bat("set")
}
}
}
}
stage('check out') {
steps {
echo '====== check out ======'
checkout scm
}
}
// FIXME - InMoov/version file needs to be created
stage('package') {
steps {
script {
echo '====== build ======'
if (isUnix()) {
sh '''
echo "building ${JOB_NAME}..."
mvn package
'''
} else {
bat('''
type "building ${JOB_NAME}..."
mvn package
''')
} // isUnix
} // script
} // steps
} // stage
/*
# not necessary to archive files - because the install step will copy the file up
stage('archive') {
steps {
archiveArtifacts 'target/inmoov-'+ version +'.zip'
}
}
*/
} // stages
post {
success {
echo "====== installing into repo ======"
sshagent(credentials : ['myrobotlab2.pem']) {
sh 'scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ./target/${ARTIFACT_ID}-${VERSION}.jar [email protected]:/home/ubuntu'
sh '''
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null [email protected] sudo mvn install:install-file -Dfile=${ARTIFACT_ID}-${VERSION}.jar \
-DgroupId=${GROUP_ID} \
-DartifactId=${ARTIFACT_ID} \
-Dversion=${VERSION} \
-Dpackaging=jar \
-DlocalRepositoryPath=/repo/artifactory/myrobotlab/
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null [email protected] sudo mv \
/repo/artifactory/myrobotlab/${GROUP_ID}/${ARTIFACT_ID}/maven-metadata-local.xml \
/repo/artifactory/myrobotlab/${GROUP_ID}/${ARTIFACT_ID}/maven-metadata.xml
'''
} // sshagent
} // success
} // post
} // pipeline