Separate building & starting of containers
Separate the build step from startup for environment containers. Build step is very slow, and we want to be able to start the containers without rebuilding when troubleshooting Jenkins jobs. TESTS ============================== Run both steps from Jenkins Story: 2010226 Task: 49212 Depends-On: https://review.opendev.org/c/starlingx/tools/+/902792 Signed-off-by: Davlet Panech <davlet.panech@windriver.com> Change-Id: I3462de0a9550310c931cbed2555de1b3a6bc53f9
This commit is contained in:
parent
38c59a480e
commit
bba927d30c
@ -280,6 +280,7 @@ or with paths relative to repo root:
|
||||
// Delete or keep packages, aptly state, etc depending on build params
|
||||
runPart ("clean-build")
|
||||
// start containers
|
||||
runPart ("build-env-containers")
|
||||
runPart ("start-containers")
|
||||
// login to docker early to catch login errors
|
||||
runPart ("docker-login")
|
||||
|
62
pipelines/parts/build-env-containers.Jenkinsfile
Normal file
62
pipelines/parts/build-env-containers.Jenkinsfile
Normal file
@ -0,0 +1,62 @@
|
||||
// vim: syn=groovy
|
||||
|
||||
//
|
||||
// Copyright (c) 2022 Wind River Systems, Inc.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
library "common@${params.JENKINS_SCRIPTS_BRANCH}"
|
||||
|
||||
setBuildDescr()
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
options {
|
||||
timestamps()
|
||||
}
|
||||
parameters {
|
||||
string (
|
||||
name: 'MASTER_JOB_NAME'
|
||||
)
|
||||
string (
|
||||
name: 'MASTER_BUILD_NUMBER'
|
||||
)
|
||||
string (
|
||||
name: 'JENKINS_SCRIPTS_BRANCH'
|
||||
)
|
||||
string (
|
||||
name: 'BUILD_HOME',
|
||||
)
|
||||
string (
|
||||
name: 'TIMESTAMP'
|
||||
)
|
||||
string (
|
||||
name: 'PUBLISH_TIMESTAMP'
|
||||
)
|
||||
booleanParam (
|
||||
name: 'SHELL_XTRACE'
|
||||
)
|
||||
booleanParam (
|
||||
name: 'REBUILD_BUILDER_IMAGES'
|
||||
)
|
||||
booleanParam (
|
||||
name: 'BUILDER_USE_DOCKER_CACHE'
|
||||
)
|
||||
booleanParam (
|
||||
name: 'USE_DOCKER_CACHE'
|
||||
)
|
||||
}
|
||||
stages {
|
||||
stage ("start-containers") {
|
||||
steps {
|
||||
sh ("${Constants.SCRIPTS_DIR}/build-env-containers.sh")
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
cleanup {
|
||||
cleanupPartJob()
|
||||
}
|
||||
}
|
||||
}
|
@ -37,15 +37,6 @@ pipeline {
|
||||
booleanParam (
|
||||
name: 'SHELL_XTRACE'
|
||||
)
|
||||
booleanParam (
|
||||
name: 'REBUILD_BUILDER_IMAGES'
|
||||
)
|
||||
booleanParam (
|
||||
name: 'BUILDER_USE_DOCKER_CACHE'
|
||||
)
|
||||
booleanParam (
|
||||
name: 'USE_DOCKER_CACHE'
|
||||
)
|
||||
}
|
||||
stages {
|
||||
stage ("start-containers") {
|
||||
|
37
scripts/build-env-containers.sh
Executable file
37
scripts/build-env-containers.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Copyright (c) 2022 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
set -e
|
||||
source $(dirname "$0")/lib/job_utils.sh
|
||||
|
||||
require_job_env BUILD_HOME
|
||||
require_job_env REBUILD_BUILDER_IMAGES
|
||||
require_job_env USE_DOCKER_CACHE
|
||||
|
||||
set -x
|
||||
load_build_env
|
||||
|
||||
# Check whether we need to login to docker hub
|
||||
dockerhub_login=
|
||||
for spec in $DOCKER_REGISTRY_LOGIN_LIST ; do
|
||||
if [[ "$(parse_docker_registry "$spec" | awk '{print $1}')" == "docker.io" ]] ; then
|
||||
dockerhub_login="--dockerhub-login"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# build or download containers
|
||||
cache_opts=
|
||||
if $BUILDER_USE_DOCKER_CACHE ; then
|
||||
cache_opts="--cache"
|
||||
fi
|
||||
rebuild_opts=
|
||||
if $REBUILD_BUILDER_IMAGES ; then
|
||||
rebuild_opts="--rebuild"
|
||||
fi
|
||||
./stx-init-env $rebuild_opts $cache_opts --no-start $dockerhub_login
|
@ -10,32 +10,13 @@ set -e
|
||||
source $(dirname "$0")/lib/job_utils.sh
|
||||
|
||||
require_job_env BUILD_HOME
|
||||
require_job_env REBUILD_BUILDER_IMAGES
|
||||
require_job_env USE_DOCKER_CACHE
|
||||
load_build_env
|
||||
require_job_env BUILDER_POD_STARTUP_TIMEOUT
|
||||
|
||||
set -x
|
||||
load_build_env
|
||||
|
||||
# Check whether we need to login to docker hub
|
||||
dockerhub_login=
|
||||
for spec in $DOCKER_REGISTRY_LOGIN_LIST ; do
|
||||
if [[ "$(parse_docker_registry "$spec" | awk '{print $1}')" == "docker.io" ]] ; then
|
||||
dockerhub_login="--dockerhub-login"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# start containers
|
||||
if $BUILDER_USE_DOCKER_CACHE ; then
|
||||
cache_opts="--cache"
|
||||
fi
|
||||
if $REBUILD_BUILDER_IMAGES ; then
|
||||
notice "rebuilding & starting containers"
|
||||
./stx-init-env --rebuild $cache_opts $dockerhub_login
|
||||
else
|
||||
notice "rebuilding containers"
|
||||
bash ./stx-init-env $cache_opts $dockerhub_login
|
||||
fi
|
||||
stx control stop
|
||||
stx config --upgrade
|
||||
stx control start
|
||||
|
||||
# wait for startup
|
||||
notice "waiting for containers to startup ($BUILDER_POD_STARTUP_TIMEOUT seconds)"
|
||||
|
Loading…
Reference in New Issue
Block a user