Skip to content

Commit 0cb614d

Browse files
committed
apply-ng.sh: Allow configuring classpath
This is helpful when running GOP as scripts from dev image but the JAR resides somewhere else. For example, when applying GOP from a Jenkins job with docker.image .inside but mounting your own Groovy Scripts or when running locally CLASSPATH=target/xyz.jar scripts/apply-ng.sh
1 parent 23fb76a commit 0cb614d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

scripts/apply-ng.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#!/usr/bin/env bash
22
set -o errexit -o nounset -o pipefail
33

4+
TRACE=${TRACE:-}
5+
[[ $TRACE == true ]] && set -x;
6+
47
ABSOLUTE_BASEDIR="$(cd "$(dirname $0)" && pwd)"
58
PLAYGROUND_DIR="$(cd ${ABSOLUTE_BASEDIR} && cd .. && pwd)"
9+
# Allow for overriding the folder to jar via env var
10+
export CLASSPATH="${CLASSPATH:-${PLAYGROUND_DIR}/gitops-playground.jar}"
611

712
function apply-ng() {
813
groovy --classpath "$PLAYGROUND_DIR"/src/main/groovy \
@@ -12,11 +17,11 @@ function apply-ng() {
1217
# Runs groovy files without needing groovy
1318
function groovy() {
1419
# We don't need the groovy "binary" (script) to start, because the gitops-playground.jar already contains groovy-all.
20+
# Note that gitops-playground.jar is passed via env var CLASSPATH
1521

1622
# Set params like startGroovy does (which is called by the "groovy" script)
1723
# See https://github.com/apache/groovy/blob/master/src/bin/startGroovy
1824
java \
19-
-classpath "$PLAYGROUND_DIR"/gitops-playground.jar \
2025
org.codehaus.groovy.tools.GroovyStarter \
2126
--main groovy.ui.GroovyMain \
2227
"$@"

0 commit comments

Comments
 (0)