-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
92 lines (91 loc) · 2.6 KB
/
Jenkinsfile
File metadata and controls
92 lines (91 loc) · 2.6 KB
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
#!/usr/bin/env groovy
pipeline {
options {
timeout(time: 30, unit: 'MINUTES')
disableConcurrentBuilds()
}
parameters {
string (name: 'GIT_REVISION', defaultValue: 'HEAD', description: 'Git revision to build')
string (name: 'ENV', defaultValue: 'dev', description: 'env to deploy to')
string (name: 'TAG', defaultValue: '', description: 'for tracking build to stage or prod')
}
agent {
node {
label 'master'
customWorkspace './open-termhub'
}
} // single node jenkins
environment {
ENV = "${params.ENV}"
S3_CREDENTIALS = credentials('DOCKER_HELM_S3')
AWS_ACCESS_KEY_ID = "${env.S3_CREDENTIALS_USR}"
AWS_SECRET_ACCESS_KEY = "${env.S3_CREDENTIALS_PSW}"
AWS_DEFAULT_REGION = 'us-west-2'
CC_TEST_REPORTER_ID = '59e2bccfce77d873a104a4566bd643ec2ad0d3bbe4eae693b6b7c146934b0105'
}
stages {
stage('Git clone and setup') {
steps {
echo 'Checkout code'
script {
if (params.GIT_REVISION == 'HEAD') {
checkout scm
} else {
checkout([$class: 'GitSCM',
branches: [[name: "${params.GIT_REVISION}"]],
userRemoteConfigs: scm.userRemoteConfigs,
submoduleCfg: []
])
}
}
echo 'Setup Helm'
sh 'helm init --client-only || :'
sh 'helm plugin install https://github.com/hypnoglow/helm-s3.git --version 0.6.0 || :'
sh 'helm repo add wci-helm s3://wci-helm/charts || :'
echo 'Setup Gradle'
sh 'mkdir -p .gradle || :'
sh 'cp /var/lib/jenkins/.gradle/gradle.properties ./.gradle/gradle.properties || :'
sh 'chown -R jenkins:docker .gradle || :'
}
}
stage('Build and test') {
when {
environment name: 'ENV', value: 'dev'
}
steps {
echo 'Build docker image and run unit tests'
sh 'make build'
}
}
stage('release') {
when {
branch 'master'
environment name: 'ENV', value: 'dev'
}
steps {
echo 'Package and push image and chart artifacts'
sh 'make release'
}
}
stage('deploy') {
when {
branch 'master'
}
steps {
echo "Deploy to ${params.ENV}"
withCredentials([file(credentialsId: "${params.ENV}-kubecfg", variable:'KUBECONFIG')]) {
sh "ENV=${params.ENV} make deploy"
}
}
}
}
post {
always {
echo 'Cleaning Workspace'
cleanWs()
}
failure {
slackSend (color: '#FF0000', message: "FAILED: Build '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
}
}