forked from Keyshelldevops/keyshell
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathJenkinsfile.slack
More file actions
85 lines (82 loc) · 2.85 KB
/
Jenkinsfile.slack
File metadata and controls
85 lines (82 loc) · 2.85 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
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
pipeline {
agent any
tools {
nodejs 'v20.9.0'
}
options {
retry(2)
timestamps()
}
stages {
stage('SCM') {
steps {
git branch: 'master', url: 'https://github.com/ajilraju/keyshell.git'
}
}
stage('Install Deps') {
steps {
sh 'npm install'
}
post {
success {
slackSend color: "good", message: "Project: ${JOB_NAME} Build #${env.BUILD_NUMBER}, URL ${env.BUILD_URL} - Installed dependency - npm install."
}
failure {
slackSend color: "danger", message: "Project: ${JOB_NAME} Build #${env.BUILD_NUMBER}, URL ${env.BUILD_URL} - Failed to install dependency - npm install."
}
}
}
stage('Build') {
steps {
sh 'ng build'
}
post {
success {
fingerprint 'dist/keyshell'
slackSend color: "good", message: "Project: ${JOB_NAME} Build #${env.BUILD_NUMBER}, URL ${env.BUILD_URL} - Build succeeded."
}
failure {
slackSend color: "danger", message: "Project: ${JOB_NAME} Build #${env.BUILD_NUMBER}, URL ${env.BUILD_URL} - Build failed."
}
}
}
stage('Deploy to Apache2') {
steps {
sh 'cp -rv dist/keyshell/* /var/www/html/'
}
post {
success {
script {
def output = sh(script: 'ls -la /var/www/html', returnStdout: true).trim()
slackSend(blocks: [
[
"type": "section",
"text": [
"type": "mrkdwn",
"text": "*Deployed files meta data*\n\n${output}"
]
]
])
}
}
failure {
slackSend color: "danger", message: "Project: ${JOB_NAME} Build #${env.BUILD_NUMBER}, URL ${env.BUILD_URL} - Deployment failed."
}
}
}
stage('Archive Artifacts') {
steps {
sh 'zip -r archive.zip dist/keyshell/*'
archiveArtifacts artifacts: 'archive.zip', fingerprint: true, onlyIfSuccessful: true
}
}
}
post {
success {
slackSend color: "good", message: "The Build #${env.BUILD_NUMBER} was successful: ${env.BUILD_URL}"
}
failure {
slackSend color: "danger", message: "The Build #${env.BUILD_NUMBER} failed: ${env.BUILD_URL}"
}
}
}