-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
118 lines (116 loc) · 3.82 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
pipeline {
agent any
stages {
// stage("Test Application"){
// steps {
// nodejs(nodeJSInstallationName: 'nodejs') {
// bat 'npm run test'
// }
// }
// }
// stage("Build Application"){
// steps {
// nodejs(nodeJSInstallationName: 'nodejs') {
// bat 'npm install'
// bat 'npm run build'
// }
// }
// }
// stage("Dockerize Application"){
// steps {
// bat 'docker build . -t lennonjansuy/webapp:dev'
// bat 'docker images'
// }
// }
// stage("Push To DockerHub"){
// steps {
// withCredentials ([
// usernamePassword(credentialsId: 'docker-cred',
// usernameVariable: "USERNAME",
// passwordVariable: "PASSWORD"
// )]) {
// bat "docker login --username $USERNAME --password $PASSWORD"
// bat 'docker push lennonjansuy/webapp:dev'
// }
// }
// }
// stage("Push To Github (Clone build to other repo)"){
// steps {
// withCredentials([gitUsernamePassword(credentialsId: 'gh-cred', gitToolName: 'Default')]) {
// git credentialsId: 'gh-cred', url: 'https://github.com/lenn0n/jenkins-post-build.git'
// bat "echo 'node_modules' > .gitignore"
// bat 'git add .'
// bat 'git commit -m "Commit from Jenkins" || echo "GOT AN ERROR, JUST CONTINUE"'
// bat 'git push -u origin HEAD:master || echo "GOT AN ERROR, JUST CONTINUE"'
// }
// }
// }
stage("Push Build Folder in Linux Machines and Restart"){
steps {
echo 'TBD'
}
}
stage("Send Email Notification"){
steps {
withCredentials([string(credentialsId: 'email-recipient', variable: 'recipient')]) {
emailext (
subject: "Pipeline Email Report - ${BUILD_DISPLAY_NAME}",
body: """
<html>
<head>
<style>
.wrapper {
background-color: rgba(0, 0, 0, 0.1);
padding: 20px;
border-radius: 20px;
}
.title {
display: flex;
gap: 10px;
}
h2 {
padding-left: 10px;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="title">
<img src="https://avatars.githubusercontent.com/u/45531522?v=4" alt="" height="50px" width="50px"/>
<h2>
A change was made to your repository.
</h2>
</div>
<p>This email was automatically generated after the build finished. See the details below.</p>
<table border="0">
<tr><td>Repository: </td><td> ${GIT_URL}</td></tr>
<tr><td>Branch: </td><td> ${GIT_BRANCH}</td></tr>
<tr><td>Commit: </td><td> ${GIT_COMMIT}</td></tr>
<tr><td>Build ID: </td><td> ${env.BUILD_NUMBER}</td></tr>
<tr><td>Job Name: </td><td> ${env.JOB_NAME}</td></tr>
<tr><td>Jenkins URL: </td><td> ${env.JOB_URL}</td></tr>
</table>
</div>
</body>
</html>
""",
to: recipient,
from: '[email protected]',
replyTo: '[email protected]',
mimeType: 'text/html'
)
}
}
}
stage("Kubernetes Deployment Restart"){
steps {
echo 'TBD'
}
}
}
post {
always {
deleteDir()
}
}
}