-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJenkinsfile
178 lines (129 loc) · 7.82 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
def userInputAcceptRelease = false
node {
// Only keep one build
properties([[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '5']]])
cleanWs()
// Mark the code checkout 'stage'....
stage('Checkout')
{
checkout scm
sh 'git submodule update --init'
}
try {
if (env.BRANCH_NAME == 'release') {
//https://support.cloudbees.com/hc/en-us/articles/226554067-Pipeline-How-to-add-an-input-step-with-timeout-that-continues-if-timeout-is-reached-using-a-default-value
try {
timeout(time: 15, unit: 'MINUTES') {
// change to a convenient timeout for you
userInputAcceptRelease = input(message: 'Do want to run the release script?', ok: 'Yes',
parameters: [booleanParam(defaultValue: false,
description: 'If you want to run the release script and perform a release, just push the button', name: 'Yes?')])
}
} catch (err) {
echo "Timeout or build abort. Marking build as SUCCESS."
currentBuild.result = 'SUCCESS'
return
}
if (userInputAcceptRelease == true) {
echo "Release accepted"
echo "Checkout branch ${env.BRANCH_NAME} to confirm to the release script"
sh "git checkout ${env.BRANCH_NAME}"
sh "echo build..."
sh "wget -q https://raw.githubusercontent.com/overturetool/overture-release-scripts/master/perform-release.sh -O perform-release.sh"
sh "sed -i 's/localCheckout=true/localCheckout=false/g' perform-release.sh"
sh "chmod +x perform-release.sh"
sh "wget -q https://raw.githubusercontent.com/overturetool/overture-release-scripts/master/git-set-private-key.sh -O git-set-private-key.sh"
sh "chmod +x git-set-private-key.sh"
// sh "git checkout development"
sh "batchmode=release ./perform-release.sh ${env.MVN_SETTINGS_PATH}"
sh "echo Detecting current version"
version = sh "mvn -f target/checkout -q -s ${env.MVN_SETTINGS_PATH} -N org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -DDmaven.repo.local=.repository/"
version = sh(script: "mvn -f target/checkout -s ${env.MVN_SETTINGS_PATH} -N org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -DDmaven.repo.local=.repository/ | grep -v '\\[' | grep -v -e '^\$'", returnStdout: true).trim()
sh "echo Version K${version}K"
sh "cp target/checkout/core/fmu-import-export/target/fmu-import-export-${version}-jar-with-dependencies.jar target/checkout/ide/repository/target/repository/fmu-import-export.jar"
sh '''#/bin/bash
cd target/checkout/ide/repository/target/repository
zip -r ../p2.zip .
mv ../p2.zip .
'''
}
} else {
stage('Clean') {
withMaven(mavenLocalRepo: '.repository', mavenSettingsFilePath: "${env.MVN_SETTINGS_PATH}") {
// Run the maven build -PWith-IDE
sh "mvn clean install -U -Pcodesigning"
}
}
stage('Build') {
withMaven(mavenLocalRepo: '.repository', mavenSettingsFilePath: "${env.MVN_SETTINGS_PATH}") {
// Run the maven build
sh "mvn install -Pall-platforms -PWith-IDE -Pcodesigning"
step([$class: 'ArtifactArchiver', artifacts: '**/target/*.jar', fingerprint: true])
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])
step([$class: 'JacocoPublisher'])
step([$class: 'TasksPublisher', canComputeNew: false, defaultEncoding: '', excludePattern: '', healthy: '', high: 'FIXME', ignoreCase: true, low: '', normal: 'TODO', pattern: '', unHealthy: ''])
}
}
stage('Integration test') {
sh "cd testing && ./integration-test.sh"
}
stage('FMI Compliance Test') {
sh "cd testing && ./validate.sh"
}
stage('Copy CLI to repo') {
sh "echo Detecting current version"
version = sh "mvn -q -s ${env.MVN_SETTINGS_PATH} -N org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -DDmaven.repo.local=.repository/"
version = sh(script: "mvn -s ${env.MVN_SETTINGS_PATH} -N org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -DDmaven.repo.local=.repository/ | grep -v '\\[' | grep -v -e '^\$'", returnStdout: true).trim()
sh "echo Version K${version}K"
sh "cp core/fmu-import-export/target/fmu-import-export-${version}-jar-with-dependencies.jar ide/repository/target/repository/fmu-import-export.jar"
}
stage('Publish Artifactory') {
if (env.BRANCH_NAME == 'development') {
def server = Artifactory.server "-844406945@1404457436085"
def buildInfo = Artifactory.newBuildInfo()
buildInfo.env.capture = true
buildInfo.env.filter.addExclude("org/overturetool/fmi/ide/**")
def rtMaven = Artifactory.newMavenBuild()
rtMaven.tool = "Maven 3.1.1"
// Tool name from Jenkins configuration
rtMaven.opts = "-Xmx1024m -XX:MaxPermSize=256M"
rtMaven.deployer releaseRepo: 'overture-fmu', snapshotRepo: 'overture-fmu', server: server
rtMaven.run pom: 'pom.xml', goals: 'install', buildInfo: buildInfo
//get rid of old snapshots only keep then for a short amount of time
// buildInfo.retention maxBuilds: 5, maxDays: 7, deleteBuildArtifacts: true
// Publish build info.
server.publishBuildInfo buildInfo
}
}
}
stage('Deploy') {
def deployBranchName = env.BRANCH_NAME
if (env.BRANCH_NAME == 'development' || env.BRANCH_NAME == 'release') {
if (env.BRANCH_NAME == 'release') {
deployBranchName = "master"
}
sh "echo branch is now ${env.BRANCH_NAME}"
DEST = sh script: "echo /home/jenkins/web/into-cps/vdm-tool-wrapper/${deployBranchName}/Build-${BUILD_NUMBER}_`date +%Y-%m-%d_%H-%M`", returnStdout: true
REMOTE = "jenkins@overture-server.au.dk"
sh "echo The remote dir will be: ${DEST}"
sh "ssh ${REMOTE} mkdir -p ${DEST}"
if (env.BRANCH_NAME != 'release')
sh "scp -r ide/repository/target/repository/* ${REMOTE}:${DEST}"
else
sh "scp -r target/checkout/ide/repository/target/repository/* ${REMOTE}:${DEST}"
sh "ssh ${REMOTE} /home/jenkins/update-latest.sh web/into-cps/vdm-tool-wrapper/${deployBranchName}"
}
}
} catch (any) {
currentBuild.result = 'FAILURE'
throw any //rethrow exception to prevent the build from proceeding
} finally {
stage('Reporting') {
// Notify on build failure using the Email-ext plugin
emailext(body: '${DEFAULT_CONTENT}', mimeType: 'text/html',
replyTo: '$DEFAULT_REPLYTO', subject: '${DEFAULT_SUBJECT}',
to: emailextrecipients([[$class: 'CulpritsRecipientProvider'],
[$class: 'RequesterRecipientProvider']]))
}
}
}