-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
58 lines (46 loc) · 1.31 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
// Set schedule
String cron_string = BRANCH_NAME == "master" ? "@hourly" : ""
// Set target environment
String env_string = BRANCH_NAME == "master" ? "--target prod" :
BRANCH_NAME ==~ /(release|hotfix)(\/)(.*)/ ? "--target test" :
BRANCH_NAME ==~ /(develop|(feature|bugfix)(\/)(.*))/ ? "--target dev" : "--target dev"
pipeline {
agent any
triggers { cron(cron_string) }
stages {
// Debug and compile
stage('Compile') {
steps {
sh "dbt debug ${env_string}"
sh "dbt compile ${env_string}"
}
}
// Run tests
stage('Test') {
steps {
sh "dbt test ${env_string}"
}
}
// Run
stage('Run') {
steps {
sh "dbt run ${env_string}"
}
}
// Generate docs
stage('Docs') {
steps {
sh "dbt docs generate ${env_string}"
archiveArtifacts artifacts: 'target/**/*', fingerprint: true, allowEmptyArchive: true
}
}
} // End of stages
post {
success {
slackSend (color: 'good', message: "SUCCESSFUL: `${env.JOB_NAME}` #${env.BUILD_NUMBER}".replaceAll("%2F", "/"))
}
failure {
slackSend (color: 'danger', message: "FAILED: `${env.JOB_NAME}` #${env.BUILD_NUMBER}".replaceAll("%2F", "/"))
}
}
} // End of pipeline