-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
99 lines (85 loc) · 2.31 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
#!/usr/bin/env groovy
def pkg_build_number() {
now = new Date().format("yyyyMMddHHmmss")
return "${env.BUILD_NUMBER}.${now}"
}
def platform2Dir = [
"centos7" : 'rpm',
"centos7java11" : 'rpm',
"centos7java17" : 'rpm',
"centos8" : 'rpm',
"ubuntu1604" : 'deb',
"ubuntu1804" : 'deb'
]
def buildPackages(platform, platform2Dir) {
return {
unstash "source"
def platformDir = platform2Dir[platform]
if (!platformDir) {
error("Unknown platform: ${platform}")
}
dir(platformDir) {
sh "PLATFORM=${platform} pkg-build.sh"
}
}
}
pipeline {
agent {
label 'docker'
}
options {
timeout(time: 1, unit: 'HOURS')
buildDiscarder(logRotator(numToKeepStr: '5'))
}
environment {
PKG_TAG = "${env.BRANCH_NAME}"
DOCKER_REGISTRY_HOST = "${env.DOCKER_REGISTRY_HOST}"
PLATFORMS = "centos7java17"
PACKAGES_VOLUME = "pkg-vol-${env.BUILD_TAG}"
STAGE_AREA_VOLUME = "sa-vol-${env.BUILD_TAG}"
PKG_SIGN_PACKAGES = "y"
PKG_SIGN_PUB_KEY = "/gpg/indigo-iam-release.pub.gpg"
PKG_SIGN_PRI_KEY = "/gpg/indigo-iam-release.pri.gpg"
DOCKER_ARGS = "--rm -v /opt/cnafsd/helper-scripts/scripts/:/usr/local/bin -v ${env.HOME}/gpg-keys/indigo-iam:/gpg:ro -v ${env.WORKSPACE}/.rpmmacros:/home/build/.rpmmacros:ro"
// PKG_SIGN_KEY_PASSWORD = credentials('indigo-iam-release-key-password')
INCLUDE_BUILD_NUMBER = "${env.BRANCH_NAME == 'develop' ? '1' : '0'}"
PKG_BUILD_NUMBER = "${pkg_build_number()}"
}
stages{
stage('checkout') {
steps {
deleteDir()
checkout scm
stash name: "source", includes: "**"
}
}
stage('setup-volumes') {
steps {
sh 'pwd && ls -lR'
sh 'rm -rf artifacts && mkdir -p artifacts'
sh './setup-volumes.sh'
}
}
stage('package') {
steps {
script {
def buildStages = PLATFORMS.split(' ').collectEntries {
[ "${it} build packages" : buildPackages(it, platform2Dir) ]
}
parallel buildStages
}
}
}
stage('archive-artifacts') {
steps {
sh 'pkg-copy-artifacts.sh'
archiveArtifacts "artifacts/**"
}
}
stage('cleanup') {
steps {
sh 'docker volume rm ${PACKAGES_VOLUME} ${STAGE_AREA_VOLUME} || echo Volume removal failed'
}
}
}
}