From bdc3f51320908182ceaa75e3e99589fc7317bf58 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 1 May 2017 21:20:42 +0200 Subject: [PATCH] Revert "Use declarative pipeline" This reverts commit e00164e3478bdfcc6621a7d8a0f488873605d93f. --- Jenkinsfile | 165 ++++++++++++++++++++++++---------------------------- 1 file changed, 75 insertions(+), 90 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 113c0a9..2090114 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,102 +1,87 @@ -pipeline { - // parameters { - // string ( - // defaultValue: '1.0', - // description: 'Current version number', - // name : 'VERSION') - // text ( - // defaultValue: '', - // description: 'A list of changes', - // name : 'CHANGES') - // booleanParam ( - // defaultValue: false, - // description: 'If build should be marked as pre-release', - // name : 'PRERELEASE') - // string ( - // defaultValue: '1.0', - // description: 'GitHub username or organization', - // name : 'GITHUB_USER') - // string ( - // defaultValue: '1.0', - // description: 'GitHub repository', - // name : 'GITHUB_REPO') - // } +/** +properties([ + parameters([ + string(defaultValue: '1.0', description: 'Current version number', name: 'VERSION'), + text(defaultValue: '', description: 'A list of changes', name: 'CHANGES'), + booleanParam(defaultValue: false, description: 'If build should be marked as pre-release', name: 'PRERELEASE'), + string(defaultValue: 'ayufan-pine64', description: 'GitHub username or organization', name: 'GITHUB_USER'), + string(defaultValue: 'build-pine64-image', description: 'GitHub repository', name: 'GITHUB_REPO'), + ]) +]) +*/ - agent { - dockerfile { - dir 'build-environment' - label 'docker && linux-build' - args '--privileged -u 0:0' - } - } - environment { - USE_CCACHE = 'true' - RELEASE_NAME = "$RELEASE_NAME" - RELEASE = "$BUILD_NUMBER" - CCACHE_DIR = "$WORKSPACE/ccache" - PRERELEASE = "$PRERELEASE" - GITHUB_USER = "$GITHUB_USER" - GITHUB_REPO = "$GITHUB_REPO" - } - options { - timestamps() - } +node('docker && linux-build') { + timestamps { + wrap([$class: 'AnsiColorBuildWrapper', colorMapName: 'xterm']) { + stage "Environment" + checkout scm - stages { - stage('Prepare') { - steps { - sh 'ccache -M 0 -F 0' - sh 'git clean -ffdx -e ccache' - } - } - - stage('Build') { - steps { - sh 'make' - } - } + def environment = docker.build('build-environment:build-pine64-image', 'build-environment') - stage('Release') { - steps { - sh '''#!/bin/bash - set -xe - shopt -s nullglob + environment.inside("--privileged -u 0:0") { + withEnv([ + "USE_CCACHE=true", + "RELEASE_NAME=$VERSION", + "RELEASE=$BUILD_NUMBER" + ]) { + stage 'Prepare' + sh '''#!/bin/bash + set +xe + export CCACHE_DIR=$WORKSPACE/ccache + ccache -M 0 -F 0 + git clean -ffdx -e ccache + ''' - github-release release \ - --tag "${VERSION}" \ - --name "$VERSION: $BUILD_TAG" \ - --description "${CHANGES}\n\n${BUILD_URL}" \ - --draft + stage 'Build' + sh '''#!/bin/bash + set +xe + export CCACHE_DIR=$WORKSPACE/ccache + make + ''' + } + + withEnv([ + "VERSION=$VERSION", + "CHANGES=$CHANGES", + "PRERELEASE=$PRERELEASE", + "GITHUB_USER=$GITHUB_USER", + "GITHUB_REPO=$GITHUB_REPO" + ]) { + stage 'Release' + sh '''#!/bin/bash + set -xe + shopt -s nullglob - for file in *.xz *.deb; do - github-release upload \ + github-release release \ --tag "${VERSION}" \ - --name "$(basename "$file")" \ - --file "$file" & - done + --name "$VERSION: $BUILD_TAG" \ + --description "${CHANGES}\n\n${BUILD_URL}" \ + --draft - wait + for file in *.xz *.deb; do + github-release upload \ + --tag "${VERSION}" \ + --name "$(basename "$file")" \ + --file "$file" & + done - if [[ "$PRERELEASE" == "true" ]]; then - github-release edit \ - --tag "${VERSION}" \ - --name "$VERSION: $BUILD_TAG" \ - --description "${CHANGES}\n\n${BUILD_URL}" \ - --pre-release - else - github-release edit \ - --tag "${VERSION}" \ - --name "$VERSION: $BUILD_TAG" \ - --description "${CHANGES}\n\n${BUILD_URL}" - fi - ''' - } - } - } + wait - post { - always { - sh 'git clean -ffdx -e ccache' + if [[ "$PRERELEASE" == "true" ]]; then + github-release edit \ + --tag "${VERSION}" \ + --name "$VERSION: $BUILD_TAG" \ + --description "${CHANGES}\n\n${BUILD_URL}" \ + --pre-release + else + github-release edit \ + --tag "${VERSION}" \ + --name "$VERSION: $BUILD_TAG" \ + --description "${CHANGES}\n\n${BUILD_URL}" + fi + ''' + } + } } } }