-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathJenkinsfile
More file actions
42 lines (38 loc) · 1.44 KB
/
Copy pathJenkinsfile
File metadata and controls
42 lines (38 loc) · 1.44 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
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 = "wa-api"
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 {
always {
UsefulNotifier(currentBuild.currentResult)
}
}
}