Skip to content

Commit 8f27a4e

Browse files
committed
feat: build both agent and inbound-agent images
1 parent ab173cf commit 8f27a4e

19 files changed

+563
-380
lines changed

.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: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ 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-
1513
# 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
14+
# Set their value to "skip" to skip corresponding tests
15+
# default is "all test suites in the "tests/" directories
16+
TEST_SUITES_AGENT ?= $(CURDIR)/tests/tests_agent.bats
17+
TEST_SUITES_INBOUND_AGENT ?= $(CURDIR)/tests/tests_inbound-agent.bats
1818

1919
##### Macros
2020
## Check the presence of a CLI in the current PATH
@@ -42,6 +42,7 @@ build: check-reqs
4242

4343
build-%:
4444
@$(call check_image,$*)
45+
@echo "== building $*"
4546
@set -x; $(bake_base_cli) --set '*.platform=linux/$(ARCH)' '$*'
4647

4748
show:
@@ -59,7 +60,7 @@ prepare-test: bats check-reqs
5960

6061
## Define bats options based on environment
6162
# common flags for all tests
62-
bats_flags := $(TEST_SUITES)
63+
bats_flags := ""
6364
# if DISABLE_PARALLEL_TESTS true, then disable parallel execution
6465
ifneq (true,$(DISABLE_PARALLEL_TESTS))
6566
# If the GNU 'parallel' command line is absent, then disable parallel execution
@@ -75,9 +76,14 @@ test-%: prepare-test
7576
@$(call check_image,$*)
7677
# Ensure that the image is built
7778
@make --silent build-$*
78-
# Execute the test harness and write result to a TAP file
79+
@echo "== testing $*"
7980
set -x
80-
IMAGE=$* bats/bin/bats $(bats_flags) | tee target/results-$*.tap
81+
@if [[ $* == agent_* ]] && [[ $(TEST_SUITES_AGENT) != skip ]]; then \
82+
IMAGE=$* bats/bin/bats $(TEST_SUITES_AGENT) $(bats_flags) | tee target/results-$*.tap; \
83+
fi
84+
@if [[ $* == inbound-agent_* ]] && [[ $(TEST_SUITES_INBOUND_AGENT) != skip ]]; then \
85+
IMAGE=$* bats/bin/bats $(TEST_SUITES_INBOUND_AGENT) $(bats_flags) | tee target/results-$*.tap; \
86+
fi
8187
# convert TAP to JUNIT
8288
docker run --rm -v "$(CURDIR)":/usr/src/app -w /usr/src/app node:16-alpine \
8389
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)