Skip to content

Commit 2f13f7f

Browse files
committed
feat: build both agent and inbound-agent images
1 parent 326edf7 commit 2f13f7f

19 files changed

Lines changed: 557 additions & 384 deletions

.github/workflows/update-dockerhub-description.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,21 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
12-
- name: Update Docker Hub description
12+
- name: Update Docker Hub description for agent
1313
uses: peter-evans/dockerhub-description@v3
1414
with:
1515
username: ${{ secrets.DOCKERHUB_USERNAME }}
1616
password: ${{ secrets.DOCKERHUB_PASSWORD }}
1717
enable-url-completion: true
18-
short-description: ${{ github.event.repository.description }}
18+
short-description: This is a base image, which provides the Jenkins agent executable (agent.jar)
19+
repository: jenkins/agent
20+
readme-filepath: ./README_agent.md
21+
- name: Update Docker Hub description for inbound-agent
22+
uses: peter-evans/dockerhub-description@v3
23+
with:
24+
username: ${{ secrets.DOCKERHUB_USERNAME }}
25+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
26+
enable-url-completion: true
27+
short-description: This is an image for Jenkins agents using TCP or WebSockets to establish inbound connection to the Jenkins controller
1928
repository: jenkins/inbound-agent
29+
readme-filepath: ./README_inbound-agent.md

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
bats-core/
33
bats/
44
target/
5+
build-windows-current.yaml

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pipeline {
6969
}
7070
post {
7171
always {
72-
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/**/junit-results.xml')
72+
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/**/junit-results*.xml')
7373
}
7474
}
7575
}

Makefile

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ export BUILDKIT_PROGRESS=plain
1010
current_arch := $(shell uname -m)
1111
export ARCH ?= $(shell case $(current_arch) in (x86_64) echo "amd64" ;; (i386) echo "386";; (aarch64|arm64) echo "arm64" ;; (armv6*) echo "arm/v6";; (armv7*) echo "arm/v7";; (s390*|riscv*|ppc64le) echo $(current_arch);; (*) echo "UNKNOWN-CPU";; esac)
1212

13-
IMAGE_NAME:=jenkins4eval/agent
14-
15-
# Set to the path of a specific test suite to restrict execution only to this
16-
# default is "all test suites in the "tests/" directory
17-
TEST_SUITES ?= $(CURDIR)/tests
18-
1913
##### Macros
2014
## Check the presence of a CLI in the current PATH
2115
check_cli = type "$(1)" >/dev/null 2>&1 || { echo "Error: command '$(1)' required but not found. Exiting." ; exit 1 ; }
@@ -42,6 +36,7 @@ build: check-reqs
4236

4337
build-%:
4438
@$(call check_image,$*)
39+
@echo "== building $*"
4540
@set -x; $(bake_base_cli) --set '*.platform=linux/$(ARCH)' '$*'
4641

4742
show:
@@ -59,7 +54,7 @@ prepare-test: bats check-reqs
5954

6055
## Define bats options based on environment
6156
# common flags for all tests
62-
bats_flags := $(TEST_SUITES)
57+
bats_flags := ""
6358
# if DISABLE_PARALLEL_TESTS true, then disable parallel execution
6459
ifneq (true,$(DISABLE_PARALLEL_TESTS))
6560
# If the GNU 'parallel' command line is absent, then disable parallel execution
@@ -75,9 +70,10 @@ test-%: prepare-test
7570
@$(call check_image,$*)
7671
# Ensure that the image is built
7772
@make --silent build-$*
78-
# Execute the test harness and write result to a TAP file
73+
@echo "== testing $*"
7974
set -x
80-
IMAGE=$* bats/bin/bats $(bats_flags) | tee target/results-$*.tap
75+
# Each type of image ("agent" or "inbound-agent") has its own tests suite
76+
IMAGE=$* bats/bin/bats $(CURDIR)/tests/tests_$(shell echo $* | cut -d "_" -f 1).bats $(bats_flags) | tee target/results-$*.tap
8177
# convert TAP to JUNIT
8278
docker run --rm -v "$(CURDIR)":/usr/src/app -w /usr/src/app node:16-alpine \
8379
sh -c "npm install tap-xunit -g && cat target/results-$*.tap | tap-xunit --package='jenkinsci.docker.$*' > target/junit-results-$*.xml"

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Jenkins Agent and Inbound Agent Docker images
2+
3+
[![Join the chat at https://gitter.im/jenkinsci/docker](https://badges.gitter.im/jenkinsci/docker.svg)](https://gitter.im/jenkinsci/docker?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4+
[![GitHub stars](https://img.shields.io/github/stars/jenkinsci/docker-agent?label=GitHub%20stars)](https://github.com/jenkinsci/docker-agent)
5+
[![GitHub release](https://img.shields.io/github/release/jenkinsci/docker-agent.svg?label=changelog)](https://github.com/jenkinsci/docker-agent/releases/latest)
6+
7+
This repository contains the definition of two images:
8+
9+
## agent
10+
[![Docker Pulls](https://img.shields.io/docker/pulls/jenkins/agent.svg)](https://hub.docker.com/r/jenkins/agent/)
11+
12+
This is a base image for Docker, which includes JDK and the Jenkins agent executable (agent.jar).
13+
14+
See [the `agent` README](./README_agent.md)
15+
16+
## inbound-agent
17+
[![Docker Pulls](https://img.shields.io/docker/pulls/jenkins/inbound-agent.svg)](https://hub.docker.com/r/jenkins/inbound-agent/)
18+
19+
This is an image based on `agent` for [Jenkins](https://jenkins.io) agents using TCP or WebSockets to establish inbound connection to the Jenkins master.
20+
21+
See [the `inbound-agent` README](./README_inbound-agent.md)

alpine/Dockerfile

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@ RUN if [ "$TARGETPLATFORM" != 'linux/arm/v7' ]; then \
4040
cp -r /opt/java/openjdk /javaruntime; \
4141
fi
4242

43-
FROM alpine:"${ALPINE_TAG}" AS build
43+
## Agent image target
44+
FROM alpine:"${ALPINE_TAG}" AS agent
4445

4546
ARG user=jenkins
4647
ARG group=jenkins
4748
ARG uid=1000
4849
ARG gid=1000
4950

5051
RUN addgroup -g "${gid}" "${group}" \
51-
&& adduser -h /home/"${user}" -u "${uid}" -G "${group}" -D "${user}"
52+
&& adduser -h /home/"${user}" -u "${uid}" -G "${group}" -D "${user}" || echo "user ${user} already exists."
5253

5354
ARG AGENT_WORKDIR=/home/"${user}"/agent
5455

@@ -82,7 +83,7 @@ ENV PATH="${JAVA_HOME}/bin:${PATH}"
8283

8384
USER "${user}"
8485
ENV AGENT_WORKDIR="${AGENT_WORKDIR}"
85-
RUN mkdir /home/"${user}"/.jenkins && mkdir -p "${AGENT_WORKDIR}"
86+
RUN mkdir -p /home/"${user}"/.jenkins && mkdir -p "${AGENT_WORKDIR}"
8687

8788
VOLUME /home/"${user}"/.jenkins
8889
VOLUME "${AGENT_WORKDIR}"
@@ -96,3 +97,25 @@ LABEL \
9697
org.opencontainers.image.url="https://www.jenkins.io/" \
9798
org.opencontainers.image.source="https://github.com/jenkinsci/docker-agent" \
9899
org.opencontainers.image.licenses="MIT"
100+
101+
## Inbound Agent image target
102+
FROM agent AS inbound-agent
103+
104+
ARG user=jenkins
105+
106+
USER root
107+
COPY ../../jenkins-agent /usr/local/bin/jenkins-agent
108+
RUN chmod +x /usr/local/bin/jenkins-agent &&\
109+
ln -s /usr/local/bin/jenkins-agent /usr/local/bin/jenkins-slave
110+
USER ${user}
111+
112+
LABEL \
113+
org.opencontainers.image.vendor="Jenkins project" \
114+
org.opencontainers.image.title="Official Jenkins Agent Base Docker image" \
115+
org.opencontainers.image.description="This is an image for Jenkins agents using TCP or WebSockets to establish inbound connection to the Jenkins controller" \
116+
org.opencontainers.image.version="${VERSION}" \
117+
org.opencontainers.image.url="https://www.jenkins.io/" \
118+
org.opencontainers.image.source="https://github.com/jenkinsci/docker-agent" \
119+
org.opencontainers.image.licenses="MIT"
120+
121+
ENTRYPOINT ["/usr/local/bin/jenkins-agent"]

0 commit comments

Comments
 (0)