-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile.DEV
62 lines (62 loc) · 1.81 KB
/
Jenkinsfile.DEV
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
57
58
59
60
61
62
pipeline {
agent any
triggers {
pollSCM('H/2 * * * 1-5')
}
options {
disableConcurrentBuilds()
timestamps()
}
environment {
registry = "northbear/server-image"
registryCredential = 'cb-access-dockerhub'
serverImageName = 'northbear/morse-responder'
serverContainerName = 'morse-responder'
serverImage = ''
serverHost = 'ec2-54-73-110-196.eu-west-1.compute.amazonaws.com'
serverPortExposed = '4000'
}
stages {
stage("Prepare Workspace") {
steps {
echo 'Prepare'
git url: 'https://github.com/northbear/cb-ms-morse.git', poll: true
}
}
stage("Build Image") {
steps {
echo "Build Image ${serverImageName}"
script {
serverImage = docker.build(serverImageName, '--rm -f Dockerfile.morse-responder .')
}
}
}
stage("Start and Test Server Container") {
steps {
echo 'Test'
script {
serverImage.withRun("--name ${serverContainerName} -p ${serverPortExposed}:5000 --env APP_PORT=5000") {
sh "curl http://${serverHost}:${serverPortExposed}/"
}
}
}
}
stage("Publish Image") {
steps {
echo 'Push image to Repo'
script {
docker.withRegistry( '', registryCredential ) {
serverImage.push("${env.BUILD_ID}")
}
}
}
}
stage("Clean Up") {
steps {
echo 'Remove containers'
// sh "docker stop ${serverContainerName} "
// sh 'docker rmi ${dockerImageName}'
}
}
}
}