downstreamJobs = [:] // map build_url : build_result
envVarList = []
job_environment = ""
job_build = ""
job_post = ""
job_utils = ""
String env_var_string = new String('')
def create_env_var_string() {
def env_vars = new String("${ENV_VAR_STRING}").split(',')
def env_vars_shell = []
env_var_string = new String('')
// read env vars from env_string
env_vars.each { env_var ->
if (env_var.contains('=')) {
String new_env_var = new String(env_var.replaceAll("\\s",""))
env_vars_shell.add(new String("export ${new_env_var}"))
envVarList.add(new String("${new_env_var}"))
}
}
// add special env vars
env_vars_shell.add(new String("export CACHE=${DOCKER_WORKSPACE}/cache_rcar-3"))
// now build one string that the shell can take as env var list
env_vars_shell.each { env_var ->
env_var_string = env_var_string + env_var + ' && '
}
// now remove last &&
if (env_var_string.endsWith(' && ')) {
int index = env_var_string.lastIndexOf(' && ');
if (index > 0) {
env_var_string = env_var_string.substring(0, index)
}
}
}
def prepare_docker_workspace() {
def status
// create deploy directory
status = job_utils.create_folder("${DEPLOY_BUILDS}")
if (status != 0) {
error('deploy directory cannot be created')
}
// fetch all lfs files
status = sh(returnStatus: true, script: "cd ${JENKINS_WORKSPACE} && repo forall -c git lfs pull")
if (status != 0) {
error('repo lfs pull failed')
}
// clean docker workspace
status = job_utils.delete_folder("${DOCKER_WORKSPACE}")
if (status != 0) {
error('removing docker workspace failed')
}
// create out directory
status = job_utils.create_folder("${OUT}")
if (status != 0) {
error('out directory cannot be created')
}
//copy jenkins workspace directory to docker workspace
status = sh(returnStatus: true, script: "rsync -a --exclude \'yocto-packages\' ${JENKINS_WORKSPACE}/ ${DOCKER_WORKSPACE}")
if (status != 0) {
error('copying workspace to docker workspace failed')
}
}
def yocto_build() {
def status
// activate SSTATE Mirror for all builds that are not
// nightly and not a RB build
if ((NIGHTLY == "false") && (BUILD_TYPE != "RB")) {
env_var_string = env_var_string + " && export SSTATE_MIRROR_DIR=${NFS_SHARE_BUILD_LINUX}"
}
// run build environment and call execution script
status = sh(returnStatus: true, script: """
#!/bin/bash
set +e
set +x
EXIT_CODE=0
cd ${BUILDENV_SH_DIR}
./run_buildenv.sh --name=${DOCKER_CONTAINER_NAME} -wd=${DOCKER_WORKSPACE} -nfsd=${NFS_SHARE_BUILD_LINUX} \\
-ypd=\"${WORKSPACE}/${JENKINS_WORKSPACE}/yocto-packages:${DOCKER_WORKSPACE}/yocto-packages\" \\
--dns=
10.243.80.201 -u=${USER} \\
\"bash -c \'${env_var_string} && ${YOCTO_SH_DIR}/run_yocto_build.sh --machine=${BUILD_VARIANT}\'\" || EXIT_CODE=\$?
exit \$EXIT_CODE
"""
)
if (status != 0) {
error('yocto build failed')
}
// generate BoM
status = job_build.generateBoM("${BUILD_VARIANT}")
if (status != 0) {
error("Generation of BoM failed for ${BUILD_VARIANT}")
}
// generate build report
status = job_build.generateBuildReport("${BUILD_VARIANT}")
if (status != 0) {
error("Generation of build report failed for ${BUILD_VARIANT}")
}
}
def deploy_artifacts(String check_code) {
def status = job_utils.copy("${RESULT_DIR}/*", "${DEPLOY_BUILDS}")
if ((status != 0) && (check_code == 'true')) {
error('deploying artifacts failed')
}
}
pipeline {
agent { node { label 'LinuxSlaveBuild' } }
options {
timestamps()
buildDiscarder(logRotator(numToKeepStr: '200', daysToKeepStr: '90'))
authorizationMatrix([
'hudson.model.Item.Workspace:pr_de12962_conti_vw_icas1',
'hudson.model.Item.Build:pr_de12962_con