-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
40 lines (39 loc) · 1.25 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
pipeline {
agent any
environment {
DOCKER_REGISTRY_HOST = "registry.dop.clsaa.com"
DOCKER_REGISTRY = "registry.dop.clsaa.com/1171067930/simple-maven-test"
BUILD_TAG = "latest"
}
stages {
stage('Build Maven') {
steps{
echo 'mvn version'
sh 'mvn --version'
sh 'mvn clean package -Dmaven.test.skip=true'
sh 'mvn package'
}
}
stage('Build Docker'){
steps{
echo 'run'
sh 'docker build -t ${DOCKER_REGISTRY}:${BUILD_TAG} ./'
}
}
stage('Push Docker'){
steps{
echo 'push'
withCredentials([usernamePassword(credentialsId: 'docker_registry', passwordVariable: 'password', usernameVariable: 'username')]) {
sh "docker login -u ${username} -p ${password} ${DOCKER_REGISTRY_HOST}"
sh "docker push ${DOCKER_REGISTRY}:${BUILD_TAG}"
}
}
}
stage('Deploy'){
steps{
echo 'deploy'
sh "docker run -itd -p 8081:8081 ${DOCKER_REGISTRY}:${BUILD_TAG}"
}
}
}
}