firmware_tools/autobuild/Common_scripts/publish/jsclient.groovy
2022-10-12 10:45:16 +01:00

89 lines
3.2 KiB
Groovy

pipeline {
agent { label AGENT_LABEL }
stages {
stage('Initial setup') {
steps {
script {
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
}
}
}
stage('Clean imports') {
steps {
script {
env.JSCLIENT = "jsclient"
cleanfolders = [
JSCLIENT,
]
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
cleaner.clean(cleanfolders)
}
}
}
stage('Import JS client artifacts') {
steps {
script {
importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
def importoptions = importer.getNewImportOptions()
importoptions.jenkinsjob(PACKAGE_CREATE_JOB, PACKAGE_CREATE_JOB_SELECTOR)
jsclientmeta = importer.artifactimportfrombuildjob(meta, importoptions, JSCLIENT)
productname = jsclientmeta.productinfo.productname
productvariant = jsclientmeta.productvariant()
buildstampprefix = jsclientmeta.buildstampinfo.buildstampprefix
echo "JS client imported for product: ${productvariant} and build stamp prefix: ${buildstampprefix}"
}
}
}
stage('Copy JS client to server') {
steps {
script {
jsclientsource = "${JSCLIENT}/${ARTIFACT_PATH_TO_JSCLIENT_ROOT}"
pathonserver = "${ROOT_PATH_ON_SERVER.trim()}/${productvariant}/${buildstampprefix}"
echo "Copying from ${jsclientsource} to ${pathonserver}"
if (isUnix()) {
sh """#!/bin/bash
rm -rfv "${pathonserver}"
if [ \$? -ne 0 ]; then exit 1; fi
mkdir -pv "${pathonserver}"
if [ \$? -ne 0 ]; then exit 1; fi
echo mv -v "${jsclientsource}"/* "${pathonserver}"
mv -v "${jsclientsource}"/* "${pathonserver}"/
if [ \$? -ne 0 ]; then exit 1; fi
"""
dir(pathonserver) {
sh """#!/bin/bash
mkdir -v unpacked
if [ \$? -ne 0 ]; then exit 1; fi
unzip -P "${ZIP_PASSWORD}" export.zip -d unpacked
if [ \$? -ne 0 ]; then exit 1; fi
"""
}
} else {
error("This job does not run on Windows at the moment")
}
}
}
}
}
post {
always {
echo 'Post-build'
}
failure {
echo 'Failed build'
}
unstable {
echo 'Unstable build'
}
success {
echo 'Succeeded build'
}
}
}