forked from vermilion-tech/stripe-charge-processor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
52 lines (44 loc) · 1.71 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
pipeline {
agent any
environment {
COMMIT_MESSAGE = """${sh(
returnStdout: true,
script: "git --no-pager log --format='medium' -1 ${GIT_COMMIT}"
)}"""
COMMIT_HASH = """${sh(
returnStdout: true,
script: "git describe --always"
)}"""
DOCKER_REPO = "kadenlnelson/stripe-charge-processor"
DOCKER_CREDENTIALS = "docker-hub-kadenlnelson"
}
stages {
stage('Notify Slack') {
steps {
slackSend(color: '#000000', message: "Build Started - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)\n```${env.COMMIT_MESSAGE}```")
}
}
stage('Build & Push Docker Image') {
agent { docker { image 'docker:stable' } }
steps {
script {
def branchName = "${GIT_BRANCH}".replace('/', '_')
def image = docker.build("${DOCKER_REPO}")
docker.withRegistry('', "${DOCKER_CREDENTIALS}") {
image.push(branchName)
image.push("${COMMIT_HASH}")
}
}
slackSend (color: '#0db7ed', message: "Docker Image Built & Pushed - https://hub.docker.com/r/${DOCKER_REPO}/tags\n```\nTry it out!\n\ndocker run --rm ${DOCKER_REPO}:${COMMIT_HASH}```")
}
}
}
post {
failure {
slackSend (color: '#FF0000', message: "Build Failed! - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)")
}
success {
slackSend (color: '#00FF00', message: "Success! - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)")
}
}
}