-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile.release
74 lines (72 loc) · 2.44 KB
/
Jenkinsfile.release
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
def label = "wordsmith-api-release-${UUID.randomUUID().toString()}"
podTemplate(label: label, yaml: """
apiVersion: v1
kind: Pod
spec:
containers:
- name: jnlp
- name: jdk
image: openjdk:8-jdk
command:
- cat
tty: true
- name: docker
image: docker:stable-dind
command:
- cat
tty: true
volumeMounts:
- mountPath: /var/run/docker.sock
name: docker-sock
- name: helm
image: devth/helm:v2.10.0
command:
- cat
tty: true
volumes:
- name: docker-sock
hostPath:
path: /var/run/docker.sock
type: File
"""
) {
node (label) {
git 'https://github.com/cloudbeers/wordsmith-api.git'
stage('Release Java App') {
container('jdk') {
withEnv(['GIT_COMMITTER_NAME=Cyrille Le Clerc', '[email protected]', 'GIT_AUTHOR_NAME=Cyrille Le Clerc', '[email protected]']) {
withMaven(mavenOpts: '-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn') {
sh './mvnw release:prepare release:perform'
}
}
}
}
stage('Release Docker Image') {
container('docker') {
withCredentials([usernamePassword(credentialsId: 'hub.docker.com', passwordVariable: 'DOCKER_HUB_CREDS_PSW', usernameVariable: 'DOCKER_HUB_CREDS_USR')]) {
APPLICATION_VERSION = readFile("target/VERSION")
sh """
cd target/checkout
docker login --username ${DOCKER_HUB_CREDS_USR} --password ${DOCKER_HUB_CREDS_PSW}
rm target/*-javadoc.jar
rm target/*-sources.jar
docker build -t ${DOCKER_HUB_CREDS_USR}/wordsmith-api:${APPLICATION_VERSION} .
docker push ${DOCKER_HUB_CREDS_USR}/wordsmith-api:${APPLICATION_VERSION}
"""
}
}
}
stage('Release Helm Chart') {
container('helm') {
sh """
cd target/checkout
# create helm chart version
helm package target/charts/wordsmith-api
# upload helm chart
curl --data-binary "@wordsmith-api-${APPLICATION_VERSION}.tgz" http://chartmuseum-chartmuseum.core.svc.cluster.local:8080/api/charts
"""
archiveArtifacts artifacts: "target/checkout/wordsmith-api-${APPLICATION_VERSION}.tgz", fingerprint: true
}
}
}
}