Permalink
Fetching contributors…
Cannot retrieve contributors at this time
75 lines (64 sloc) 2.76 KB
def notifyBuild(String buildStatus, Exception e) {
buildStatus = buildStatus ?: 'SUCCESSFUL'
// Default values
def colorName = 'RED'
def colorCode = '#FF0000'
def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'"
def summary = """*${buildStatus}*: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':\nMore detail in console output at <${env.BUILD_URL}|${env.BUILD_URL}>"""
def details = """${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':\n
Check console output at ${env.BUILD_URL} """
// Override default values based on build status
if (buildStatus == 'STARTED') {
color = 'YELLOW'
colorCode = '#FFFF00'
} else if (buildStatus == 'SUCCESSFUL') {
color = 'GREEN'
colorCode = '#00FF00'
} else {
color = 'RED'
colorCode = '#FF0000'
details +="<p>Error message ${e.message}, stacktrace: ${e}</p>"
summary +="\nError message ${e.message}, stacktrace: ${e}"
}
// Send notifications
slackSend channel: "#forms-api", baseUrl: 'https://hooks.slack.com/services/', tokenCredentialId: 'slackmessagetpt2', color: colorCode, message: summary
emailext(
subject: subject,
body: details,
attachLog: true,
recipientProviders: [[$class: 'DevelopersRecipientProvider']],
to: "Alex.Kuznetsov@osi.ca.gov, leonid.marushevskiy@osi.gov.ca"
)
}
node ('preint') {
def serverArti = Artifactory.newServer url: 'https://jcenter.bintray.com'
def rtGradle = Artifactory.newGradleBuild()
properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '5')),
[$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false],
parameters([
string(defaultValue: 'development', description: '', name: 'branch'),
string(defaultValue: 'https://forms-api.preint.cwds.io/', description: '', name: 'APP_URL')]),pipelineTriggers([])])
def errorcode = null;
def buildInfo = '';
try {
stage('Preparation') {
cleanWs()
git branch: '$branch', credentialsId: '433ac100-b3c2-4519-b4d6-207c029a103b', url: 'git@github.com:ca-cwds/forms-api.git'
rtGradle.tool = "Gradle_3.5.1"
rtGradle.resolver server: serverArti
rtGradle.useWrapper = true
}
stage('Run tests'){
writeFile file: "gradle.properties", text: "api.url=${APP_URL}"
buildInfo = rtGradle.run buildFile: 'build.gradle', tasks: 'integrationTest'
}
} catch (Exception e) {
errorcode = e
currentBuild.result = "FAIL"
notifyBuild(currentBuild.result,errorcode)
throw e;
}finally {
publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true, reportDir: 'build/reports/tests/integrationTest', reportFiles: 'index.html', reportName: 'Integration Test Report', reportTitles: ''])
cleanWs()
}
}