forked from Elad0109/simple-webapp-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
65 lines (63 loc) · 1.72 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
57
58
59
60
61
62
63
64
65
@Library('my-library@main') _
pipeline {
agent { label "windows" }
stages {
stage('Clean Workspace') {
steps {
script {
KILL = "false"
REMOVE = "false"
}
cleanWs()
}
}
stage('Git Pull') {
steps {
git 'https://github.com/ciantfv456/simple-webapp-nodejs.git'
}
}
stage('Say My Name') {
steps {
script {
ciConfig = readYaml(text: libraryResource('environments.yml'))
}
echo "${name}"
echo "${ciConfig.buildImage}"
}
}
stage('Build Docker') {
steps {
dockerBuild(context: '.', tag: 'latest')
}
}
stage('Run Docker') {
steps {
script {
REMOVE = "true"
}
bat "docker run -itd -p 3000:3000 --name server server:latest"
script {
KILL = "true"
}
}
}
stage('run tests') {
steps {
bat "curl http://localhost:3000/"
bat "python test.py"
}
}
}
post {
always {
script {
if (KILL == "true") {
bat "docker kill server"
}
if (REMOVE == "true") {
bat "docker rm server"
}
}
}
}
}