Jenkinsfile: switch to declarative pipeline

coolant-mod
krzys-h 2018-05-16 15:23:41 +02:00
parent 3cbab7144e
commit 079d5fc412
1 changed files with 30 additions and 32 deletions

62
Jenkinsfile vendored
View File

@ -1,39 +1,37 @@
#!/usr/bin/env groovy
if (env.BRANCH_NAME.startsWith('PR-')) {
properties([[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', artifactNumToKeepStr: '1']]])
} else {
properties([[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', artifactDaysToKeepStr: '30', artifactNumToKeepStr: '5']]])
}
if (env.CHANGE_TARGET == 'master') {
error("This pull request targets the wrong branch. Please reopen the pull request targetting the dev branch.")
}
node('master') {
stage('Pull changes') {
checkout scm
pipeline {
agent { label 'colobot-build' }
options {
buildDiscarder(logRotator(artifactDaysToKeepStr: '30', artifactNumToKeepStr: '5'))
}
stages {
stage('Check pull request target') {
when { changeRequest() }
steps {
script {
if (env.CHANGE_TARGET == 'master') {
throw "This pull request targets the wrong branch. Please reopen the pull request targetting the dev branch."
}
}
}
}
stage('Build data') {
steps {
sh '''
cmake -DCMAKE_INSTALL_PREFIX=/install -DCOLOBOT_INSTALL_DATA_DIR=/install/data ..
make
rm -rf install
DESTDIR=. make install
'''
}
}
stage('Build data') {
sh 'mkdir -p build'
dir('build') {
sh '''
cmake -DCMAKE_INSTALL_PREFIX=/install -DCOLOBOT_INSTALL_DATA_DIR=/install/data ..
make
rm -rf install
DESTDIR=. make install
'''
stage('Archive data') {
steps {
sh 'rm -f data.zip'
zip zipFile: 'data.zip', archive: true, dir: 'build/install'
}
}
}
stage('Archive data') {
sh 'rm -f data.zip'
zip zipFile: 'data.zip', archive: true, dir: 'build/install'
}
// Clean workspace after building pull requests
// to save disk space on the Jenkins host
if (env.BRANCH_NAME.startsWith('PR-')) {
cleanWs()
}
}