diff --git a/deploy_app.sh b/deploy_app.sh index 6f64e58b71ac99bf957d42616b6079f7cfd72fcb..761cfb141f7915359a55a5e050881dea5e35f4a6 100755 --- a/deploy_app.sh +++ b/deploy_app.sh @@ -18,6 +18,7 @@ # 2023-12-?? v1.1 <axel.hahn@unibe.ch> show OK message in profile log # 2023-12-14 v1.2 <axel.hahn@unibe.ch> export some vars; abort on errors # 2023-12-18 v1.3 <axel.hahn@unibe.ch> add lines to profile log on error +# 2024-02-22 v1.4 <axel.hahn@unibe.ch> create replace_ciserver.txt # ====================================================================== @@ -25,7 +26,7 @@ # CONFIG # ---------------------------------------------------------------------- cd $( dirname $0 ) -_version=1.3 +_version=1.4 export selfdir; selfdir=$( /bin/pwd ) export profiledir @@ -251,6 +252,24 @@ function deploy(){ # echo rm -f ${IMLCI_PROJECT}.tgz + # ---------------------------------------------------------------------- + cijson="${installdir}/${IMLCI_PROJECT}.json" + replacefile="${profiledir}/replace_ciserver.txt" + header "Create $replacefile with ciserver project vars" + + if [ ! -f "$cijson" ]; then + echo "ERROR: Source not found: $cijson" + exit 4 + fi + echo "# generated with data from $cijson" > "$replacefile" + for mykey in branch revision + do + civalue=$( cat "$cijson" | jq ".${mykey}" | tr -d '"') + echo "ci-${mykey}=$civalue" >> "$replacefile" + done + ls -l "$replacefile" + + # ---------------------------------------------------------------------- header "Update config files" echo "Showing replacements:" ; grep '@replace\[' hooks/templates/* diff --git a/docs/30_Configuration.md b/docs/30_Configuration.md index 2072303ec6451db3e2ff9b20bdb06f8f40c0b2b5..8ef620e0bf7679ffe3d2ecdfa440d75205c5a86f 100644 --- a/docs/30_Configuration.md +++ b/docs/30_Configuration.md @@ -103,7 +103,9 @@ For hooks you can create files with pre defined names. A hook script must have e * profiles/myapp/tasks_config.sh - replace config files (see below) * profiles/myapp/tasks_postinstall.sh - do postinstall actions before finishing -## Create configs for an application: tasks_config.sh +## Create configs for an application + +### Run script tasks_config.sh The script `./bin/create_config.sh` can read config templates and create an output file. @@ -125,7 +127,9 @@ During execution the working directory is the target directory of your applicati * "${selfdir}/bin/create_config.sh" is the script that replaces config data in a template. * In your software repsoitory put a template into ./hooks/templates/. It will be found if the archive was extracted. * the target file is relative to your application root. -* files with replacement data. +* files with replacement data. You can use file globbing, eg. `${profiledir}/replace*.txt` + +### Replacements A sample replacement file is profiles/example/replace.txt: @@ -158,6 +162,17 @@ their replacement data: * developers add api keys and other internal values * ... +### Ciserver project values + +After extracting the software there is an atomatic step that generates a replacement from [PROJECTID].json in the install directory. + +It generates a replacement file named `replace_ciserver`.txt in the profile directory and contains the branch name and the revision id of the last commit: + +```shell +ci-branch=origin/master +ci-revision=9f041d5f3fe9faa43769da97f3eb46d5c553e3fe +``` + ## Pre and post install actions Example: A simple tasks_postinstall.sh can contain the start of a script that is delivered in the tgz archive.