-
-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bootstrap wrapper script for Docker
This allows users to pass "cli" or "run" as Docker CMD to easily switch modes without having to set environment variables. Also provides the DEBUG environment variable that used to be provided by the launcher script (which is no longer used as of this). Also removes the FORCE_JENKINS_CLI environment variables as it's no longer necessary. as per #207 (comment)
- Loading branch information
1 parent
6aeca51
commit f2c00fd
Showing
5 changed files
with
93 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [[ -z "${JENKINS_HOME}" ]] || [[ -z "${JENKINS_REF}" ]]; then | ||
echo "$0: Environment variables JENKINS_HOME and JENKINS_REF need to be set!" >&2 | ||
exit 1 | ||
elif [[ ! -d "${JENKINS_HOME}" ]]; then | ||
echo "$0: JENKINS_HOME at ${JENKINS_HOME} does not exist." >&2 | ||
exit 1 | ||
elif [[ ! -d "${JENKINS_REF}" ]]; then | ||
echo "$0: JENKINS_REF at ${JENKINS_REF} does not exist." >&2 | ||
exit 1 | ||
fi | ||
|
||
export JENKINS_WORKSPACE="${JENKINS_WORKSPACE:-/workspace}" | ||
export JENKINS_BUILD_DIR="${JENKINS_BUILD_DIR:-/build}" | ||
export CASC_JENKINS_CONFIG="${CASC_JENKINS_CONFIG:-${JENKINS_REF}/casc}" | ||
export JENKINS_PLUGIN_DIR="${JENKINS_PLUGIN_DIR:-${JENKINS_REF}/plugins}" | ||
|
||
export JENKINS_UC="${JENKINS_UC:-https://updates.jenkins.io}" | ||
|
||
LAUNCHER_PARAMS=("-w" "${JENKINS_HOME}" "-p" "${JENKINS_REF}/plugins") | ||
|
||
if [[ -n "${DEBUG}" ]]; then | ||
export JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 ${JAVA_OPTS:-}" | ||
echo "$0: Make sure to expose the port by providing -p 5005:5005 to docker run" | ||
fi | ||
|
||
if [[ "$#" -gt 0 ]]; then | ||
case "$1" in | ||
run) | ||
LAUNCHER_PARAMS+=("-f" "${JENKINS_WORKSPACE}" "--runWorkspace" "${JENKINS_BUILD_DIR}") | ||
;; | ||
cli) | ||
LAUNCHER_PARAMS+=("--cli") | ||
;; | ||
*) | ||
echo "$0: Unknown action $1. Try $0 [run|cli]" | ||
echo " run: Launch a Jenkinsfile build." | ||
echo " cli: Attach an interactive Jenkins shell." | ||
exit 1 | ||
;; | ||
esac | ||
|
||
if [[ "$#" -gt 1 ]]; then | ||
LAUNCHER_PARAMS+=("${@:1}") | ||
fi | ||
fi | ||
|
||
if [[ -x "/app/bin/jenkinsfile-runner" ]]; then | ||
/app/bin/jenkinsfile-runner "${LAUNCHER_PARAMS[@]}" | ||
else | ||
echo "$0: /app/bin/jenkinsfile-runner needs to be an executable file." >&2 | ||
exit 1 | ||
fi |