Skip to content
Snippets Groups Projects
Commit 66e9c815 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch '7030-ci-projectvars-for-replacement' into 'master'

create replace_ciserver.txt

See merge request !20
parents a442bd03 13b35fcb
No related branches found
No related tags found
1 merge request!20create replace_ciserver.txt
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
# 2023-12-?? v1.1 <axel.hahn@unibe.ch> show OK message in profile log # 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-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 # 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 @@ ...@@ -25,7 +26,7 @@
# CONFIG # CONFIG
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
cd $( dirname $0 ) cd $( dirname $0 )
_version=1.3 _version=1.4
export selfdir; selfdir=$( /bin/pwd ) export selfdir; selfdir=$( /bin/pwd )
export profiledir export profiledir
...@@ -251,6 +252,24 @@ function deploy(){ ...@@ -251,6 +252,24 @@ function deploy(){
# echo rm -f ${IMLCI_PROJECT}.tgz # 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" header "Update config files"
echo "Showing replacements:" ; grep '@replace\[' hooks/templates/* echo "Showing replacements:" ; grep '@replace\[' hooks/templates/*
......
...@@ -103,7 +103,9 @@ For hooks you can create files with pre defined names. A hook script must have e ...@@ -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_config.sh - replace config files (see below)
* profiles/myapp/tasks_postinstall.sh - do postinstall actions before finishing * 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. 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 ...@@ -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. * "${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. * 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. * 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: A sample replacement file is profiles/example/replace.txt:
...@@ -158,6 +162,17 @@ their replacement data: ...@@ -158,6 +162,17 @@ their replacement data:
* developers add api keys and other internal values * 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 ## 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. Example: A simple tasks_postinstall.sh can contain the start of a script that is delivered in the tgz archive.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment