diff --git a/Jenkinsfile b/Jenkinsfile index 18a2532f8236797c5f074eadcd9b6c160a9ef22a..ef75d120c0fd95c20dfa4fd2df24db385d318171 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,19 @@ +import groovy.json.JsonOutput + +// From https://issues.jenkins-ci.org/browse/JENKINS-44231 + +// Given arbitrary string returns a strongly escaped shell string literal. +// I.e. it will be in single quotes which turns off interpolation of $(...), etc. +// E.g.: 1'2\3\'4 5"6 (groovy string) -> '1'\''2\3\'\''4 5"6' (groovy string which can be safely pasted into shell command). +def shellString(s) { + // Replace ' with '\'' (https://unix.stackexchange.com/a/187654/260156). Then enclose with '...'. + // 1) Why not replace \ with \\? Because '...' does not treat backslashes in a special way. + // 2) And why not use ANSI-C quoting? I.e. we could replace ' with \' + // and enclose using $'...' (https://stackoverflow.com/a/8254156/4839573). + // Because ANSI-C quoting is not yet supported by Dash (default shell in Ubuntu & Debian) (https://unix.stackexchange.com/a/371873). + '\'' + s.replace('\'', '\'\\\'\'') + '\'' +} + pipeline { agent any @@ -6,9 +22,20 @@ pipeline { } stages { + stage('pre-build') { + steps { + checkout scm: [$class: 'GitSCM', clean: false, clearWorkspace: false] + + sh 'rm -rf ./build ./tmp' + } + } + stage('build') { steps { - build 'reticulum' + script { + def baseAssetsPath = "https://assets-dev.reticium.io/" + sh "GENERATE_SMOKE_TEST=true BASE_ASSETS_PATH=${shellString(baseAssetsPath)} yarn build -- --output-path build" + } } } }