-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
29 lines (24 loc) · 888 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
node {
def app
stage('Clone repository') {
checkout scm
}
stage('Build Docker Image') {
//path to DockerHub repo:
app = docker.build("mb2love/app")
//sh 'docker build -t mb2love/docker:latest'
}
stage('Test image') {
app.inside {
sh 'echo "Tests passed"'
}
}
stage('Push Docker Image'){
// create secrets DOCKER_HUB_USER and DOCKER_HUB_PASSWORD in GitHub
withCredentials([usernamePassword(credentialsId: 'dockerhub_id', passwordVariable: 'DOCKER_HUB_PASSWORD', usernameVariable: 'DOCKER_HUB_USER')]) {
sh 'docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASSWORD'
}
//sh "docker push mb2love/docker:latest"
app.push("${env.BUILD_NUMBER}")
}
}