-
Notifications
You must be signed in to change notification settings - Fork 7
/
Jenkinsfile_Test
48 lines (48 loc) · 4.94 KB
/
Jenkinsfile_Test
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
pipeline{
agent{
label 'agent2'
}
stages{
stage('Test'){
steps{
echo "Welcome to Volt MX Doc Build"
}
}
}
post {
success{
echo "Build result is ${currentBuild.currentResult} !"
}
failure{
echo "Build result is ${currentBuild.currentResult}. Please check the console logs to re-run the build"
}
always{
echo " ----------- Build Details ----------- "
echo "Build Number: ${env.BUILD_NUMBER}"
echo "Build Result: ${currentBuild.currentResult}"
script{
def author_name = sh script: "git show -s --pretty=\"%an\" ${GIT_COMMIT}", returnStdout: true
def author_email_id = sh script: "git show -s --pretty=\"%ae\" ${GIT_COMMIT}", returnStdout: true
def commit_hash = sh script: "git show -s --pretty=\"%h\" ${GIT_COMMIT}", returnStdout: true
def commit_date = sh script: "git show -s --pretty=\"%ar\" ${GIT_COMMIT}", returnStdout: true
def commit_message = sh script: "git show -s --pretty=\"%s\" ${GIT_COMMIT}", returnStdout: true
def commit_message2 = sh script: "git show -s --pretty=\"%b\" ${GIT_COMMIT}", returnStdout: true
println("${author_email_id}")
sh "echo 'Last 5 commit/change history'"
//def n1 = sh script: "git show -s --pretty=format:'Author_Name: %an, Author_Email_Id: %ae, Committed_Time: %ar, Changes: %s, Change_Description: %b, Commit_Hash_Id: %h .' ${GIT_COMMIT} -5 ", returnStdout: true
def n1 = sh script: "git show -s --pretty=format:'Author_Name: %an, Author_Email_Id: %ae, Committed_Time: %ar, Changes: %s, Commit_Hash_Id: %h.' ${GIT_COMMIT} -5 ", returnStdout: true
println("${n1}")
println("Datatype of n1 is :")
println(n1.getClass().getName())
def (h1,h2,h3,h4,h5) = "${n1}".tokenize('\n')
println("Commit History 1: ${h1}")
println("Commit History 2: ${h2}")
println("Commit History 3: ${h3}")
println("Commit History 4: ${h4}")
println("Commit History 5: ${h5}")
//emailext attachLog: true, compressLog:true, body:"<p>***********************************************************************************</p><h2>${env.PROJECT_NAME} - Build Status: </h2><h3><u>Present Build Updates:</u></h3><table><tr><th>Build Number: </th><td><code>${env.BUILD_NUMBER}</code></td></tr><tr><th>Build Status: </th><td><code>${currentBuild.currentResult}</code></td></tr><tr><th>Build Duration: </th><td><code>${currentBuild.durationString}</code></td></tr></table><h3><u>Last 5 ChangeSets/History:</u></h3><table><tr><th>Commit History-1:</th><td><code>${h1}</code></td></tr><tr><th>Commit History-2:</th><td><code>${h2}</code></td></tr><tr><th>Commit History-3:</th><td><code>${h3}</code></td></tr><tr><th>Commit History-4:</th><td><code>${h4}</code></td></tr><tr><th>Commit History-5:</th><td><code>${h5}</code></td></tr></table><p>Please check the attached build logs and output to view the results in detail.</p><p>Verify your changes published externally from this base URL: <br>https://opensource.hcltechsw.com/volt-mx-docs/docs/documentation/ .</p><p>***********************************************************************************</p>", replyTo: '[email protected]', subject: "${env.PROJECT_NAME} - Build # ${env.BUILD_NUMBER} - ${currentBuild.currentResult}!", to: '[email protected], [email protected], [email protected], [email protected], [email protected], [email protected]'
emailext attachLog: true, compressLog:true, body:"<p>***********************************************************************************</p><h2>${env.PROJECT_NAME} - Build Status: </h2><h3><u>Present Build Updates:</u></h3><table><tr><th>Build Number: </th><td><code>${env.BUILD_NUMBER}</code></td></tr><tr><th>Build Status: </th><td><code>${currentBuild.currentResult}</code></td></tr><tr><th>Build Duration: </th><td><code>${currentBuild.durationString}</code></td></tr></table><h3><u>Last 5 ChangeSets/History:</u></h3><table><tr><th>Commit History-1:</th><td><code>${h1}</code></td></tr><tr><th>Commit History-2:</th><td><code>${h2}</code></td></tr><tr><th>Commit History-3:</th><td><code>${h3}</code></td></tr><tr><th>Commit History-4:</th><td><code>${h4}</code></td></tr><tr><th>Commit History-5:</th><td><code>${h5}</code></td></tr></table><p>Please check the attached build logs and output to view the results in detail.</p><p>Verify your changes published externally from this base URL: <br>https://opensource.hcltechsw.com/volt-mx-docs/docs/documentation/ .</p><p>***********************************************************************************</p>", replyTo: '[email protected]', subject: "${env.PROJECT_NAME} - Build # ${env.BUILD_NUMBER} - ${currentBuild.currentResult}!", to: '[email protected]'
}
}
}
}