-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
63 lines (58 loc) · 2.1 KB
/
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
pipeline {
agent {
kubernetes {
defaultContainer 'kaniko'
yaml """
kind: Pod
spec:
containers:
- name: kaniko
image: gcr.io/k8s-skaffold/skaffold:latest
imagePullPolicy: IfNotPresent
command:
- cat
tty: true
"""
}
}
options {
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '5', numToKeepStr: '20')
timeout(15)
disableConcurrentBuilds()
}
parameters {
credentials credentialType: 'com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl', defaultValue: 'aws_jenkins_s3', description: 'AWS Credentials to use to publish', name: 'AWS_CREDENTIALS', required: true
string defaultValue: 'www.robbot.app', description: 'AWS S3 Bucket to push to', name: 'AWS_S3_BUCKET', trim: true
}
stages {
stage("Checkout") {
steps {
checkout([
$class: 'GitSCM',
branches: scm.branches,
extensions: scm.extensions + [[$class: 'SubmoduleOption', parentCredentials: true]],
userRemoteConfigs: scm.userRemoteConfigs
])
}
}
stage("Build and Deploy"){
steps {
echo "Params used:"
echo "${params}"
echo "---"
echo "env | sort"
sh "env | sort"
echo "---"
withCredentials([usernamePassword(credentialsId: "${params.AWS_CREDENTIALS}", passwordVariable: 'awsSecretAccessKey', usernameVariable: 'awsAccessKeyId')]) {
sh "/kaniko/executor " +
"-f `pwd`/build.Dockerfile " +
"-c `pwd` " +
"--build-arg 'awsAccessKeyId=${awsAccessKeyId}' " +
"--build-arg 'awsSecretAccessKey=${awsSecretAccessKey}' " +
"--build-arg 'targetS3Bucket=${params.AWS_S3_BUCKET}' "+
"--no-push"
}
}
}
}
}