This repository was archived by the owner on Nov 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
51 lines (50 loc) · 2.02 KB
/
Jenkinsfile
File metadata and controls
51 lines (50 loc) · 2.02 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
pipeline {
agent {
docker {
image 'boisvert/python-build'
args '-v /var/run/docker.sock:/var/run/docker.sock -u root'
}
}
environment {
DOCKER_TOKEN = credentials('alphagamedev-docker-token')
WEBUI_VERSION = sh(returnStdout: true, script: "cat webui.json | jq '.VERSION' -cMr").trim()
// MySQL stuff
MYSQL_HOST = "hubby.internal"
MYSQL_DATABASE = "alphagamebot"
MYSQL_USER = "alphagamebot"
MYSQL_PASSWORD = credentials('alphagamebot-mysql-password')
}
stages {
stage('build') {
steps {
sh 'docker build -t alphagamedev/alphagamebot:webui-$WEBUI_VERSION .'
}
}
stage('push') {
when {
// We ONLY want to push Docker images when we are in the master branch!
branch 'master'
}
steps {
echo "Pushing image to Docker Hub"
sh 'echo $DOCKER_TOKEN | docker login -u alphagamedev --password-stdin'
sh 'docker tag alphagamedev/alphagamebot:webui-$WEBUI_VERSION alphagamedev/alphagamebot:webui-latest'
sh 'docker push alphagamedev/alphagamebot:webui-$WEBUI_VERSION' // push tag latest version
sh 'docker push alphagamedev/alphagamebot:webui-latest' // push tag latest
sh 'docker logout'
}
}
stage('deploy') {
steps {
// conditionally deploy
sh "docker container stop alphagamebot-webui || true"
sh "docker container rm alphagamebot-webui || true"
sh "docker run -d \
--name alphagamebot-webui -e BUILD_NUMBER -p 5600:5000 \
-e MYSQL_HOST -e MYSQL_DATABASE -e MYSQL_USER -e MYSQL_PASSWORD \
--restart=always \
alphagamedev/alphagamebot:webui-$WEBUI_VERSION"
}
}
} // stages
}