-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
48 lines (48 loc) · 1.68 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
pipeline {
agent any
options {
buildDiscarder logRotator(artifactDaysToKeepStr: '5', artifactNumToKeepStr: '5', daysToKeepStr: '5', numToKeepStr: '5')
}
triggers {
pollSCM 'H/10 * * * *'
}
environment {
DISCORD_TOKEN = credentials('discord-token')
GIPHY_KEY = credentials('giphy-token')
MONGODB_URL = 'localhost'
DOCKER_HUB_URL = credentials('docker-hub-url')
DOCKER_LOGIN = credentials('docker-login')
}
stages {
stage('Compile test') {
agent {
dockerfile { filename 'Dockerfile.build' }
}
steps {
echo 'Compiling in Python!'
sh 'printf "DISCORD_TOKEN=${DISCORD_TOKEN}\nGIPHY_KEY=${GIPHY_KEY}\nMONGODB_URL=${MONGODB_URL}" >> .env'
sh 'python -m compileall .'
}
}
stage('Build Docker image') {
steps {
echo 'BUILDING!'
sh 'docker build -t ${DOCKER_HUB_URL} .'
}
}
stage('Publish Docker image') {
steps {
sh 'docker login --username=$DOCKER_LOGIN_USR --password=$DOCKER_LOGIN_PSW'
sh 'docker push ${DOCKER_HUB_URL}'
}
}
stage('Deploy') {
steps {
sh 'printf "DISCORD_TOKEN=${DISCORD_TOKEN}\nGIPHY_KEY=${GIPHY_KEY}\nMONGODB_URL=${MONGODB_URL}" >> .env'
sh 'docker-compose -f docker-compose-production.yml pull'
sh 'docker-compose -f docker-compose-production.yml down'
sh 'docker-compose -f docker-compose-production.yml up -d'
}
}
}
}