Add failed build action
This commit is contained in:
parent
3f5001a7c2
commit
607232dd23
1 changed files with 79 additions and 30 deletions
|
|
@ -1,35 +1,45 @@
|
|||
/* Example post build info
|
||||
{
|
||||
"Build outcomes": {
|
||||
"Success": {
|
||||
"Actions": {
|
||||
"Deploy doxygen": {
|
||||
"Description": "Can be empty - Name of doxygen deploy job to run if this build is successful",
|
||||
"Job": "HMB_FD_HV_0.9.6/HMB_FD_HV_0.9.6_sg1024_doxygen_deploy"
|
||||
"Build outcomes": {
|
||||
"Success": {
|
||||
"Actions": {
|
||||
"Deploy doxygen": {
|
||||
"Description": "Can be empty - Name of doxygen deploy job to run if this build is successful",
|
||||
"Job": "HMB_FD_HV_0.9.6/HMB_FD_HV_0.9.6_sg1024_doxygen_deploy"
|
||||
},
|
||||
"Static analysis": {
|
||||
"Description": "Can be empty - Static analysis job to run when this build is successful",
|
||||
"Job": ""
|
||||
},
|
||||
"Unit test": {
|
||||
"Description": "Can be empty - Unit test job to run when this build is successful",
|
||||
"Job": ""
|
||||
},
|
||||
"Regression test": {
|
||||
"Description": "Can be empty - Regression test job to run when this build is successful",
|
||||
"Job": "HMB_FD_HV_0.9.6/HMB_FD_HV_0.9.6_sg1024_run_tests"
|
||||
},
|
||||
"Update differences": {
|
||||
"Description": "Can be empty - Update differences job to run when this build is successful",
|
||||
"Job": "HMB_FD_HV_diff_releases"
|
||||
},
|
||||
"Release to git": {
|
||||
"Description": "Can be empty - Name of release to git job to run if this build is successful",
|
||||
"Job": "HMB_FD_HV_release_to_git"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Static analysis": {
|
||||
"Description": "Can be empty - Static analysis job to run when this build is successful",
|
||||
"Job": ""
|
||||
},
|
||||
"Unit test": {
|
||||
"Description": "Can be empty - Unit test job to run when this build is successful",
|
||||
"Job": ""
|
||||
},
|
||||
"Regression test": {
|
||||
"Description": "Can be empty - Regression test job to run when this build is successful",
|
||||
"Job": "HMB_FD_HV_0.9.6/HMB_FD_HV_0.9.6_sg1024_run_tests"
|
||||
},
|
||||
"Update differences": {
|
||||
"Description": "Can be empty - Update differences job to run when this build is successful",
|
||||
"Job": "HMB_FD_HV_diff_releases"
|
||||
},
|
||||
"Release to git": {
|
||||
"Description": "Can be empty - Name of release to git job to run if this build is successful",
|
||||
"Job": "HMB_FD_HV_release_to_git"
|
||||
"Failed": {
|
||||
"Actions": {
|
||||
"Email": {
|
||||
"Description": "Can be empty - Name of release to git job to run if this build is successful",
|
||||
"To": [
|
||||
"dan.hawkins@globalinkjetsystems.com"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
|
@ -88,12 +98,18 @@ def deployjob(String buildselector, postbuildactions, String action, String alte
|
|||
}
|
||||
}
|
||||
|
||||
def readPostBuildInfo() {
|
||||
def postbuildinfo = readJSON(text: POST_BUILD_INFO)
|
||||
def postbuildjsontext = writeJSON(returnText: true, json: postbuildinfo, pretty: 1)
|
||||
echo "Post build info:\n${postbuildjsontext}"
|
||||
|
||||
return postbuildinfo
|
||||
}
|
||||
|
||||
def performSuccessfulBuildActions() {
|
||||
def postbuildactions
|
||||
if (params.POST_BUILD_INFO != null) {
|
||||
def postbuildinfo = readJSON(text: POST_BUILD_INFO)
|
||||
def postbuildjsontext = writeJSON(returnText: true, json: postbuildinfo, pretty: 1)
|
||||
echo "Post build info:\n${postbuildjsontext}"
|
||||
def postbuildinfo = readPostBuildInfo()
|
||||
try {
|
||||
postbuildactions = postbuildinfo['Build outcomes']['Success']['Actions']
|
||||
postbuildinfoavailable = true
|
||||
|
|
@ -112,4 +128,37 @@ def performSuccessfulBuildActions() {
|
|||
deployjob(buildselector, postbuildactions, 'Release to git', 'RELEASE_TO_GIT_JOB')
|
||||
}
|
||||
|
||||
def sendemails(emailtolist) {
|
||||
def emailbody = """
|
||||
Failed build: ${JOBNAME} ${BUILD_DISPLAY_NAME} : ${BUILD_URL}
|
||||
"""
|
||||
|
||||
for(emailto in emailtolist) {
|
||||
mail(
|
||||
subject: "Failed build: ${JOBNAME} ${BUILD_DISPLAY_NAME}",
|
||||
body: emailbody,
|
||||
to: emailto
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
def performFailedBuildActions() {
|
||||
def postbuildactions = null
|
||||
if (params.POST_BUILD_INFO != null) {
|
||||
def postbuildinfo = readPostBuildInfo()
|
||||
try {
|
||||
postbuildactions = postbuildinfo['Build outcomes']['Failed']['Actions']
|
||||
} catch(Exception ex) {
|
||||
echo "Post build info did not contain: Build outcomes/Failed/Actions"
|
||||
postbuildactions = null
|
||||
}
|
||||
}
|
||||
if (postbuildactions) {
|
||||
def emailtolist = postbuildactions['Email']['To']
|
||||
if (emailtolist) {
|
||||
sendemails(emailtolist)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue