-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
38 lines (37 loc) · 1.1 KB
/
Copy pathJenkinsfile
File metadata and controls
38 lines (37 loc) · 1.1 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
pipeline {
agent any
environment{
DOCKERHUB_CREDS = credentials('dockerhub')
}
stages {
stage('Clone Repo') {
steps {
checkout scm
sh 'ls *'
}
}
stage('Build Image') {
steps {
//sh 'docker build -t joemile/jenkinsdocker ./pushdockerimage/' (this will use the tag latest)
sh 'docker build -t joemile/jenkinsdocker:$BUILD_NUMBER ./pushdockerimage/'
}
}
stage('Docker Login') {
steps {
//sh 'docker login -u $DOCKERHUB_CREDS_USR -p $DOCKERHUB_CREDS_PSW' (this will leave the password visible)
sh 'echo $DOCKERHUB_CREDS_PSW | docker login -u $DOCKERHUB_CREDS_USR --password-stdin'
}
}
stage('Docker Push') {
steps {
//sh 'docker push joemile/jenkinsdocker' (this will use the tag latest)
sh 'docker push joemile/jenkinsdocker:$BUILD_NUMBER'
}
}
}
post {
always {
sh 'docker logout'
}
}
}