forked from eclipse-amlen/amlen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile.distro
114 lines (108 loc) · 4.48 KB
/
Jenkinsfile.distro
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
//This is a more customisable version of the default Jenkinsfile stored at in the root folder of the project
//This version allows (in particular) choosing which Linux distribution to build on
pipeline {
parameters{
//Annoyingly the jobs in jenkins specify a default value as well, so when changing default values below, change them
//in any relevant jobs in the jenkins webui as well
gitParameter branchFilter: 'origin/(.*)', defaultValue: 'main', name: 'branchName', type: 'PT_BRANCH'
choice(name: 'distro', choices: ['centos7','alma8','alma9','fedora'], description: 'Linux distribution to build on')
string(name: 'buildId', defaultValue: '', description: 'Build Identifier to ensure build can be easily identified (set blank to autogenerate - default)')
string(name: 'buildcontainerVersion', defaultValue: '1.0.0.6', description: 'Version of the amlen-build-(distro) container to use to do the build')
}
agent {
kubernetes {
label "amlen-${distro}-build-pod"
yaml """
apiVersion: v1
kind: Pod
spec:
containers:
- name: amlen-${distro}-build
image: "quay.io/amlen/amlen-builder-${distro}:${buildcontainerVersion}"
command:
- cat
tty: true
resources:
limits:
memory: "4Gi"
cpu: "2"
requests:
memory: "4Gi"
cpu: "2"
volumeMounts:
- mountPath: /dev/shm
name: dshm
- name: jnlp
volumeMounts:
- name: volume-known-hosts
mountPath: /home/jenkins/.ssh
volumes:
- name: volume-known-hosts
configMap:
name: known-hosts
- name: dshm
emptyDir:
medium: Memory
"""
}
}
stages {
stage('Init') {
steps {
container("amlen-${distro}-build") {
script {
if (buildId != null && buildId != '') {
env.BUILD_LABEL = buildId
}
if (env.BUILD_LABEL == null ) {
env.BUILD_LABEL = sh(script: "date +%Y%m%d-%H%M", returnStdout: true).toString().trim() +"_eclipse${distro}"
}
currentBuild.displayName ="${currentBuild.number}-${distro}"
}
echo "In Init, BUILD_LABEL is ${env.BUILD_LABEL}"
}
}
}
stage('Build') {
steps {
echo "In Build, BUILD_LABEL is ${env.BUILD_LABEL}"
container("amlen-${distro}-build") {
sh 'pwd && free -m && cd server_build && bash buildcontainer/build.sh'
}
}
}
stage('Deploy') {
steps {
container('jnlp') {
echo "In Deploy, BUILD_LABEL is ${env.BUILD_LABEL}"
sshagent ( ['projects-storage.eclipse.org-bot-ssh']) {
sh '''
pwd
echo ${GIT_BRANCH}
echo "BUILD_LABEL is ${BUILD_LABEL}"
NOORIGIN_BRANCH=${GIT_BRANCH#origin/} # turns origin/main into main
#ssh -o BatchMode=yes [email protected] rm -rf /home/data/httpd/download.eclipse.org/projectname/snapshots
ssh -o BatchMode=yes [email protected] mkdir -p /home/data/httpd/download.eclipse.org/amlen/snapshots/${NOORIGIN_BRANCH}/${BUILD_LABEL}/${distro}
scp -o BatchMode=yes -r rpms/*.tar.gz [email protected]:/home/data/httpd/download.eclipse.org/amlen/snapshots/${NOORIGIN_BRANCH}/${BUILD_LABEL}/${distro}/
'''
}
}
}
}
}
post {
// send a mail on unsuccessful and fixed builds
unsuccessful { // means unstable || failure || aborted
emailext subject: 'Build $BUILD_STATUS $PROJECT_NAME #$BUILD_NUMBER!',
body: '''Check console output at $BUILD_URL to view the results.''',
recipientProviders: [culprits(), requestor()],
to: '[email protected]'
}
fixed { // back to normal
emailext subject: 'Build $BUILD_STATUS $PROJECT_NAME #$BUILD_NUMBER!',
body: '''Check console output at $BUILD_URL to view the results.''',
recipientProviders: [culprits(), requestor()],
to: '[email protected]'
}
}
}