HMBXR5601-827 - Add package publish operations

This commit is contained in:
Dan Hawkins 2019-08-27 14:57:02 +01:00
commit e3a3ef6176

109
publish/package.groovy Normal file
View file

@ -0,0 +1,109 @@
pipeline {
agent { label "${AGENT_LABEL}" }
stages {
stage('Initial setup') {
steps {
script {
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
}
}
}
stage('Checkout dependencies') {
steps {
script {
configurationhelper = autobuilder.configurationhelper()
PYTHONURL = 'git@hydra:tools/python.git'
if (isUnix()) {
PYTHONBRANCH = "origin/3.6.3_linux"
}
else {
PYTHONBRANCH = "origin/3.6.3_windows"
}
PYTHONDIR = "${WORKSPACE}/python"
PYTHONROOTDIR = 'python'
configurationhelper.gitCheckoutAndRegister(meta, 'python', PYTHONURL, PYTHONBRANCH, PYTHONDIR, PYTHONROOTDIR)
if (isUnix()) {
env.PYTHON = "${PYTHONDIR}/usr/local/bin/python3"
}
else {
env.PYTHON = "${PYTHONDIR}/ver/python.exe"
}
}
}
}
stage('Clean exports') {
steps {
script {
PACKAGEDEST = "${WORKSPACE}/package"
cleanfolders = [
PACKAGEDEST,
]
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
cleaner.clean(cleanfolders)
}
}
}
stage('Copying package artifacts') {
steps {
script {
packagemeta = importer.artifactimport(meta, PACKAGE_CREATE_JOB, PACKAGE_CREATE_JOB_SELECTOR, PACKAGEDEST)
}
}
}
stage('Aptly environment') {
steps {
script {
echo "Aptly config file is ${APTLY_CONFIG_FILE}"
sh """!/#bin/bash
aptly config show
if [ \$? -ne 0 ]; then exit 1; fi
"""
}
}
}
stage('Create repo - if not already there') {
steps {
script {
echo "Repo name is ${REPO_NAME}"
sh """!/#bin/bash
aptly repo -config="${APTLY_CONFIG_FILE}" show "${REPO_NAME}"
if [ \$? -ne 0 ]; then
echo "aptly repo ${REPO_NAME} does not exist; Creating it"
aptly repo -config="${APTLY_CONFIG_FILE}" create "${REPO_NAME}"
if [ \$? -ne 0 ]; then exit 1; fi
fi
"""
}
}
}
stage('Create snapshot - if not already there') {
steps {
script {
echo "Snapshot name is ${SNAPSHOT_NAME}"
FULL_SNAPSHOT_NAME = "${REPO_NAME}_${SNAPSHOT_NAME}"
echo "Full Snapshot name is ${FULL_SNAPSHOT_NAME}"
sh """!/#bin/bash
# This errors if the snapshot exists already; Ignore it
aptly snapshot -config="${APTLY_CONFIG_FILE}" create "${FULL_SNAPSHOT_NAME}" from repo "${REPO_NAME}"
"""
}
}
}
}
post {
always {
echo 'Post-build'
}
failure {
echo 'Failed build'
}
unstable {
echo 'Unstable build'
}
success {
echo 'Succeeded build'
}
}
}