-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
67 lines (66 loc) · 1.84 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
66
67
def deployCompose (command) {
yarn "docker:prod --project-name Botler --env-file \$DEPLOY_CONFIG $command"
}
pipeline {
agent any
environment {
DISCORD_WEBHOOK = credentials('discord-webhook')
}
options {
skipStagesAfterUnstable()
}
stages {
stage('Install Dependencies') {
steps {
yarn 'install --frozen-lockfile'
}
}
stage('Build') {
steps {
yarn 'prisma generate'
yarn 'build:prod'
}
}
stage('Check Style') {
parallel {
stage('Check Linting') {
steps {
yarn 'lint:ci'
}
post {
always {
recordIssues enabledForFailure: true, aggregatingResults: true, tool: checkStyle(pattern: 'eslint.xml')
}
}
}
stage('Check Formatting') {
steps {
yarn 'format:check'
}
}
}
}
stage('Deploy') {
when { branch 'master' }
environment {
DEPLOY_CONFIG = credentials('deploy-config')
}
steps {
script {
deployCompose('build')
if (0 != sh(script: "git diff --exit-code $GIT_PREVIOUS_COMMIT $GIT_COMMIT migrations", returnStatus: true)) {
deployCompose('stop bot')
deployCompose('run --rm bot node_modules/.bin/prisma migrate deploy')
}
deployCompose('up --detach')
}
discordSend webhookURL: DISCORD_WEBHOOK, description: "**[$JOB_NAME #$BUILD_NUMBER](${JENKINS_URL}blue/organizations/jenkins/Botler/detail/master/$BUILD_NUMBER/pipeline) deployed a new version.**"
}
}
}
post {
unsuccessful {
discordSend webhookURL: DISCORD_WEBHOOK, description: "**[$JOB_NAME #$BUILD_NUMBER](${JENKINS_URL}blue/organizations/jenkins/Botler/detail/master/$BUILD_NUMBER/pipeline) was unsuccessful.**"
}
}
}