From 653623282ec8dad33944edd51d1d3661decd9d63 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 27 Aug 2019 14:57:02 +0100 Subject: [PATCH] HMBXR5601-827 - Add package publish operations --- publish/package.groovy | 109 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 publish/package.groovy diff --git a/publish/package.groovy b/publish/package.groovy new file mode 100644 index 0000000..3efe70b --- /dev/null +++ b/publish/package.groovy @@ -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' + } + } +} +