forked from jenkins-infra/jenkins.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile_k8s
101 lines (93 loc) · 2.32 KB
/
Jenkinsfile_k8s
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
pipeline {
agent {
kubernetes {
yaml '''
apiVersion: "v1"
kind: "Pod"
metadata:
labels:
jenkins: "agent"
job: "jenkins-io"
spec:
tolerations:
- key: "os"
operator: "Equal"
value: "linux"
effect: "NoSchedule"
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/os
operator: In
values:
- linux
restartPolicy: "Never"
automountServiceAccountToken: false
containers:
- name: "jnlp"
image: "jenkinsciinfra/builder:2.1.49"
resources:
limits: {}
requests:
memory: "4Gi"
cpu: "2"
'''
}
}
environment {
TZ = "UTC"
USE_LOCAL_NODE = "true"
USE_LOCAL_RUBY = "true"
}
triggers {
cron("${env.BRANCH_NAME == 'master' ? 'H/30 * * * *' : ''}")
}
options {
timeout(time: 60, unit: 'MINUTES')
ansiColor('xterm')
disableConcurrentBuilds(abortPrevious: true)
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '5', numToKeepStr: '5')
}
stages {
stage('NPM Install') {
steps {
sh 'npm install'
}
}
stage('Bundle Install') {
steps {
// throw errors if Gemfile has been modified since Gemfile.lock
sh '''
bundle config --global frozen 1
bundle install
'''
}
}
stage('Build') {
steps {
sh 'make'
}
}
stage('Deploy to preview site') {
when {
changeRequest target: 'master'
}
environment {
NETLIFY_AUTH_TOKEN = credentials('netlify-auth-token')
}
post {
success {
recordDeployment('jenkins-infra', 'jenkins.io', pullRequest.head, 'success', "https://deploy-preview-${CHANGE_ID}--jenkins-io-site-pr.netlify.app")
}
failure {
recordDeployment('jenkins-infra', 'jenkins.io', pullRequest.head, 'failure', "https://deploy-preview-${CHANGE_ID}--jenkins-io-site-pr.netlify.app")
}
}
steps {
sh('/usr/local/bin/netlify-deploy --siteName "jenkins-io-site-pr" --title "Preview deploy for ${CHANGE_ID}" --alias "deploy-preview-${CHANGE_ID}" -d ./build/_site')
}
}
}
}