diff --git a/pipelines/monolithic.Jenkinsfile b/pipelines/monolithic.Jenkinsfile index 2fd3592..7a8965a 100644 --- a/pipelines/monolithic.Jenkinsfile +++ b/pipelines/monolithic.Jenkinsfile @@ -39,6 +39,7 @@ def loadEnv() { final props = parseProps (configText) data.BUILD_OUTPUT_HOME_URL = props.BUILD_OUTPUT_HOME_URL data.PUBLISH_URL = props.PUBLISH_URL + data.BUILD_REMOTE_CLI = props.BUILD_REMOTE_CLI == "true" PROPS = data return data.NEED_BUILD } @@ -359,6 +360,12 @@ or with paths relative to repo root: } } // stages } // stage('IMAGES') + stage('remote-cli') { + when { expression { PROPS.BUILD_REMOTE_CLI } } + steps { + runPart ("build-remote-cli") + } + } stage('export-dir') { steps { runPart ("build-export-dir") } } diff --git a/pipelines/parts/build-remote-cli.Jenkinsfile b/pipelines/parts/build-remote-cli.Jenkinsfile new file mode 100644 index 0000000..7bbc696 --- /dev/null +++ b/pipelines/parts/build-remote-cli.Jenkinsfile @@ -0,0 +1,55 @@ +// 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' + ) + booleanParam ( + name: 'DRY_RUN' + ) + booleanParam ( + name: 'SHELL_XTRACE' + ) + } + stages { + stage ("build-export-dir") { + steps { + sh ("${Constants.SCRIPTS_DIR}/build-remote-cli.sh") + sh ("${Constants.SCRIPTS_DIR}/archive-remote-cli.sh") + sh ("${Constants.SCRIPTS_DIR}/publish-remote-cli.sh") + } + } + } + post { + cleanup { + cleanupPartJob() + } + } +} diff --git a/scripts/archive-remote-cli.sh b/scripts/archive-remote-cli.sh new file mode 100755 index 0000000..3349fbd --- /dev/null +++ b/scripts/archive-remote-cli.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# +# Copyright (c) 2022 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +set -e +source $(dirname "$0")/lib/job_utils.sh + +load_build_env + +src_dir="$WORKSPACE_ROOT/std/build-remote-cli" +dst_dir="$BUILD_OUTPUT_HOME/workspace/std/build-remote-cli" + +notice "copying remote-cli files to $dst_dir" + +if [[ -d "$dst_dir" ]] ; then + maybe_run rm -rf --one-file-system "$dst_dir" +fi + +if [[ -d "$src_dir" ]] ; then + maybe_run cp -arv "$src_dir" "$dst_dir" +fi + diff --git a/scripts/build-remote-cli.sh b/scripts/build-remote-cli.sh new file mode 100755 index 0000000..b8f2176 --- /dev/null +++ b/scripts/build-remote-cli.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +# +# Copyright (c) 2022 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +set -e +source $(dirname "$0")/lib/job_utils.sh +load_build_env +require_job_env DOCKER_BASE_OS +require_job_env BUILD_STREAM stable + +PLATFORM_IMAGE="stx-platformclients" +APPLICATION_IMAGE="stx-openstackclients" + +notice "building remote CLI tarball" + +# Usage: filter_image IMAGE_NAME LIST_FILE +filter_image() { + \grep --no-filename -E "^([^#].*/)*$1:" "$2" | tail -n 1 +} + +# Find images we built during this run +full_platform_image= +full_application_image= +if [[ -f "$WORKSPACE_ROOT/std/build-images/images-debian-stable-versioned.lst" ]] ; then + full_platform_image=$(filter_image "$PLATFORM_IMAGE" "$WORKSPACE_ROOT/std/build-images/images-debian-stable-versioned.lst") + full_application_image=$(filter_image "$APPLICATION_IMAGE" "$WORKSPACE_ROOT/std/build-images/images-debian-stable-versioned.lst") +fi + +build_args= +if [[ "$full_platform_image" ]] ; then + build_args+=" --platform-image $full_platform_image" +else + warn "docker image $PLATFORM_IMAGE not built, using default" +fi +if [[ "$full_application_image" ]] ; then + build_args+=" --application-image $full_application_image" +else + warn "docker image $APPLICATION_IMAGE not built, using default" +fi + +# Creates $MY_WORKSPACE/std/build-remote-cli/*.tgz +stx_docker_cmd $DRY_RUN_ARG "\$MY_REPO/build-tools/build-remote-cli.sh $build_args" diff --git a/scripts/print-config.sh b/scripts/print-config.sh index 08a498e..b093788 100755 --- a/scripts/print-config.sh +++ b/scripts/print-config.sh @@ -13,3 +13,4 @@ load_build_env echo "BUILD_OUTPUT_HOME_URL=$BUILD_OUTPUT_HOME_URL" echo "PUBLISH_URL=$PUBLISH_URL" +echo "BUILD_REMOTE_CLI=$BUILD_REMOTE_CLI" diff --git a/scripts/publish-remote-cli.sh b/scripts/publish-remote-cli.sh new file mode 100755 index 0000000..b24365a --- /dev/null +++ b/scripts/publish-remote-cli.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# +# Copyright (c) 2022 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +set -e +source $(dirname "$0")/lib/job_utils.sh + +load_build_env + +remote_cli_dir="$WORKSPACE_ROOT/std/build-remote-cli" +oidc_auth="$REPO_ROOT/cgcs-root/stx/oidc-auth-armada-app/oidc-auth-tools/oidcauthtools/oidcauthtools/oidc_auth.py" +dst_dir="$PUBLISH_DIR/outputs/remote-cli" + +notice "publishing remote-cli to $dst_dir" +maybe_run mkdir -p "$dst_dir" +if [[ -d "$remote_cli_dir" ]] || $DRY_RUN ; then + maybe_run find "$remote_cli_dir" -mindepth 1 -maxdepth 1 -name '*.tgz' -exec \ + cp -v -f --preserve=timestamps -t "$dst_dir" '{}' '+' +fi +if [[ -f "$oidc_auth" ]] || $DRY_RUN ; then + maybe_run cp -v -f --preserve=mode,timestamps "$oidc_auth" "$dst_dir/oidc-auth" + maybe_run chmod +x "$dst_dir/oidc-auth" +fi diff --git a/scripts/templates/build.conf.example.in b/scripts/templates/build.conf.example.in index 712a352..34e9b33 100644 --- a/scripts/templates/build.conf.example.in +++ b/scripts/templates/build.conf.example.in @@ -66,6 +66,9 @@ EXTRA_EXPORT_DIR_CMD= # $MY_WORKSPACE/export will be copied to the publish area at the end. EXTRA_EXPORT_FILES= +# Build & publish stx-remote-cli tarball (StarlingX only) +BUILD_REMOTE_CLI=false + ################################################## # Build outputs ##################################################