Skip to content

Commit

Permalink
Revert "Use declarative pipeline"
Browse files Browse the repository at this point in the history
This reverts commit e00164e.
  • Loading branch information
ayufan committed May 1, 2017
1 parent e00164e commit bdc3f51
Showing 1 changed file with 75 additions and 90 deletions.
165 changes: 75 additions & 90 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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
'''
}
}
}
}
}

0 comments on commit bdc3f51

Please sign in to comment.