forked from de-jena/broker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
114 lines (80 loc) · 2.42 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
114
pipeline {
agent any
environment {
JAVA_OPTS = "-Xms2048m -Xmx2048m -XX:MaxMetaspaceSize=1024m ${sh(script:'echo $JAVA_OPTS', returnStdout: true).trim()}"
VERSION = "${env.BUILD_ID}"
}
tools {
jdk 'OpenJDK17'
}
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
}
stages {
stage('clean workspace and checkout') {
steps {
deleteDir()
checkout scm
}
}
stage('App build') {
steps {
echo "I am building app on branch: ${env.GIT_BRANCH}"
sh "./gradlew clean build -x testOSGi --info --stacktrace -Dmaven.repo.local=${WORKSPACE}/.m2"
}
}
stage('Integration Tests') {
steps {
echo "I am running integration tests on branch: ${env.GIT_BRANCH}"
sh "./gradlew testOSGi --info --stacktrace -Dmaven.repo.local=${WORKSPACE}/.m2"
junit testResults: '**/generated/test-reports/**/*.xml', allowEmptyResults: true
}
}
stage('Resolve') {
steps {
echo "I am building app on branch: ${env.GIT_BRANCH}"
sh "./gradlew :de.jena.sensinact.runtime:resolve.base --info --stacktrace -Dmaven.repo.local=${WORKSPACE}/.m2"
}
}
stage('Export') {
when {
branch 'main'
}
steps {
echo "I am building app on branch: ${env.GIT_BRANCH}"
sh "./gradlew :de.jena.sensinact.runtime:export.de.jena.sensinact.runtime.docker --info --stacktrace -Dmaven.repo.local=${WORKSPACE}/.m2"
}
}
stage('Prepare Docker') {
when {
branch 'main'
}
steps {
echo "I am preparing docker: ${env.GIT_BRANCH}"
sh "./gradlew prepareDocker -x testOSGi --info --stacktrace -Dmaven.repo.local=${WORKSPACE}/.m2"
}
}
stage('Docker image build'){
when {
branch 'main'
}
steps {
echo "I am building and publishing a docker image on branch: ${env.GIT_BRANCH}"
step([$class: 'DockerBuilderPublisher',
dockerFileDirectory: 'docker',
cloud: 'docker',
tagsString: """registry-git.jena.de/scj/dim-broker:latest
registry-git.jena.de/scj/dim-broker:${VERSION}""",
pushOnSuccess: true,
pushCredentialsId: 'github-jena'])
step([$class: 'DockerBuilderPublisher',
dockerFileDirectory: 'docker',
cloud: 'docker',
tagsString: """devel.data-in-motion.biz:6000/scj/dim-broker:latest
devel.data-in-motion.biz:6000/scj/dim-broker:${VERSION}""",
pushOnSuccess: true,
pushCredentialsId: 'dim-nexus'])
}
}
}
}