-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJenkinsfile
More file actions
57 lines (53 loc) · 2.31 KB
/
Copy pathJenkinsfile
File metadata and controls
57 lines (53 loc) · 2.31 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
pipeline {
agent any
environment {
GIT_MESSAGE = sh(returnStdout: true, script: "git log -n 1 --format=%s ${GIT_COMMIT}").trim()
GIT_AUTHOR = sh(returnStdout: true, script: "git log -n 1 --format=%ae ${GIT_COMMIT}").trim()
GIT_COMMIT_SHORT = sh(returnStdout: true, script: "git rev-parse --short ${GIT_COMMIT}").trim()
GIT_INFO = "Branch(Version): ${GIT_BRANCH}\nLast Message: ${GIT_MESSAGE}\nAuthor: ${GIT_AUTHOR}\nCommit: ${GIT_COMMIT_SHORT}"
DOCKERHUB_CREDENTIAL = "dockerhub-yymin1022"
DOCKER_IMAGE_NAME = "peeper-ai"
DOCKER_IMAGE_STORAGE = "yymin1022"
DOCKER_IMAGE_TAG = "release${BUILD_NUMBER}"
}
stages {
stage("Build Docker Image") {
steps {
script {
docker.build("${DOCKER_IMAGE_STORAGE}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}")
}
}
}
stage("Push Docker Image to Dockerhub") {
steps {
script {
image = docker.image("${DOCKER_IMAGE_STORAGE}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}")
docker.withRegistry("", DOCKERHUB_CREDENTIAL) {
image.push("$DOCKER_IMAGE_TAG")
image.push("latest")
}
}
}
}
}
post {
success {
withCredentials([string(credentialsId: "discord-default", variable: "DISCORD_WEBHOOK_URL")]) {
discordSend description: "**Build ${BUILD_NUMBER}**가 성공하였습니다.\n\n${GIT_INFO}",
link: env.BUILD_URL,
result: currentBuild.currentResult,
title: env.JOB_NAME,
webhookURL: "$DISCORD_WEBHOOK_URL"
}
}
failure {
withCredentials([string(credentialsId: "discord-default", variable: "DISCORD_WEBHOOK_URL")]) {
discordSend description: "**Build ${BUILD_NUMBER}**가 실패하였습니다.\n\n${GIT_INFO}",
link: env.BUILD_URL,
result: currentBuild.currentResult,
title: env.JOB_NAME,
webhookURL: "$DISCORD_WEBHOOK_URL"
}
}
}
}