jenkins.sh 1.2 KB

1234567891011121314151617181920212223242526
  1. #! /bin/bash -e
  2. : "${JENKINS_HOME:="/var/jenkins_home"}"
  3. touch "${COPY_REFERENCE_FILE_LOG}" || { echo "Can not write to ${COPY_REFERENCE_FILE_LOG}. Wrong volume permissions?"; exit 1; }
  4. echo "--- Copying files at $(date)" >> "$COPY_REFERENCE_FILE_LOG"
  5. find /usr/share/jenkins/ref/ -type f -exec bash -c '. /usr/local/bin/jenkins-support; for arg; do copy_reference_file "$arg"; done' _ {} +
  6. # if `docker run` first argument start with `--` the user is passing jenkins launcher arguments
  7. if [[ $# -lt 1 ]] || [[ "$1" == "--"* ]]; then
  8. # read JAVA_OPTS and JENKINS_OPTS into arrays to avoid need for eval (and associated vulnerabilities)
  9. java_opts_array=()
  10. while IFS= read -r -d '' item; do
  11. java_opts_array+=( "$item" )
  12. done < <([[ $JAVA_OPTS ]] && xargs printf '%s\0' <<<"$JAVA_OPTS")
  13. jenkins_opts_array=( )
  14. while IFS= read -r -d '' item; do
  15. jenkins_opts_array+=( "$item" )
  16. done < <([[ $JENKINS_OPTS ]] && xargs printf '%s\0' <<<"$JENKINS_OPTS")
  17. exec java "${java_opts_array[@]}" -jar /usr/share/jenkins/jenkins.war "${jenkins_opts_array[@]}" "$@"
  18. fi
  19. # As argument is not jenkins, assume user want to run his own process, for example a `bash` shell to explore this image
  20. exec "$@"