-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
101 lines (98 loc) · 2.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
pipeline {
agent any
stages {
stage('Clone sources') {
steps {
git url: 'https://github.com/andsild/qwde.git'
checkout([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: true,
extensions: scm.extensions + [[$class: 'SubmoduleOption', parentCredentials: true]],
userRemoteConfigs: scm.userRemoteConfigs
])
}
}
stage('Env check') {
steps {
sh "java -version"
sh "echo $JAVA_HOME"
}
}
stage('Gradle build backend') {
when {
changeset "backend/**"
}
steps {
dir("${env.WORKSPACE}/backend") {
withGradle {
sh './gradlew build check --info'
}
}
}
}
stage('Gradle build frontend') {
when {
changeset "frontend/**"
}
steps {
dir("${env.WORKSPACE}/frontend") {
sh '''
docker image inspect qwdefrontend:deps >/dev/null 2>&1 || docker build -t qwdefrontend:deps . -f Dockerfile_build
rm -rv target || true
mkdir target
docker build -t qwdefrontend:jenkins .
id=$(docker create qwdefrontend:jenkins)
docker cp $id:/qwde/qwdeserver-dist/bin/qwdeserver target/qwdeserver.bin
docker cp $id:/qwde/qwdeclient-dist/bin/qwdeclient.jsexe/all.js target/all.js
docker rm -v $id
cd target/
tar -czvf qwdefrontend.tar.gz all.js qwdeserver.bin
'''
}
}
}
stage('Publish backend') {
when {
anyOf {
changeset "backend/**"
}
}
steps {
dir("${env.WORKSPACE}/backend") {
withGradle {
sh './gradlew publish'
}
sh '''
set +x # don't expose password
token="$(cat /run/secrets/deploy-password)"
echo "Doing curl https://qwde.no:9000/hooks/qwde-deploy?token=..."
curl "https://qwde.no:9000/hooks/qwde-deploy?token=$token&service=qwdebackend&artifact=webapi&classifier=all&extension=jar"
set -x
'''
}
}
}
stage ('Publish frontend') {
when {
anyOf {
changeset "frontend/**"
}
}
steps {
dir("${env.WORKSPACE}/frontend") {
withGradle {
sh './gradlew publish --info'
}
sh '''
set +x # don't expose password
token="$(cat /run/secrets/deploy-password)"
echo "Doing curl https://qwde.no:9000/hooks/qwde-deploy?token=..."
curl "https://qwde.no:9000/hooks/qwde-deploy?token=$token&service=qwdefrontend&artifact=frontend&classifier=prod&extension=tar.gz"
set -x
'''
}
}
}
}
}