Add timeout for Jenkinsfile

This commit is contained in:
Lipu Fei 2018-01-03 11:58:14 +01:00
parent f6168c07f0
commit 6997c2d2dc

70
Jenkinsfile vendored
View file

@ -1,45 +1,47 @@
parallel_nodes(['linux && cura', 'windows && cura']) { timeout(time: 2, unit: "HOURS") {
// Prepare building parallel_nodes(['linux && cura', 'windows && cura']) {
stage('Prepare') { // Prepare building
// Ensure we start with a clean build directory. stage('Prepare') {
step([$class: 'WsCleanup']) // Ensure we start with a clean build directory.
step([$class: 'WsCleanup'])
// Checkout whatever sources are linked to this pipeline. // Checkout whatever sources are linked to this pipeline.
checkout scm checkout scm
} }
// If any error occurs during building, we want to catch it and continue with the "finale" stage. // If any error occurs during building, we want to catch it and continue with the "finale" stage.
catchError { catchError {
// Building and testing should happen in a subdirectory. // Building and testing should happen in a subdirectory.
dir('build') { dir('build') {
// Perform the "build". Since Uranium is Python code, this basically only ensures CMake is setup. // Perform the "build". Since Uranium is Python code, this basically only ensures CMake is setup.
stage('Build') { stage('Build') {
def branch = env.BRANCH_NAME def branch = env.BRANCH_NAME
if(!fileExists("${env.CURA_ENVIRONMENT_PATH}/${branch}")) { if(!fileExists("${env.CURA_ENVIRONMENT_PATH}/${branch}")) {
branch = "master" branch = "master"
}
// Ensure CMake is setup. Note that since this is Python code we do not really "build" it.
def uranium_dir = get_workspace_dir("Ultimaker/Uranium/${branch}")
cmake("..", "-DCMAKE_PREFIX_PATH=\"${env.CURA_ENVIRONMENT_PATH}/${branch}\" -DCMAKE_BUILD_TYPE=Release -DURANIUM_DIR=\"${uranium_dir}\"")
} }
// Ensure CMake is setup. Note that since this is Python code we do not really "build" it. // Try and run the unit tests. If this stage fails, we consider the build to be "unstable".
def uranium_dir = get_workspace_dir("Ultimaker/Uranium/${branch}") stage('Unit Test') {
cmake("..", "-DCMAKE_PREFIX_PATH=\"${env.CURA_ENVIRONMENT_PATH}/${branch}\" -DCMAKE_BUILD_TYPE=Release -DURANIUM_DIR=\"${uranium_dir}\"") try {
} make('test')
} catch(e) {
// Try and run the unit tests. If this stage fails, we consider the build to be "unstable". currentBuild.result = "UNSTABLE"
stage('Unit Test') { }
try {
make('test')
} catch(e) {
currentBuild.result = "UNSTABLE"
} }
} }
} }
}
// Perform any post-build actions like notification and publishing of unit tests. // Perform any post-build actions like notification and publishing of unit tests.
stage('Finalize') { stage('Finalize') {
// Publish the test results to Jenkins. // Publish the test results to Jenkins.
junit allowEmptyResults: true, testResults: 'build/junit*.xml' junit allowEmptyResults: true, testResults: 'build/junit*.xml'
notify_build_result(env.CURA_EMAIL_RECIPIENTS, '#cura-dev', ['master', '2.']) notify_build_result(env.CURA_EMAIL_RECIPIENTS, '#cura-dev', ['master', '2.'])
}
} }
} }