Skip to content

Commit d55f053

Browse files
authored
feat: add dotnet agent (#1057)
* feat: add dotnet quickstart fix: fix build fix: fix context * fix: add dotnet build * feat: add coverage plugin for showing the coverage * feat: add dotnet quickstart fix: fix build fix: fix context * fix: add dotnet build
1 parent 6a802c6 commit d55f053

File tree

7 files changed

+88
-1
lines changed

7 files changed

+88
-1
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,8 @@ updates:
5858
schedule:
5959
interval: weekly
6060
open-pull-requests-limit: 10
61+
- package-ecosystem: docker
62+
directory: "./dockerfiles/dotnet"
63+
schedule:
64+
interval: weekly
65+
open-pull-requests-limit: 10

.github/labeler.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,9 @@ multi:
5252
github_actions:
5353
- changed-files:
5454
- any-glob-to-any-file: '/.github/workflows/*'
55+
56+
57+
# Add 'dotnet' label to any change to Dockerfile* files within the root dir
58+
dotnet:
59+
- changed-files:
60+
- any-glob-to-any-file: 'dockerfiles/dotnet/**'

.github/workflows/github-docker-registry-push.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,13 @@ jobs:
214214
platforms: linux/amd64, linux/aarch64
215215
push: true
216216
tags: ghcr.io/${{ env.REPO_NAME }}/jenkinsci-tutorials:cpp_${{ env.BRANCH }}
217+
218+
- name: Build and push the jenkins agent for dotnet tutorial
219+
# This step builds and pushes the Jenkins agent for the C++ tutorial
220+
if: contains(env.files, 'dockerfiles/dotnet/Dockerfile')
221+
uses: docker/build-push-action@v6
222+
with:
223+
context: ./dockerfiles/dotnet
224+
platforms: linux/amd64, linux/aarch64
225+
push: true
226+
tags: ghcr.io/${{ env.REPO_NAME }}/jenkinsci-tutorials:dotnet_${{ env.BRANCH }}

build-docker-compose.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ services:
2525
- android
2626
- multi
2727
- golang
28+
- dotnet
2829
- default
2930
# This service depends on the sidekick_service (generating SSH keys and JCasc token) completing successfully.
3031
depends_on:
@@ -222,6 +223,25 @@ services:
222223
retries: 5
223224
volumes:
224225
- agent-ssh-dir:/home/jenkins/.ssh:ro
226+
dotnet:
227+
build: dockerfiles/dotnet/.
228+
container_name: desktop-jenkins_agent-1-dotnet
229+
profiles:
230+
- dotnet
231+
depends_on:
232+
sidekick_service:
233+
condition: service_completed_successfully
234+
jenkins_controller:
235+
condition: service_started
236+
ports:
237+
- "5000:5000"
238+
healthcheck:
239+
test: ["CMD-SHELL", "[ -f /home/jenkins/.ssh/authorized_keys ] || exit 1"]
240+
interval: 5s
241+
timeout: 10s
242+
retries: 5
243+
volumes:
244+
- agent-ssh-dir:/home/jenkins/.ssh:ro
225245
volumes:
226246
jenkins_home: null
227247
agent-ssh-dir:

docker-compose.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ services:
3535
- android
3636
- multi
3737
- golang
38+
- dotnet
3839
- default
3940
# This service depends on the sidekick_service (generating SSH keys and JCasc token) completing successfully.
4041
depends_on:
@@ -61,6 +62,7 @@ services:
6162
- android
6263
- golang
6364
- cpp
65+
- dotnet
6466
- default
6567
# The CASC_RELOAD_TOKEN environment variable is used by the Jenkins controller to restart the Configuration as Code (JCasc) plugin configuration.
6668
environment:
@@ -304,7 +306,28 @@ services:
304306
retries: 5
305307
volumes:
306308
- agent-ssh-dir:/home/jenkins/.ssh:ro # Mounts the agent-ssh-dir volume to the /home/jenkins/.ssh path inside the container as read-only
307-
309+
dotnet:
310+
image: ${IMAGE_PREFIX}/${GHCR_USERNAME}/quickstart-tutorials/jenkinsci-tutorials:dotnet_${BRANCH_SUFFIX}
311+
environment:
312+
- GITPOD_WORKSPACE_URL=${GITPOD_WORKSPACE_URL}
313+
container_name: desktop-jenkins_agent-1
314+
profiles:
315+
- dotnet
316+
depends_on:
317+
sidekick_service:
318+
condition: service_completed_successfully # Depends on the successful completion of the sidekick_service
319+
jenkins_controller:
320+
condition: service_started
321+
ports:
322+
- "5000:5000"
323+
healthcheck:
324+
test: ["CMD-SHELL", "[ -f /home/jenkins/.ssh/authorized_keys ] || exit 1"]
325+
# Checks if the authorized_keys file exists in the /home/jenkins/.ssh path
326+
interval: 5s
327+
timeout: 10s
328+
retries: 5
329+
volumes:
330+
- agent-ssh-dir:/home/jenkins/.ssh:ro # Mounts the agent-ssh-dir volume to the /home/jenkins/.ssh path inside the container as read-only
308331
volumes:
309332
jenkins_home: null
310333
empty_jenkins_home: null

dockerfiles/dotnet/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM jenkins/ssh-agent:6.10.0 AS ssh-agent
2+
3+
# install dotnet dependencies
4+
RUN apt-get update && apt-get install -y --no-install-recommends libc6 libgcc1 libgssapi-krb5-2 libicu72 libssl3 libstdc++6 zlib1g wget && apt-get clean && \
5+
rm -rf /var/lib/apt/lists/*
6+
7+
# Now time to install dotnet
8+
ARG DOTNET_VERSION=8.0
9+
10+
# Set SHELL flags for RUN commands to allow -e and pipefail
11+
# Rationale:https://github.com/hadolint/hadolint/wiki/DL4006
12+
SHELL ["/bin/bash", "-eo", "pipefail", "-c"]
13+
14+
RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && chmod +x ./dotnet-install.sh && \
15+
./dotnet-install.sh --channel ${DOTNET_VERSION} --install-dir /usr/local/dotnet
16+
17+
ENV DOTNET_ROOT=/usr/local/dotnet
18+
ENV PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools
19+
20+
RUN echo "PATH=${PATH}" >> /etc/environment && chown -R jenkins:jenkins "${JENKINS_AGENT_HOME}" && \
21+
dotnet --list-sdks
22+

dockerfiles/plugins.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ cloudbees-folder:6.985.va_f1635030cc5
1111
commons-lang3-api:3.17.0-84.vb_b_938040b_078
1212
commons-text-api:1.13.0-153.v91dcd89e2a_22
1313
configuration-as-code:1932.v75cb_b_f1b_698d
14+
coverage:2.2.0
1415
credentials-binding:687.v619cb_15e923f
1516
credentials:1408.va_622a_b_f5b_1b_1
1617
display-url-api:2.209.v582ed814ff2f

0 commit comments

Comments
 (0)