From 404e5effb15b08de820d2ac1a242abf2bdaec06c Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Sun, 23 Jul 2017 13:24:27 +1000 Subject: [PATCH] Updated depreciated stage declarations Jenkins depreciated the form of the stage step that did not accept a block argument. https://jenkins.io/doc/pipeline/steps/pipeline-stage-step/#pipeline-stage-step --- Jenkinsfile | 228 +++++++++++++++++++++++++++------------------------- 1 file changed, 118 insertions(+), 110 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c140de2..34873bd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,116 +13,124 @@ properties([ node('docker && linux-build') { timestamps { wrap([$class: 'AnsiColorBuildWrapper', colorMapName: 'xterm']) { - stage "Environment" - checkout scm - - def environment = docker.build('build-environment:build-rock64-image', 'environment') - - 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 - ''' - - stage 'Sources' - sh '''#!/bin/bash - set -xe - - export HOME=$WORKSPACE - export USER=jenkins - - repo init -u https://github.com/ayufan-rock64/linux-manifests -b default --depth=1 - - repo sync -j 20 -c --force-sync - ''' - - stage 'U-boot' - sh '''#!/bin/bash - set +xe - export CCACHE_DIR=$WORKSPACE/ccache - make u-boot - ''' - - stage 'Kernel' - sh '''#!/bin/bash - set +xe - export CCACHE_DIR=$WORKSPACE/ccache - make kernel - ''' - - stage 'Images' - sh '''#!/bin/bash - set +xe - export CCACHE_DIR=$WORKSPACE/ccache - make -j$(nproc) - ''' - } - - withEnv([ - "VERSION=$VERSION", - "CHANGES=$CHANGES", - "PRERELEASE=$PRERELEASE", - "GITHUB_USER=$GITHUB_USER", - "GITHUB_REPO=$GITHUB_REPO" - ]) { - stage 'Freeze' - sh '''#!/bin/bash - # use -ve, otherwise we could leak GITHUB_TOKEN... - set -ve - shopt -s nullglob - - export HOME=$WORKSPACE - export USER=jenkins - - repo manifest -r -o manifest.xml - ''' - - stage 'Release' - sh '''#!/bin/bash - set -xe - shopt -s nullglob - - github-release release \ - --tag "${VERSION}" \ - --name "$VERSION: $BUILD_TAG" \ - --description "${CHANGES}\n\n${BUILD_URL}" \ - --draft - - github-release upload \ - --tag "${VERSION}" \ - --name "manifest.xml" \ - --file "manifest.xml" - - for file in *.xz *.deb; do - github-release upload \ - --tag "${VERSION}" \ - --name "$(basename "$file")" \ - --file "$file" & - done - - wait - - 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 - ''' + stage('Environment') { + checkout scm + + def environment = docker.build('build-environment:build-rock64-image', 'environment') + + 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 + ''' + } + + stage 'Sources' { + sh '''#!/bin/bash + set -xe + + export HOME=$WORKSPACE + export USER=jenkins + + repo init -u https://github.com/ayufan-rock64/linux-manifests -b default --depth=1 + + repo sync -j 20 -c --force-sync + ''' + } + + stage('U-boot') { + sh '''#!/bin/bash + set +xe + export CCACHE_DIR=$WORKSPACE/ccache + make u-boot + ''' + } + + stage('Kernel') { + sh '''#!/bin/bash + set +xe + export CCACHE_DIR=$WORKSPACE/ccache + make kernel + ''' + } + + stage('Images') { + sh '''#!/bin/bash + set +xe + export CCACHE_DIR=$WORKSPACE/ccache + make -j$(nproc) + ''' + } + } + + withEnv([ + "VERSION=$VERSION", + "CHANGES=$CHANGES", + "PRERELEASE=$PRERELEASE", + "GITHUB_USER=$GITHUB_USER", + "GITHUB_REPO=$GITHUB_REPO" + ]) { + stage('Freeze') { + sh '''#!/bin/bash + # use -ve, otherwise we could leak GITHUB_TOKEN... + set -ve + shopt -s nullglob + + export HOME=$WORKSPACE + export USER=jenkins + + repo manifest -r -o manifest.xml + ''' + } + + stage('Release') { + sh '''#!/bin/bash + set -xe + shopt -s nullglob + + github-release release \ + --tag "${VERSION}" \ + --name "$VERSION: $BUILD_TAG" \ + --description "${CHANGES}\n\n${BUILD_URL}" \ + --draft + + github-release upload \ + --tag "${VERSION}" \ + --name "manifest.xml" \ + --file "manifest.xml" + + for file in *.xz *.deb; do + github-release upload \ + --tag "${VERSION}" \ + --name "$(basename "$file")" \ + --file "$file" & + done + + wait + + 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 + ''' + } + } } } }