-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
113 lines (100 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
109
110
111
112
113
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'
script {
if (env.BRANCH_NAME == 'master') {
sh 'composer require --dev cyclonedx/cyclonedx-php-composer --no-progress'
sh 'composer CycloneDX:make-sbom --output-format=JSON --output-file=bom.json'
withCredentials([string(credentialsId: 'dependency-track', variable: 'API_KEY')]) {
sh 'curl -v --fail -X POST https://api.dependency-track.ivyteam.io/api/v1/bom \
-H "Content-Type: multipart/form-data" \
-H "X-API-Key: ' + API_KEY + '" \
-F "autoCreate=true" \
-F "projectName=dev.axonivy.com" \
-F "projectVersion=master" \
-F "[email protected]"'
}
}
}
}
}
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"
}
}
}
}
}
}