This repository was archived by the owner on Oct 3, 2024. It is now read-only.
forked from eficode-academy/jenkins-katas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
73 lines (72 loc) · 1.72 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
pipeline {
agent any
environment {
docker_username = 'horib'
}
stages {
stage('clone down') {
steps {
stash excludes: '.git', name: 'code'
}
}
stage('Parallel execution') {
parallel {
stage('Say Hello') {
steps {
sh 'echo "hello world"'
}
}
stage('build app') {
options {
skipDefaultCheckout(true) }
agent {
docker {
image 'gradle:jdk11'
}
}
steps {
unstash 'code'
sh 'ci/build-app.sh'
archiveArtifacts 'app/build/libs/'
stash excludes: '.git', name: 'code'
sh 'ls'
deleteDir()
sh 'ls -lah'
}
}
stage('test app') {
options {
skipDefaultCheckout(true) }
agent {
docker {
image 'gradle:jdk11'
}
}
steps {
unstash 'code'
sh 'ci/unit-test-app.sh'
junit 'app/build/test-results/test/TEST-*.xml'
}
}
}
}
stage('push docker app') {
when {
beforeAgent true
branch 'master'
}
environment {
DOCKERCREDS = credentials('docker_login') //use the credentials just created in this stage
}
options {
skipDefaultCheckout(true)
}
steps {
unstash 'code' //unstash the repository code
sh 'ci/build-docker.sh'
sh 'echo "$DOCKERCREDS_PSW" | docker login -u "$DOCKERCREDS_USR" --password-stdin' //login to docker hub with the credentials above
sh 'ci/push-docker.sh'
}
}
}
}