-
Notifications
You must be signed in to change notification settings - Fork 211
/
fabric8UITemplate.groovy
77 lines (67 loc) · 3.69 KB
/
fabric8UITemplate.groovy
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
#!/usr/bin/groovy
import io.fabric8.Fabric8Commands
def call(Map parameters = [:], body) {
def flow = new Fabric8Commands()
def defaultLabel = buildId('ui')
def label = parameters.get('label', defaultLabel)
def uiImage = parameters.get('uiImage', 'fabric8/fabric8-ui-builder:v3c57d6b')
def inheritFrom = parameters.get('inheritFrom', 'base')
def jnlpImage = (flow.isOpenShift()) ? 'fabric8/jenkins-slave-base-centos7:v54e55b7' : 'jenkinsci/jnlp-slave:2.62'
def cloud = flow.getCloudConfig()
def userSecret = 'planner-team-test-osio-token'
def testEnvVars = [
secretEnvVar(secretName: userSecret, key: 'PLANNER_TOKEN', secretKey: 'planner-test-osio-token'),
envVar(key: 'DOCKER_CONFIG', value: '/home/jenkins/.docker/')
]
def utils = new io.fabric8.Utils()
if (utils.isUseOpenShiftS2IForBuilds()) {
echo 'Runnning on openshift so using S2I binary source and Docker strategy'
podTemplate(cloud: cloud, label: label, serviceAccount: 'jenkins', inheritFrom: "${inheritFrom}",
containers: [
containerTemplate(
name: 'jnlp',
image: "${jnlpImage}",
args: '${computer.jnlpmac} ${computer.name}',
workingDir: '/home/jenkins/'),
containerTemplate(
name: 'ui',
image: "${uiImage}",
command: '/bin/sh -c',
args: 'cat',
ttyEnabled: true,
workingDir: '/home/jenkins/',
envVars: testEnvVars)
],
volumes: [
secretVolume(secretName: 'jenkins-docker-cfg', mountPath: '/home/jenkins/.docker'),
secretVolume(secretName: 'npm-npmrc', mountPath: '/home/jenkins/.npm-npmrc'),
secretVolume(secretName: 'npm-token', mountPath: '/home/jenkins/.npm-token'),
secretVolume(secretName: 'jenkins-hub-api-token', mountPath: '/home/jenkins/.apitoken')]) {
body()
}
} else {
echo 'Mounting docker socket to build docker images'
podTemplate(cloud: cloud, label: label, serviceAccount: 'jenkins', inheritFrom: "${inheritFrom}",
containers: [
containerTemplate(
name: 'ui',
image: "${uiImage}",
command: '/bin/sh -c',
args: 'cat',
privileged: true,
workingDir: '/home/jenkins/',
ttyEnabled: true,
envVars: testEnvVars)
],
volumes: [
secretVolume(secretName: 'jenkins-docker-cfg', mountPath: '/home/jenkins/.docker'),
secretVolume(secretName: 'jenkins-hub-api-token', mountPath: '/home/jenkins/.apitoken'),
secretVolume(secretName: 'npm-npmrc', mountPath: '/home/jenkins/.npm-npmrc'),
secretVolume(secretName: 'jenkins-ssh-config', mountPath: '/root/.ssh-ro'),
secretVolume(secretName: 'jenkins-git-ssh', mountPath: '/root/.ssh-git-ro'),
secretVolume(secretName: 'npm-token', mountPath: '/home/jenkins/.npm-token'),
hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock')]) {
body()
}
}
}