Skip to content
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ jobs:
matrix:
remoting_tag:
- 4.13.2-1-jdk11
- 4.13.3-1-jdk17
runs-on: ubuntu-latest
steps:
- name: Build and Push Docker Image
uses: Dwolla/jenkins-agents-workflow/.github/actions/build@main
with:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
BASE_TAG: ${{ matrix.REMOTING_TAG }}
BASE_TAG: ${{ matrix.remoting_tag }}
TAG_NAME: JENKINS_REMOTING_TAG
IMAGE_NAME: dwolla/jenkins-agent-core
build-complete:
Expand Down
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ LABEL org.label-schema.vcs-url="https://github.com/Dwolla/jenkins-agent-docker-c
ENV JENKINS_HOME=/home/jenkins

COPY build/install-esh.sh /tmp/build/install-esh.sh
COPY build/sdkman-init-wrapper.sh /usr/local/bin/sdkman-init-wrapper.sh

WORKDIR ${JENKINS_HOME}

Expand Down Expand Up @@ -37,6 +38,7 @@ RUN set -ex && \
&& \
ln -s /usr/bin/python3 /usr/bin/python && \
/tmp/build/install-esh.sh v0.3.2 && \
chmod +x /usr/local/bin/sdkman-init-wrapper.sh && \
rm -rf /tmp/build && \
mkdir -p /usr/share/man/man1/ && \
touch /usr/share/man/man1/sh.distrib.1.gz
Expand All @@ -53,4 +55,8 @@ RUN git config --global user.email "dev+jenkins@dwolla.com" && \
git config --global 'credential.https://github.com.username' 'x-access-token' && \
git config --global 'credential.https://github.com.helper' '!f() { if [ "$1" = get ]; then case "${GH_TOKEN-}" in (*[![:space:]]*) echo "password=${GH_TOKEN}";; (*) echo "error: GH_TOKEN is missing" >&2; exit 1;; esac; fi; }; f'

# Install SDKMAN
RUN curl -s "https://get.sdkman.io" | bash && \
bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && sdk version"

ENTRYPOINT ["jenkins-agent"]
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,29 @@ JENKINS_REMOTING_TAG := 4.13.2-1-jdk11
JOB := remoting-${JENKINS_REMOTING_TAG}
CLEAN_JOB := clean-${CORE_TAG}

# Default target builds Java 11 variant
all: remoting-4.13.2-1-jdk11 remoting-4.13.3-1-jdk17

clean: ${CLEAN_JOB}
.PHONY: all clean ${JOB} ${CLEAN_JOB}
.PHONY: all clean ${JOB} ${CLEAN_JOB} remoting-4.13.2-1-jdk11 remoting-4.13.3-1-jdk17

${JOB}: remoting-%: Dockerfile
docker build \
--build-arg JENKINS_REMOTING_TAG=$* \
--tag dwolla/jenkins-agent-core:$*-SNAPSHOT \
.

remoting-4.13.2-1-jdk11: Dockerfile
docker build \
--build-arg JENKINS_REMOTING_TAG=4.13.2-1-jdk11 \
--tag dwolla/jenkins-agent-core:4.13.2-1-jdk11-SNAPSHOT \
.

remoting-4.13.3-1-jdk17: Dockerfile
docker build \
--build-arg JENKINS_REMOTING_TAG=4.13.3-1-jdk17 \
--tag dwolla/jenkins-agent-core:4.13.3-1-jdk17-SNAPSHOT \
.

${CLEAN_JOB}: clean-%:
docker rmi -f dwolla/jenkins-agent-core:$*-SNAPSHOT
41 changes: 41 additions & 0 deletions build/sdkman-init-wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
# SDKMAN initialization wrapper script
# This script is designed to be used as BASH_ENV to automatically configure
# SDKMAN when .sdkmanrc files are present in the workspace.
#
# When BASH_ENV is set to this script, it will be sourced by every non-interactive
# bash shell, ensuring SDKMAN is configured before any commands run.

# Source SDKMAN initialization if it exists
if [ -f "$HOME/.sdkman/bin/sdkman-init.sh" ]; then
# SDKMAN requires errexit to be disabled during initialization
set +o errexit +o xtrace

# Source SDKMAN initialization
source "$HOME/.sdkman/bin/sdkman-init.sh"

# Check if .sdkmanrc exists in the current working directory or workspace
# Jenkins workspace is typically in $WORKSPACE or current directory
SDKMANRC_PATH=""
if [ -f ".sdkmanrc" ]; then
SDKMANRC_PATH=".sdkmanrc"
elif [ -n "${WORKSPACE:-}" ] && [ -f "${WORKSPACE}/.sdkmanrc" ]; then
SDKMANRC_PATH="${WORKSPACE}/.sdkmanrc"
fi

if [ -n "$SDKMANRC_PATH" ]; then
# Change to the directory containing .sdkmanrc for sdk env install
SDKMANRC_DIR=$(dirname "$SDKMANRC_PATH")
if [ "$SDKMANRC_DIR" != "." ]; then
cd "$SDKMANRC_DIR" || true
fi
# Install Java version specified in .sdkmanrc
sdk env install || true
# Re-source to ensure the new Java is on PATH
source "$HOME/.sdkman/bin/sdkman-init.sh"
fi

# Re-enable errexit and xtrace
set -o errexit -o xtrace
fi

Loading