-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJenkinsfile
139 lines (118 loc) · 4.66 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
version = "2.0.${BUILD_NUMBER}"
groupId = 'program-ab'
artifactId = 'program-ab-data'
resourceDir = 'ProgramAB'
groupIdPath = groupId.replaceAll('\\.', '/')
pipeline {
// use linux for ssh or switch from ssh-agent to plain ssh
// agent { label 'linux' }
agent any
environment {
VERSION = "${version}"
GROUP_ID = "${groupId}"
GROUP_ID_PATH = "${groupIdPath}"
ARTIFACT_ID = "${artifactId}"
RESOURCE_DIR = "${resourceDir}"
}
options {
// This is required if you want to clean before build
skipDefaultCheckout(true)
}
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('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
}
}
stage('clean') {
steps {
echo '====== clean ======'
// cleanWs()
script {
if (isUnix()) {
sh '''
mvn clean
'''
} else {
bat('''
mvn clean
''')
}
}
}
}
// FIXME - InMoov/version file needs to be created
stage('build') {
steps {
script {
echo '====== build ======'
if (isUnix()) {
sh '''
echo "building ${JOB_NAME}..."
echo "${VERSION}" > version.txt
mvn package
'''
} else {
bat('''
type "building ${JOB_NAME}..."
type '${VERSION}' > version.txt
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}-0.0.1-SNAPSHOT.zip ubuntu@repo.myrobotlab.org:/home/ubuntu'
sh '''
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ubuntu@repo.myrobotlab.org sudo mvn install:install-file -Dfile=${ARTIFACT_ID}-0.0.1-SNAPSHOT.zip \
-DgroupId=${GROUP_ID} \
-DartifactId=${ARTIFACT_ID} \
-Dversion=${VERSION} \
-Dpackaging=zip \
-DlocalRepositoryPath=/repo/artifactory/myrobotlab/
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ubuntu@repo.myrobotlab.org sudo mv \
/repo/artifactory/myrobotlab/${GROUP_ID_PATH}/${ARTIFACT_ID}/maven-metadata-local.xml \
/repo/artifactory/myrobotlab/${GROUP_ID_PATH}/${ARTIFACT_ID}/maven-metadata.xml
'''
} // sshagent
discordSend description: "worky !", footer: "", link: env.BUILD_URL, result: currentBuild.currentResult, title: JOB_NAME, webhookURL: "https://discord.com/api/webhooks/1015707773260005388/1i6svmKMHYKAFbTXBgen_4CClypYpeqg4WEBMFnc-46Vmf1TNWCxW-ASgDE7mDkkix3u"
} // success
aborted {
discordSend description: "abort abort !", footer: "", link: env.BUILD_URL, result: currentBuild.currentResult, title: JOB_NAME, webhookURL: "https://discord.com/api/webhooks/1015707773260005388/1i6svmKMHYKAFbTXBgen_4CClypYpeqg4WEBMFnc-46Vmf1TNWCxW-ASgDE7mDkkix3u"
}
unsuccessful {
discordSend description: "noWorky !", footer: "", link: env.BUILD_URL, result: currentBuild.currentResult, title: JOB_NAME, webhookURL: "https://discord.com/api/webhooks/1015707773260005388/1i6svmKMHYKAFbTXBgen_4CClypYpeqg4WEBMFnc-46Vmf1TNWCxW-ASgDE7mDkkix3u"
}
} // post
} // pipeline