From 6324800b824bf89fef606de5edeaa05ab2c27734 Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Thu, 9 Aug 2018 13:39:45 +0100 Subject: [PATCH] HMBXR5601-395 First import from Printserver2_Autobuild_Scripts --- release_to_git/release_to_git.gsh | 150 ++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 release_to_git/release_to_git.gsh diff --git a/release_to_git/release_to_git.gsh b/release_to_git/release_to_git.gsh new file mode 100644 index 0000000..b21cd73 --- /dev/null +++ b/release_to_git/release_to_git.gsh @@ -0,0 +1,150 @@ +pipeline { + agent { label "${AGENT_LABEL}" } + stages { + stage('Initial setup') { + steps { + script { + configurationhelper = load("${WORKSPACE}/Common_scripts/configuration/configuration.gsh") + githelper = load("${WORKSPACE}/Common_scripts/versioncontrol/git.gsh") + echo "Uncomment me" + //configurationhelper.registerPipelineScriptConfiguration() + } + } + } + stage('Clean workspace') { + when { + expression { + env.CLEAN_WORKSPACE == "true" + } + } + steps { + // Save any script files that were loaded into the workspace at first and are required after cleaning the workspace + stash allowEmpty: true, includes: 'Common_scripts/**/*', name: 'Clean workspace stash', useDefaultExcludes: false + cleanWs() + unstash name: 'Clean workspace stash' + } + } + stage('Nothing to build check') { + when { + expression { + env.RELEASE_COMMIT == "false" + } + } + steps { + echo 'No installers to build' + script { + currentBuild.result = 'UNSTABLE' + } + } + } + stage('Checkout dependencies') { + when { + expression { + env.RELEASE_COMMIT == "true" + } + } + steps { + script { + PYTHONURL = 'git@hydra:tools/python.git' + PYTHONBRANCH = 'origin/3.6.3_windows' + PYTHONDIR = "${WORKSPACE}/python" + PYTHONROOTDIR = 'python' + configurationhelper.gitCheckoutAndRegister('python', PYTHONURL, PYTHONBRANCH, PYTHONDIR, PYTHONROOTDIR) + env.PYTHON = "${PYTHONDIR}/ver/python.exe" + + SOURCEURL = 'git@hydra:gis/newsw.git' + SOURCEBRANCH = "${SOURCE_BRANCH}" + SOURCEDIR = "${WORKSPACE}\\newsw" + SOURCEROOTDIR = 'newsw' + configurationhelper.gitCheckoutAndRegister('newsw', SOURCEURL, SOURCEBRANCH, SOURCEDIR, SOURCEROOTDIR) + env.SOURCE_PATH = "${SOURCEDIR}" + } + } + } + stage("Clean imports") { + steps { + script { + env.IMPORTSPATH = "${WORKSPACE}/imports" + } + dir("${IMPORTSPATH}") { + echo "Deleting directories in ${IMPORTSPATH}" + deleteDir() + } + } + } + stage("Import binaries and versions") { + when { + expression { + env.RELEASE_COMMIT == "true" + } + } + steps { + script { + projectImports = [ + [ 'Installers and Binaries', "${INSTALLER_BUILD_JOB}", "${IMPORTSPATH}/install", '**', true ], + [ 'Build', "${BUILD_JOB}", "${IMPORTSPATH}/build", 'version/**,pipeline/**', false ], + ] + for (projectImport in projectImports) { + (importName, sourceProject, destFolder, toCopy, checkImports) = projectImport + copyArtifacts excludes: '', filter: toCopy, fingerprintArtifacts: true, projectName: "${sourceProject}", selector: lastSuccessful(), target: "${destFolder}" + if (checkImports) { + env.importDest = destFolder + bat ''' + "%PYTHON%" "%SOURCE_PATH%\\autobuild\\common\\fingerprint.py" -f "%importDest%\\pipeline\\hashes.txt" -v -p "%importDest%" + ''' + } + } + } + } + } + stage("Release to git") { + when { + expression { + env.RELEASE_COMMIT == "true" + } + } + steps { + script { + bat ''' + "%PYTHON34%" -u "%WORKSPACE%\\newsw\\autobuild\\releasetogit\\conditional_add.py" + ''' + } + } + } + stage('Check for unstable build') { + when { + expression { + env.RELEASE_COMMIT == "true" + } + } + steps { + script { + if (env.DRY_RUN_PUSH == "true") { + echo "Not pushing the content to git therefore marking building unstable" + currentBuild.result = 'UNSTABLE' + } + } + } + } + } + post { + always { + echo 'Post-build' + } + failure { + echo 'Failed build' +/* + step([$class: 'LogParserPublisher', + parsingRulesPath: 'GitRepository/autobuild/build/log parsing rules/vs.txt', + useProjectRule: true + ]) + */ + } + unstable { + echo 'Unstable build' + } + success { + echo 'Succeeded build' + } + } +}