forked from hibernate/hibernate-github-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
67 lines (66 loc) · 2.24 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
@Library('[email protected]') _
pipeline {
agent {
label 'Worker'
}
tools {
maven 'Apache Maven 3.6'
jdk 'OpenJDK 17 Latest'
}
stages {
stage('Build') {
steps {
checkout scm
sh """ \
./mvnw -B clean verify
"""
}
}
stage('Deploy image') {
when {
beforeAgent true
not { changeRequest() }
}
environment {
QUAY_CREDS = credentials('hibernate.quay.io')
}
steps {
script {
if ( env.BRANCH_NAME == 'main' ) {
env.QUARKUS_CONTAINER_IMAGE_ADDITIONAL_TAGS = 'main,latest'
}
else {
env.QUARKUS_CONTAINER_IMAGE_ADDITIONAL_TAGS = env.BRANCH_NAME
}
}
sh '''
./mvnw -B package -Dquarkus.container-image.build=true -Dquarkus.container-image.push=true \
-Dquarkus.container-image.username=${QUAY_CREDS_USR} \
-Dquarkus.container-image.password=${QUAY_CREDS_PSW} \
'''
}
}
stage('Deploy container') {
when {
beforeAgent true
not { changeRequest() }
branch 'main'
}
steps {
configFileProvider([configFile(fileId: 'release.config.ssh', targetLocation: env.HOME + '/.ssh/config'),
configFile(fileId: 'release.config.ssh.knownhosts', targetLocation: env.HOME + '/.ssh/known_hosts')]) {
// Bots are hosted on the same machine as in.relation.to
sshagent(['jenkins.in.relation.to']) {
// Pull the latest version of the container image and restart the container
sh 'ssh in.relation.to sudo systemctl start podman-auto-update'
}
}
}
}
}
post {
always {
notifyBuildResult maintainers: '[email protected]'
}
}
}