From 61fff8c9cda029b5bcba6df7aef91b9e7fe96ad5 Mon Sep 17 00:00:00 2001 From: Bervianto Leo Pratama Date: Thu, 13 Mar 2025 17:55:04 +0700 Subject: [PATCH 1/5] feat: add dotnet quickstart fix: fix build fix: fix context --- .github/dependabot.yml | 5 ++++ .github/labeler.yml | 6 +++++ .../workflows/github-docker-registry-push.yml | 10 ++++++++ docker-compose.yaml | 25 ++++++++++++++++++- dockerfiles/dotnet/Dockerfile | 22 ++++++++++++++++ 5 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 dockerfiles/dotnet/Dockerfile diff --git a/.github/dependabot.yml b/.github/dependabot.yml index a350a4d1..ba747743 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -58,3 +58,8 @@ updates: schedule: interval: weekly open-pull-requests-limit: 10 + - package-ecosystem: docker + directory: "./dockerfiles/dotnet" + schedule: + interval: weekly + open-pull-requests-limit: 10 diff --git a/.github/labeler.yml b/.github/labeler.yml index 6dbfec0c..97252803 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -52,3 +52,9 @@ multi: github_actions: - changed-files: - any-glob-to-any-file: '/.github/workflows/*' + + +# Add 'dotnet' label to any change to Dockerfile* files within the root dir +dotnet: + - changed-files: + - any-glob-to-any-file: 'dockerfiles/dotnet/**' diff --git a/.github/workflows/github-docker-registry-push.yml b/.github/workflows/github-docker-registry-push.yml index 02569763..15430e5c 100644 --- a/.github/workflows/github-docker-registry-push.yml +++ b/.github/workflows/github-docker-registry-push.yml @@ -214,3 +214,13 @@ jobs: platforms: linux/amd64, linux/aarch64 push: true tags: ghcr.io/${{ env.REPO_NAME }}/jenkinsci-tutorials:cpp_${{ env.BRANCH }} + + - name: Build and push the jenkins agent for dotnet tutorial + # This step builds and pushes the Jenkins agent for the C++ tutorial + if: contains(env.files, 'dockerfiles/dotnet/Dockerfile') + uses: docker/build-push-action@v6 + with: + context: ./dockerfiles/dotnet + platforms: linux/amd64, linux/aarch64 + push: true + tags: ghcr.io/${{ env.REPO_NAME }}/jenkinsci-tutorials:dotnet_${{ env.BRANCH }} diff --git a/docker-compose.yaml b/docker-compose.yaml index 4de602b9..0c34c62e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -35,6 +35,7 @@ services: - android - multi - golang + - dotnet - default # This service depends on the sidekick_service (generating SSH keys and JCasc token) completing successfully. depends_on: @@ -61,6 +62,7 @@ services: - android - golang - cpp + - dotnet - default # The CASC_RELOAD_TOKEN environment variable is used by the Jenkins controller to restart the Configuration as Code (JCasc) plugin configuration. environment: @@ -304,7 +306,28 @@ services: retries: 5 volumes: - 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 - + dotnet: + image: ${IMAGE_PREFIX}/${GHCR_USERNAME}/quickstart-tutorials/jenkinsci-tutorials:dotnet_${BRANCH_SUFFIX} + environment: + - GITPOD_WORKSPACE_URL=${GITPOD_WORKSPACE_URL} + container_name: desktop-jenkins_agent-1 + profiles: + - dotnet + depends_on: + sidekick_service: + condition: service_completed_successfully # Depends on the successful completion of the sidekick_service + jenkins_controller: + condition: service_started + ports: + - "5000:5000" + healthcheck: + test: ["CMD-SHELL", "[ -f /home/jenkins/.ssh/authorized_keys ] || exit 1"] + # Checks if the authorized_keys file exists in the /home/jenkins/.ssh path + interval: 5s + timeout: 10s + retries: 5 + volumes: + - 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 volumes: jenkins_home: null empty_jenkins_home: null diff --git a/dockerfiles/dotnet/Dockerfile b/dockerfiles/dotnet/Dockerfile new file mode 100644 index 00000000..92e856b5 --- /dev/null +++ b/dockerfiles/dotnet/Dockerfile @@ -0,0 +1,22 @@ +FROM jenkins/ssh-agent:6.10.0 AS ssh-agent + +# install dotnet dependencies +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 && \ + rm -rf /var/lib/apt/lists/* + +# Now time to install dotnet +ARG DOTNET_VERSION=8.0 + +# Set SHELL flags for RUN commands to allow -e and pipefail +# Rationale:https://github.com/hadolint/hadolint/wiki/DL4006 +SHELL ["/bin/bash", "-eo", "pipefail", "-c"] + +RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && chmod +x ./dotnet-install.sh && \ + ./dotnet-install.sh --channel ${DOTNET_VERSION} --install-dir /usr/local/dotnet + +ENV DOTNET_ROOT=/usr/local/dotnet +ENV PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools + +RUN echo "PATH=${PATH}" >> /etc/environment && chown -R jenkins:jenkins "${JENKINS_AGENT_HOME}" && \ + dotnet --list-sdks + From 162312cf97d5fdbecb953e95364c00273594636e Mon Sep 17 00:00:00 2001 From: Bervianto Leo Pratama Date: Thu, 13 Mar 2025 12:53:09 +0700 Subject: [PATCH 2/5] fix: add dotnet build --- build-docker-compose.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/build-docker-compose.yaml b/build-docker-compose.yaml index 36832739..a7db261a 100644 --- a/build-docker-compose.yaml +++ b/build-docker-compose.yaml @@ -25,6 +25,7 @@ services: - android - multi - golang + - dotnet - default # This service depends on the sidekick_service (generating SSH keys and JCasc token) completing successfully. depends_on: @@ -222,6 +223,25 @@ services: retries: 5 volumes: - agent-ssh-dir:/home/jenkins/.ssh:ro + dotnet: + build: dockerfiles/dotnet/. + container_name: desktop-jenkins_agent-1-dotnet + profiles: + - dotnet + depends_on: + sidekick_service: + condition: service_completed_successfully + jenkins_controller: + condition: service_started + ports: + - "5000:5000" + healthcheck: + test: ["CMD-SHELL", "[ -f /home/jenkins/.ssh/authorized_keys ] || exit 1"] + interval: 5s + timeout: 10s + retries: 5 + volumes: + - agent-ssh-dir:/home/jenkins/.ssh:ro volumes: jenkins_home: null agent-ssh-dir: From 564b8687d3bdd71936726ff3d921ef737b6c98ed Mon Sep 17 00:00:00 2001 From: Bervianto Leo Pratama Date: Thu, 13 Mar 2025 17:55:04 +0700 Subject: [PATCH 3/5] feat: add dotnet quickstart fix: fix build fix: fix context --- .github/dependabot.yml | 5 ++++ .github/labeler.yml | 6 +++++ .../workflows/github-docker-registry-push.yml | 10 ++++++++ docker-compose.yaml | 25 ++++++++++++++++++- dockerfiles/dotnet/Dockerfile | 22 ++++++++++++++++ 5 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 dockerfiles/dotnet/Dockerfile diff --git a/.github/dependabot.yml b/.github/dependabot.yml index a350a4d1..ba747743 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -58,3 +58,8 @@ updates: schedule: interval: weekly open-pull-requests-limit: 10 + - package-ecosystem: docker + directory: "./dockerfiles/dotnet" + schedule: + interval: weekly + open-pull-requests-limit: 10 diff --git a/.github/labeler.yml b/.github/labeler.yml index 6dbfec0c..97252803 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -52,3 +52,9 @@ multi: github_actions: - changed-files: - any-glob-to-any-file: '/.github/workflows/*' + + +# Add 'dotnet' label to any change to Dockerfile* files within the root dir +dotnet: + - changed-files: + - any-glob-to-any-file: 'dockerfiles/dotnet/**' diff --git a/.github/workflows/github-docker-registry-push.yml b/.github/workflows/github-docker-registry-push.yml index 02569763..15430e5c 100644 --- a/.github/workflows/github-docker-registry-push.yml +++ b/.github/workflows/github-docker-registry-push.yml @@ -214,3 +214,13 @@ jobs: platforms: linux/amd64, linux/aarch64 push: true tags: ghcr.io/${{ env.REPO_NAME }}/jenkinsci-tutorials:cpp_${{ env.BRANCH }} + + - name: Build and push the jenkins agent for dotnet tutorial + # This step builds and pushes the Jenkins agent for the C++ tutorial + if: contains(env.files, 'dockerfiles/dotnet/Dockerfile') + uses: docker/build-push-action@v6 + with: + context: ./dockerfiles/dotnet + platforms: linux/amd64, linux/aarch64 + push: true + tags: ghcr.io/${{ env.REPO_NAME }}/jenkinsci-tutorials:dotnet_${{ env.BRANCH }} diff --git a/docker-compose.yaml b/docker-compose.yaml index 4de602b9..0c34c62e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -35,6 +35,7 @@ services: - android - multi - golang + - dotnet - default # This service depends on the sidekick_service (generating SSH keys and JCasc token) completing successfully. depends_on: @@ -61,6 +62,7 @@ services: - android - golang - cpp + - dotnet - default # The CASC_RELOAD_TOKEN environment variable is used by the Jenkins controller to restart the Configuration as Code (JCasc) plugin configuration. environment: @@ -304,7 +306,28 @@ services: retries: 5 volumes: - 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 - + dotnet: + image: ${IMAGE_PREFIX}/${GHCR_USERNAME}/quickstart-tutorials/jenkinsci-tutorials:dotnet_${BRANCH_SUFFIX} + environment: + - GITPOD_WORKSPACE_URL=${GITPOD_WORKSPACE_URL} + container_name: desktop-jenkins_agent-1 + profiles: + - dotnet + depends_on: + sidekick_service: + condition: service_completed_successfully # Depends on the successful completion of the sidekick_service + jenkins_controller: + condition: service_started + ports: + - "5000:5000" + healthcheck: + test: ["CMD-SHELL", "[ -f /home/jenkins/.ssh/authorized_keys ] || exit 1"] + # Checks if the authorized_keys file exists in the /home/jenkins/.ssh path + interval: 5s + timeout: 10s + retries: 5 + volumes: + - 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 volumes: jenkins_home: null empty_jenkins_home: null diff --git a/dockerfiles/dotnet/Dockerfile b/dockerfiles/dotnet/Dockerfile new file mode 100644 index 00000000..92e856b5 --- /dev/null +++ b/dockerfiles/dotnet/Dockerfile @@ -0,0 +1,22 @@ +FROM jenkins/ssh-agent:6.10.0 AS ssh-agent + +# install dotnet dependencies +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 && \ + rm -rf /var/lib/apt/lists/* + +# Now time to install dotnet +ARG DOTNET_VERSION=8.0 + +# Set SHELL flags for RUN commands to allow -e and pipefail +# Rationale:https://github.com/hadolint/hadolint/wiki/DL4006 +SHELL ["/bin/bash", "-eo", "pipefail", "-c"] + +RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && chmod +x ./dotnet-install.sh && \ + ./dotnet-install.sh --channel ${DOTNET_VERSION} --install-dir /usr/local/dotnet + +ENV DOTNET_ROOT=/usr/local/dotnet +ENV PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools + +RUN echo "PATH=${PATH}" >> /etc/environment && chown -R jenkins:jenkins "${JENKINS_AGENT_HOME}" && \ + dotnet --list-sdks + From 014922ec7531414cdd87153afee8730a0416dba6 Mon Sep 17 00:00:00 2001 From: Bervianto Leo Pratama Date: Thu, 13 Mar 2025 12:53:09 +0700 Subject: [PATCH 4/5] fix: add dotnet build --- build-docker-compose.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/build-docker-compose.yaml b/build-docker-compose.yaml index 36832739..a7db261a 100644 --- a/build-docker-compose.yaml +++ b/build-docker-compose.yaml @@ -25,6 +25,7 @@ services: - android - multi - golang + - dotnet - default # This service depends on the sidekick_service (generating SSH keys and JCasc token) completing successfully. depends_on: @@ -222,6 +223,25 @@ services: retries: 5 volumes: - agent-ssh-dir:/home/jenkins/.ssh:ro + dotnet: + build: dockerfiles/dotnet/. + container_name: desktop-jenkins_agent-1-dotnet + profiles: + - dotnet + depends_on: + sidekick_service: + condition: service_completed_successfully + jenkins_controller: + condition: service_started + ports: + - "5000:5000" + healthcheck: + test: ["CMD-SHELL", "[ -f /home/jenkins/.ssh/authorized_keys ] || exit 1"] + interval: 5s + timeout: 10s + retries: 5 + volumes: + - agent-ssh-dir:/home/jenkins/.ssh:ro volumes: jenkins_home: null agent-ssh-dir: From cd360edccc80daf5e8f66865b1db309b3fd0bf63 Mon Sep 17 00:00:00 2001 From: Bervianto Leo Pratama Date: Thu, 13 Mar 2025 14:50:41 +0700 Subject: [PATCH 5/5] feat: add coverage plugin for showing the coverage --- dockerfiles/plugins.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dockerfiles/plugins.txt b/dockerfiles/plugins.txt index c98fd29a..0d246bd0 100644 --- a/dockerfiles/plugins.txt +++ b/dockerfiles/plugins.txt @@ -11,6 +11,7 @@ cloudbees-folder:6.985.va_f1635030cc5 commons-lang3-api:3.17.0-84.vb_b_938040b_078 commons-text-api:1.13.0-153.v91dcd89e2a_22 configuration-as-code:1932.v75cb_b_f1b_698d +coverage:2.2.0 credentials-binding:687.v619cb_15e923f credentials:1408.va_622a_b_f5b_1b_1 display-url-api:2.209.v582ed814ff2f