-
Notifications
You must be signed in to change notification settings - Fork 12
/
Jenkinsfile
35 lines (34 loc) · 999 Bytes
/
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
pipeline {
agent any
stages{
stage('Code'){
steps{
git url: 'https://github.com/<dockerhub-username>/harryporter.git', branch: 'master'
}
}
stage('Build'){
steps{
sh 'docker build . -t harryporter'
sh 'docker image list'
}
}
stage('Login'){
steps{
withCredentials([string(credentialsId: 'DOCKER_HUB_PASSWORD', variable: 'PASSWORD')]) {
sh 'docker login -u <dockerhub-username> -p $PASSWORD'
}
}
}
stage("Push Image to Docker Hub"){
steps{
sh 'docker tag harryporter <dockerhub-username>/harryporter:latest'
sh 'docker push <dockerhub-username>/harryporter:latest'
}
}
stage('Deploy'){
steps{
sh "docker run --name harry -p 8081:80 -d harryporter"
}
}
}
}