forked from Crashedmind/plantuml-github-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
67 lines (60 loc) · 2.11 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
64
65
66
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr:'8'))
ansiColor('xterm')
disableConcurrentBuilds()
}
environment {
DOCKER_BASE_IMAGE = 'cloudbees/plantuml-github-action'
DOCKER_REPO_NAME = 'docker.io'
SLACK_CHANNELS = "#notify-product-security"
}
agent {
kubernetes {
label "kaniko-${UUID.randomUUID().toString()}"
yamlFile 'KubePod.yaml'
}
}
stages {
stage('Regular build') {
environment {
PATH = "/busybox:/kaniko:$PATH"
}
steps {
container(name: 'kaniko', shell: '/busybox/sh') {
withCredentials([file(credentialsId: 'dockerhub-cbproductsecurity-PAT', variable: 'dockerconfig')]) {
sh '''
mkdir -p /kaniko/.docker
cp ${dockerconfig} /kaniko/.docker/config.json
'''
}
sh '''#!/busybox/sh
set -e
echo "docker image: $DOCKER_BASE_IMAGE"
/kaniko/executor --context `pwd` --dockerfile=`pwd`/Dockerfile --destination $DOCKER_REPO_NAME/$DOCKER_BASE_IMAGE:latest \
'''
}
}
}
}
post {
success {
script {
def message = "${currentBuild.result}: ${env.DOCKER_REPO_NAME}/${env.DOCKER_BASE_IMAGE} built and pushed. (`${env.JOB_NAME}` #${env.BUILD_NUMBER}:\n${env.BUILD_URL})"
slackSend (
channel: "${env.SLACK_CHANNELS}",
message: "${message}"
)
}
}
failure {
script {
def message = "${currentBuild.result}: ${env.DOCKER_REPO_NAME}/${env.DOCKER_BASE_IMAGE} (`${env.JOB_NAME}` #${env.BUILD_NUMBER}:\n${env.BUILD_URL})"
slackSend (
channel: "${env.SLACK_CHANNELS}",
message: "${message}"
)
}
}
}
}