forked from Commonjava/indy-jenkins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sonarqubeImageBuild.Jenkinsfile
94 lines (94 loc) · 2.55 KB
/
sonarqubeImageBuild.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
library identifier: 'c3i@master', changelog: false,
retriever: modernSCM([$class: 'GitSCMSource', remote: 'https://pagure.io/c3i-library.git'])
import static org.apache.commons.lang.StringEscapeUtils.escapeHtml;
pipeline {
agent {
kubernetes {
cloud params.JENKINS_AGENT_CLOUD_NAME
label "jenkins-slave-${UUID.randomUUID().toString()}"
serviceAccount "jenkins"
defaultContainer 'jnlp'
yaml """
apiVersion: v1
kind: Pod
metadata:
labels:
app: "jenkins-${env.JOB_BASE_NAME}"
indy-pipeline-build-number: "${env.BUILD_NUMBER}"
spec:
containers:
- name: jnlp
image: registry.redhat.io/openshift3/jenkins-agent-maven-35-rhel7:v3.11.219-1
imagePullPolicy: Always
tty: true
env:
- name: USER
value: 'jenkins-k8s-config'
- name: IMG_BUILD_HOOKS
valueFrom:
secretKeyRef:
key: img-build-hooks.json
name: img-build-hooks-secrets
- name: HOME
value: /home/jenkins
resources:
requests:
memory: 4Gi
cpu: 2000m
limits:
memory: 8Gi
cpu: 4000m
volumeMounts:
- mountPath: /home/jenkins/sonatype
name: volume-0
- mountPath: /mnt/ocp
name: volume-2
workingDir: /home/jenkins
volumes:
- name: volume-0
secret:
defaultMode: 420
secretName: sonatype-secrets
- name: volume-2
configMap:
defaultMode: 420
name: jenkins-openshift-mappings
"""
}
}
options {
timeout(time: 30, unit: 'MINUTES')
}
environment {
PIPELINE_NAMESPACE = readFile('/run/secrets/kubernetes.io/serviceaccount/namespace').trim()
PIPELINE_USERNAME = sh(returnStdout: true, script: 'id -un').trim()
}
stages {
stage('Build Quay Image') {
when{
expression{
return params.PUSH_TO_QUAY == true
}
}
steps{
script{
openshift.withCluster(){
def template = readYaml file: 'openshift/sonarqube-quay-template.yaml'
def processed = openshift.process(template,
'-p', "QUAY_TAG='latest'"
)
def build = c3i.buildAndWait(script: this, objs: processed)
echo 'Publish build succeeds!'
}
}
}
}
}
post {
success {
script {
echo "SUCCEED"
}
}
}
}