-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
97 lines (85 loc) · 2.43 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
pipeline {
agent any
triggers {
cron 'H 22 * * *'
}
options {
buildDiscarder(logRotator(numToKeepStr: '120', artifactNumToKeepStr: '3'))
skipStagesAfterUnstable()
}
environment {
DIST_FILE = "ivy-website-developer.tar"
}
stages {
stage('build') {
agent {
dockerfile {
dir 'docker/apache'
}
}
steps {
sh 'composer install --no-dev --no-progress'
sh "tar -cf ${env.DIST_FILE} --exclude=src/web/releases --exclude=src/web/docs src vendor"
archiveArtifacts env.DIST_FILE
stash name: 'website-tar', includes: env.DIST_FILE
sh 'composer install --no-progress'
sh './vendor/bin/phpunit --log-junit phpunit-junit.xml || exit 0'
junit 'phpunit-junit.xml'
}
}
stage('sonar') {
when {
branch 'master'
}
agent {
docker {
image 'sonarsource/sonar-scanner-cli'
args '-e SONAR_HOST_URL=https://sonar.ivyteam.io'
}
}
steps {
sh 'sonar-scanner'
}
}
stage('check editorconfig') {
steps {
script {
docker.image('mstruebing/editorconfig-checker').inside {
sh 'ec -no-color'
}
}
}
}
stage('deploy') {
when {
branch 'master'
}
agent {
docker {
image 'axonivy/build-container:ssh-client-1'
}
}
steps {
sshagent(['zugprojenkins-ssh']) {
script {
unstash 'website-tar'
def targetFolder = "/home/axonivya/deployment/ivy-website-developer-" + 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 mkdir $targetFolder/src/web/releases"
sh "ssh $host ln -fns /home/axonivya/data/ivy-releases $targetFolder/src/web/releases/ivy"
sh "ssh $host ln -fns /home/axonivya/data/doc $targetFolder/src/web/docs"
sh "ssh $host ln -fns $targetFolder/src/web /home/axonivya/www/developer.axonivy.com/linktoweb"
}
}
}
}
}
}