-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
56 lines (55 loc) · 1.73 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
def pipelineContext = [:]
pipeline {
agent any
environment {
DOCKER_CREDENTIALS = credentials('docker_login')
}
stages {
stage ('Checkout Git') {
steps {
checkout scm
}
}
stage ('Build Docker image') {
steps {
echo 'Starting to build docker image'
script {
// dockerImage = docker.build("${env.DOCKER_CREDENTIALS_USR}/my-image:${env.BUILD_ID}")
// pipelineContext.dockerImage = dockerImage
try {
sh '''#!/bin/bash
docker build -t httpd:1 -f Dockerfile .
'''
}
catch (exc) {
echo "Something failed..."
throw exc
}
}
}
}
stage('Run') {
steps {
echo "Run docker image"
script {
pipelineContext.dockerContainer = pipelineContext.dockerImage.run()
}
}
}
stage('Verify') {
parallel {
stage('Verify home') {
steps {
echo "demo"
docker_id = sh (
script: 'docker images',
returnStdout: true
)
println docker_id
// sh "docker exec -it my-image:${env.BUILD_ID} /bin/bash -c "ps -ax""
}
}
}
}
}
}