forked from yoyowallet/tech-radar
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
93 lines (82 loc) · 2.91 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
env.name = "pup-tech-radar"
env.description = "Project is responsible for updates to our Tech Radar"
env.maintainer = "Carsten Neuendorf <[email protected]>"
env.homepage = "https://github.com/productsupcom/pup-tech-radar"
def slack_channel = "#tech-radar"
env.branch
env.version
env.gitCommitHash
env.gitCommitAuthor
env.gitCommitMessage
env.package_file_name
@Library('jenkins-library@main') _
pipeline {
agent { label 'jenkins-4'}
options {
buildDiscarder(
logRotator(
numToKeepStr: '5',
artifactNumToKeepStr: '5'
)
)
timestamps()
timeout(time: 1, unit: 'HOURS')
disableConcurrentBuilds()
skipDefaultCheckout()
}
environment {
COMPOSE_PROJECT_NAME = "${env.JOB_NAME}_${env.BUILD_ID}"
}
stages {
// Checkout code with tags. The regular scm call does a flat checkout
// and we need the tags to set the version
stage("Checkout") {
steps {
gitCheckout()
}
}
// set version with the following scheme
// tags: version = <tag>
// PR: version = <latest tag>-<PR number>
// branch: version = <latest tag>-<branch name>
stage('Prepare Info') {
steps {
prepareInfo()
}
}
stage ('Publish Techradar') {
when {
buildingTag()
}
steps {
sshagent (credentials: ['jenkins-ssh']) {
sh 'scp -o StrictHostKeyChecking=no -r docs/* [email protected]:/home/radar.productsup.dev/public/'
sh 'ssh [email protected] chown -vvv -R www-data.www-data /home/radar.productsup.dev/public/'
}
}
}
}
// Run post jobs steps
post {
// failure sends a failure slack message if the pipeline exit with a failed state
failure {
script {
if (slack_channel) {
slackSend message: "${env.name} <${RUN_DISPLAY_URL}|failed>.", channel: "${slack_channel}", color: "danger"
}
}
}
// success sends a success slack message if the pipeline exit with a success state
success {
script {
if (slack_channel) {
slackSend message: "*${env.name} <${RUN_DISPLAY_URL}|success>*. \nAll checks passed for *${env.branch}* \nat commit *${env.gitCommitHash}* \nwhen *${env.gitCommitAuthor}* performed \n> ${env.gitCommitMessage}.", channel: "${slack_channel}", color: "good"
}
}
}
// cleanup always run last and will trigger for both success and failure states
cleanup {
cleanWs deleteDirs: true
}
}
}