You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2019/11/08 15:08:15 UTC
[isis] branch master updated: ISIS-2167: ci-scripts: create the
build revision only once per run
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 637d705 ISIS-2167: ci-scripts: create the build revision only once per run
637d705 is described below
commit 637d7056a8582f31f02badfb370dd1dc84845eb8
Author: Andi Huber <ah...@apache.org>
AuthorDate: Fri Nov 8 16:07:42 2019 +0100
ISIS-2167: ci-scripts: create the build revision only once per run
since we cannot share environment variables among jobs within a single
CI build run, we introduce the concept of shared-env-vars
we store those on the build-system's file-system eg. ~/ci-env.txt so
that individual scripts/jobs can pick them up there
currently only the REVISION variable is handled that way, which ensures
we have a consistent build version throughout the entire ci-workflow
---
.gitlab-ci.yml | 2 +-
scripts/ci/build-core.sh | 3 +++
scripts/ci/build-demo-app.sh | 3 +++
scripts/ci/build-example-apps.sh | 3 +++
scripts/ci/build-mixins.sh | 5 +++++
scripts/ci/core-gitlab-ci.yml | 2 ++
scripts/ci/dry-run.sh | 21 ++++++++++++---------
scripts/ci/print-environment.sh | 3 +--
8 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index def26ac..5804ce9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -12,4 +12,4 @@ include:
before_script:
- export PROJECT_ROOT_PATH=$CI_PROJECT_DIR
- export CI_SCRIPTS_PATH=$PROJECT_ROOT_PATH/scripts/ci
- - export REVISION=$BASELINE.$(date +%Y%m%d)-$(date +%H%M)-$(echo $CI_COMMIT_SHA | cut -c1-8)
+
\ No newline at end of file
diff --git a/scripts/ci/build-core.sh b/scripts/ci/build-core.sh
index ac83908..1d2b54f 100644
--- a/scripts/ci/build-core.sh
+++ b/scripts/ci/build-core.sh
@@ -1,6 +1,9 @@
#!/bin/bash
set -e
+# import shared vars (non secret!)
+source $SHARED_VARS_FILE && export $(cut -d= -f1 $SHARED_VARS_FILE)
+
sh $CI_SCRIPTS_PATH/print-environment.sh "build-core"
cd $PROJECT_ROOT_PATH/core
diff --git a/scripts/ci/build-demo-app.sh b/scripts/ci/build-demo-app.sh
index 8653c0a..dca5747 100644
--- a/scripts/ci/build-demo-app.sh
+++ b/scripts/ci/build-demo-app.sh
@@ -1,6 +1,9 @@
#!/bin/bash
set -e
+# import shared vars (non secret!)
+source $SHARED_VARS_FILE && export $(cut -d= -f1 $SHARED_VARS_FILE)
+
sh $CI_SCRIPTS_PATH/print-environment.sh "build-demo-app"
export FLAVOR=$1
diff --git a/scripts/ci/build-example-apps.sh b/scripts/ci/build-example-apps.sh
index 411d482..81190d8 100644
--- a/scripts/ci/build-example-apps.sh
+++ b/scripts/ci/build-example-apps.sh
@@ -1,6 +1,9 @@
#!/bin/bash
set -e
+# import shared vars (non secret!)
+source $SHARED_VARS_FILE && export $(cut -d= -f1 $SHARED_VARS_FILE)
+
sh $CI_SCRIPTS_PATH/print-environment.sh "build-example-apps"
cd $PROJECT_ROOT_PATH/examples
diff --git a/scripts/ci/build-mixins.sh b/scripts/ci/build-mixins.sh
index 38cfa0a..311648a 100644
--- a/scripts/ci/build-mixins.sh
+++ b/scripts/ci/build-mixins.sh
@@ -1,6 +1,11 @@
#!/bin/bash
set -e
+echo "Shared Vars File: ${SHARED_VARS_FILE}"
+
+# import shared vars (non secret!)
+source $SHARED_VARS_FILE && export $(cut -d= -f1 $SHARED_VARS_FILE)
+
sh $CI_SCRIPTS_PATH/print-environment.sh "build-mixins"
cd $PROJECT_ROOT_PATH/mixins
diff --git a/scripts/ci/core-gitlab-ci.yml b/scripts/ci/core-gitlab-ci.yml
index ed12ac1..ab5a6ec 100644
--- a/scripts/ci/core-gitlab-ci.yml
+++ b/scripts/ci/core-gitlab-ci.yml
@@ -20,9 +20,11 @@
build all:
stage: build-package-push
variables:
+ SHARED_VARS_FILE: ~/ci-env.txt
MVN_STAGES: deploy
script:
# mixins are built first because core (which includes extensions) depend upon them.
+ - echo "REVISION=$BASELINE.$(date +%Y%m%d)-$(date +%H%M)-$(echo $CI_COMMIT_SHA | cut -c1-8)" > $SHARED_VARS_FILE
- sh $CI_SCRIPTS_PATH/build-mixins.sh
- sh $CI_SCRIPTS_PATH/build-core.sh
- sh $CI_SCRIPTS_PATH/build-demo-app.sh springboot
diff --git a/scripts/ci/dry-run.sh b/scripts/ci/dry-run.sh
index 4fbbf63..75a6b45 100644
--- a/scripts/ci/dry-run.sh
+++ b/scripts/ci/dry-run.sh
@@ -5,22 +5,25 @@ set -e
export BASELINE=2.0.0-M2
export GCPAPPENGINEREPO_URL=https://repo.incode.work
+export SHARED_VARS_FILE=~/ci-env.txt
-export REVISION=$BASELINE.$(date +%Y%m%d)
+echo "REVISION=$BASELINE.$(date +%Y%m%d)-$(date +%H%M)-$(echo $CI_COMMIT_SHA | cut -c1-8)" > $SHARED_VARS_FILE
+
+## for the consumers to import shared vars (non secret!)
+## source $SHARED_VARS_FILE && export $(cut -d= -f1 $SHARED_VARS_FILE)
export PROJECT_ROOT_PATH=$PWD
export CI_SCRIPTS_PATH=$PROJECT_ROOT_PATH/scripts/ci
export MVN_STAGES="install"
-SECRETS_FILE=~/ci-secrets.txt
-
echo "================= DRY RUN =================="
-echo "\$REVISION = ${REVISION}"
-echo "\$CI_BUILDS_DIR = ${CI_BUILDS_DIR}"
+echo "Shared Vars File: ${SHARED_VARS_FILE}"
+cat $SHARED_VARS_FILE
echo "=============================================="
cd $PROJECT_ROOT_PATH
+SECRETS_FILE=~/ci-secrets.txt
if [ -f "$SECRETS_FILE" ]; then
source $SECRETS_FILE
export $(cut -d= -f1 $SECRETS_FILE)
@@ -30,7 +33,7 @@ else
exit 0
fi
-sh $CI_SCRIPTS_PATH/build-mixins.sh
-sh $CI_SCRIPTS_PATH/build-core.sh
-sh $CI_SCRIPTS_PATH/build-demo-app.sh dryrun
-sh $CI_SCRIPTS_PATH/build-example-apps.sh
+bash $CI_SCRIPTS_PATH/build-mixins.sh
+bash $CI_SCRIPTS_PATH/build-core.sh
+bash $CI_SCRIPTS_PATH/build-demo-app.sh dryrun
+bash $CI_SCRIPTS_PATH/build-example-apps.sh
diff --git a/scripts/ci/print-environment.sh b/scripts/ci/print-environment.sh
index 22bd67c..365b8a7 100644
--- a/scripts/ci/print-environment.sh
+++ b/scripts/ci/print-environment.sh
@@ -2,8 +2,7 @@
echo "\n\n"
-echo "================= ISIS CI SCRIPT ====================="
-echo "Name: $1"
+echo "=========== ISIS CI SCRIPT [$1] ================="
echo "\$PROJECT_ROOT_PATH = ${PROJECT_ROOT_PATH}"
echo "\$MVN_STAGES = ${MVN_STAGES}"
echo "\$REVISION = ${REVISION}"