forked from axonivy-market/market
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
74 lines (65 loc) · 1.9 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
pipeline {
agent any
triggers {
cron '@midnight'
}
options {
buildDiscarder(logRotator(numToKeepStr: '60', artifactNumToKeepStr: '3'))
skipStagesAfterUnstable()
}
stages {
stage('validate') {
steps {
script {
docker.image('mstruebing/editorconfig-checker:2.0.4').inside {
sh 'ec -no-color'
}
docker.image('maven:3.6.3-jdk-11').inside {
dir ('market-test') {
maven cmd: 'compile exec:java -Dexec.mainClass="com.axonivy.market.CreateBundle"'
maven cmd: 'verify'
}
}
recordIssues tools: [eclipse()], unstableTotalAll: 1
recordIssues tools: [mavenConsole()], unstableTotalAll: 1
junit '**/target/surefire-reports/**/*.xml'
}
}
}
stage('deploy') {
when {
branch 'master'
}
agent {
docker {
image 'axonivy/build-container:ssh-client-1'
reuseNode true
}
}
environment {
DIST_FILE = "market.tar"
}
steps {
dir ('market-test/target') {
sh "tar -cf ../../${env.DIST_FILE} market"
}
archiveArtifacts env.DIST_FILE
sshagent(['zugprojenkins-ssh']) {
script {
def targetFolder = "/home/axonivya/deployment/market-" + new Date().format("yyyy-MM-dd_HH-mm-ss-SSS");
def targetFile = targetFolder + ".tar"
def host = '[email protected]'
// copy
sh "scp ${env.DIST_FILE} $host:$targetFile"
// untar
sh "ssh $host mkdir $targetFolder"
sh "ssh $host tar -xf $targetFile -C $targetFolder"
sh "ssh $host rm -f $targetFile"
// symlink
sh "ssh $host ln -fns $targetFolder/market /home/axonivya/data/market"
}
}
}
}
}
}