Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/agent #18

Merged
merged 3 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions bash/.klibio/dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

# activate bash checks
#set -o xtrace # activate debug
set -o nounset # exit with error on unset variables
set -o errexit # exit if any statement returns a non-true return value
set -o pipefail # exit if any pipe command is failing

echo "# DEVELOPMENT start"

unset ospath

removeFromPath () {
local segment=$1
if [[ $ospath == *"\\"* ]]; then
# windows remove segment path (and optional trailing semi-colon)
export PATH=$(echo ${PATH} | sed -E -e "s/${segment/\\/\\\\};?//" -e "s/;$//")
else
# *nix remove segment from path (and optional trailing colon)
export PATH=$(echo ${PATH} | sed -E -e "s;${segment}:?;;" -e "s;:$;;")
fi
export $PATH
}

PATH=$PATH:"/c/dir_a:/c/dir_b:/c/dir_c:/c/dir_d"
echo "PATH=${PATH}"

path2remove="/c/dir_a"
echo "path after removing ${path2remove} from path $( removeFromPath ${path2remove} )"

path2remove="/c/dir_b"
echo "path after removing ${path2remove} from path $( removeFromPath ${path2remove} )"

path2remove="/c/dir_d"
echo "path after removing ${path2remove} from path $( removeFromPath ${path2remove} )"


ospath="c:\dir_a;c:\dir_b;c:\dir_c;c:\dir_d"
echo "ospath=${ospath}"

path2remove="c:\dir_a"
echo "path after removing ${path2remove} from path $( removeFromPath ${path2remove} )"

path2remove="c:\dir_b"
echo "path after removing ${path2remove} from path $( removeFromPath ${path2remove} )"

path2remove="c:\dir_d"
echo "path after removing ${path2remove} from path $( removeFromPath ${path2remove} )"

echo "# DEVELOPMENT finish"

2 changes: 1 addition & 1 deletion bash/.klibio/klibio.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ declare -a build_agent_vars=(
"date"
"branch" "vcs_ref" "vcs_ref_short" # git variables
)
if [[ ! -n ${AGENT_ID:-} ]]; then
if [[ ! -z ${AGENT_ID+x} ]]; then
echo "running inside workflow pipeline - hence set variables"
for i in "${build_agent_vars[@]}"; do
key=$(echo $i | tr '[:lower:]' '[:upper:]')
Expand Down
13 changes: 12 additions & 1 deletion bash/.klibio/set-java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ set -o pipefail # exit if any pipe command is failing
java_home_suffix=${java_home_suffix:=}

removeFromPath () {
export PATH=$(echo $PATH | sed -E -e "s;:$1;;" -e "s;$1:?;;")
local segment=$1
# *nix remove segment from path (and optional trailing colon)
export PATH=$(echo ${PATH} | sed -E -e "s;${segment}:?;;" -e "s;:$;;")
}

if [ -n "${JAVA_HOME+x}" ]; then
Expand All @@ -18,17 +20,21 @@ fi

case $1 in
unset)
removeFromPath $JAVA_HOME
unset JAVA_HOME
echo "JAVA_HOME unset - available Java LTS are 8, 11, 17"
exit 0
;;
8)
removeFromPath $JAVA_HOME
export JAVA_HOME=${KLIBIO}/java/ee/JAVA8${java_home_suffix}
;;
11)
removeFromPath $JAVA_HOME
export JAVA_HOME=${KLIBIO}/java/ee/JAVA11${java_home_suffix}
;;
17)
removeFromPath $JAVA_HOME
export JAVA_HOME=${KLIBIO}/java/ee/JAVA17${java_home_suffix}
;;
*)
Expand All @@ -41,3 +47,8 @@ echo JAVA_HOME=${JAVA_HOME}
export PATH=${JAVA_HOME}/bin:$PATH

java -version

// reset the bash settings
set +o nounset # exit with error on unset variables
set +o errexit # exit if any statement returns a non-true return value
set +o pipefail # exit if any pipe command is failing