Skip to content
Open
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
24 changes: 20 additions & 4 deletions pipeline/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,36 @@ function compile() {
fi
}

#
# Load config from config.groovy
# If an argument is passed then the values are filtered through grep to only
# include the given values.
#
# Note that here we are taking advantage of the fact that Groovy and Bash share
# common syntax for defining variables.
#
function load_config() {
if [ -z "$BASE" ];
then
BASE="."
fi
CONFIG=`sed 's/\/\/.*$//' $BASE/pipeline/config.groovy`

if [ ! -z "$1" ];
then
CONFIG=`sed 's/\/\/.*$//' $BASE/pipeline/config.groovy | grep "$1"`
else
CONFIG=`sed 's/\/\/.*$//' $BASE/pipeline/config.groovy`
fi

eval "$CONFIG"
}

function set_config_variable() {
NAME="$1"
VALUE="$2"
cp "$BASE/pipeline/config.groovy" "$BASE/pipeline/config.groovy.tmp"
sed 's,'^[\s]*$NAME'=\("\?\).*$,'$NAME'=\1'$VALUE'\1,g' $BASE/pipeline/config.groovy.tmp > "$BASE/pipeline/config.groovy" || err "Failed to set configuration variable $NAME to value $VALUE"

$TOOLS/groovy/2.3.4/bin/groovy -D name="$NAME" -D value="$VALUE" \

$GROOVY -D name="$NAME" -D value="$VALUE" \
-pne 'line.startsWith(System.properties.name+"=")?line.replaceAll("=.*",/="/+java.util.regex.Matcher.quoteReplacement(System.properties.value)+/"/): line' \
"$BASE/pipeline/config.groovy.tmp" > \
"$BASE/pipeline/config.groovy" \
Expand Down Expand Up @@ -163,6 +177,8 @@ fi
fi

BASE=`pwd`
TOOLS="$BASE/tools"
load_config GROOVY
set_config_variable BASE "$BASE"
load_config
}
Expand Down