Skip to content

Commit bd6b06e

Browse files
gounthardependabot[bot]actions-user
authored
Add C++ profile to Docker Compose and Updatecli (#1004)
* chore(deps): bump debian in /dockerfiles/sidekick Bumps debian from bookworm-20231218 to bookworm-20240110. --- updated-dependencies: - dependency-name: debian dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(deps): bump updatecli/updatecli-action from 2.52.0 to 2.53.0 Bumps [updatecli/updatecli-action](https://github.com/updatecli/updatecli-action) from 2.52.0 to 2.53.0. - [Release notes](https://github.com/updatecli/updatecli-action/releases) - [Commits](updatecli/updatecli-action@v2.52.0...v2.53.0) --- updated-dependencies: - dependency-name: updatecli/updatecli-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): bump anchore/scan-action from 3.5.0 to 3.6.0 Bumps [anchore/scan-action](https://github.com/anchore/scan-action) from 3.5.0 to 3.6.0. - [Release notes](https://github.com/anchore/scan-action/releases) - [Changelog](https://github.com/anchore/scan-action/blob/main/CHANGELOG.md) - [Commits](anchore/scan-action@1d59d90...0550541) --- updated-dependencies: - dependency-name: anchore/scan-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * chore(jenkins): Update Jenkins plugins * chore(deps): bump updatecli/updatecli-action from 2.53.0 to 2.54.0 Bumps [updatecli/updatecli-action](https://github.com/updatecli/updatecli-action) from 2.53.0 to 2.54.0. - [Release notes](https://github.com/updatecli/updatecli-action/releases) - [Commits](updatecli/updatecli-action@v2.53.0...v2.54.0) --- updated-dependencies: - dependency-name: updatecli/updatecli-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): bump debian in /dockerfiles/sidekick Bumps debian from bookworm-20240110 to bookworm-20240130. --- updated-dependencies: - dependency-name: debian dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): bump jenkins/ssh-agent in /dockerfiles/python Bumps jenkins/ssh-agent from 5.22.0 to 5.24.0. --- updated-dependencies: - dependency-name: jenkins/ssh-agent dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): bump jenkins/ssh-agent in /dockerfiles/android Bumps jenkins/ssh-agent from 5.22.0 to 5.24.0. --- updated-dependencies: - dependency-name: jenkins/ssh-agent dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): bump jenkins/ssh-agent in /dockerfiles/maven Bumps jenkins/ssh-agent from 5.22.0 to 5.24.0. --- updated-dependencies: - dependency-name: jenkins/ssh-agent dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): bump release-drafter/release-drafter from 5 to 6 Bumps [release-drafter/release-drafter](https://github.com/release-drafter/release-drafter) from 5 to 6. - [Release notes](https://github.com/release-drafter/release-drafter/releases) - [Commits](release-drafter/release-drafter@v5...v6) --- updated-dependencies: - dependency-name: release-drafter/release-drafter dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): bump anchore/scan-action from 3.6.0 to 3.6.4 Bumps [anchore/scan-action](https://github.com/anchore/scan-action) from 3.6.0 to 3.6.4. - [Release notes](https://github.com/anchore/scan-action/releases) - [Changelog](https://github.com/anchore/scan-action/blob/main/CHANGELOG.md) - [Commits](anchore/scan-action@0550541...3343887) --- updated-dependencies: - dependency-name: anchore/scan-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): bump jenkins/ssh-agent in /dockerfiles/multi Bumps jenkins/ssh-agent from 5.22.0 to 5.24.0. --- updated-dependencies: - dependency-name: jenkins/ssh-agent dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): bump jenkins/ssh-agent in /dockerfiles/node Bumps jenkins/ssh-agent from 5.22.0 to 5.24.0. --- updated-dependencies: - dependency-name: jenkins/ssh-agent dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): bump codacy/codacy-analysis-cli-action from 4.3.0 to 4.4.0 Bumps [codacy/codacy-analysis-cli-action](https://github.com/codacy/codacy-analysis-cli-action) from 4.3.0 to 4.4.0. - [Release notes](https://github.com/codacy/codacy-analysis-cli-action/releases) - [Commits](codacy/codacy-analysis-cli-action@5cc54a7...33d4559) --- updated-dependencies: - dependency-name: codacy/codacy-analysis-cli-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(deps): bump debian in /dockerfiles/sidekick Bumps debian from bookworm-20240130 to bookworm-20240211. --- updated-dependencies: - dependency-name: debian dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): bump updatecli/updatecli-action from 2.54.0 to 2.55.0 (#114) * chore(deps): bump jenkins/ssh-agent in /dockerfiles/multi (#115) * chore(deps): bump jenkins/ssh-agent in /dockerfiles/node (#116) * chore(deps): bump jenkins/ssh-agent in /dockerfiles/android (#117) * chore(deps): bump jenkins/ssh-agent in /dockerfiles/maven (#118) * chore(deps): bump jenkins/ssh-agent in /dockerfiles/python (#119) * chore(jenkins): Update Jenkins plugins * Multi controller is the same as simple controller * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(deps): Bump debian in /dockerfiles/sidekick Bumps debian from bookworm-20240311 to bookworm-20240408. --- updated-dependencies: - dependency-name: debian dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * chore(jenkins): Update Jenkins plugins * chore(deps): bump codacy/codacy-analysis-cli-action from 4.4.0 to 4.4.1 Bumps [codacy/codacy-analysis-cli-action](https://github.com/codacy/codacy-analysis-cli-action) from 4.4.0 to 4.4.1. - [Release notes](https://github.com/codacy/codacy-analysis-cli-action/releases) - [Commits](codacy/codacy-analysis-cli-action@33d4559...3ff8e64) --- updated-dependencies: - dependency-name: codacy/codacy-analysis-cli-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): bump updatecli/updatecli-action from 2.57.0 to 2.58.0 Bumps [updatecli/updatecli-action](https://github.com/updatecli/updatecli-action) from 2.57.0 to 2.58.0. - [Release notes](https://github.com/updatecli/updatecli-action/releases) - [Commits](updatecli/updatecli-action@v2.57.0...v2.58.0) --- updated-dependencies: - dependency-name: updatecli/updatecli-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(deps): bump updatecli/updatecli-action from 2.58.0 to 2.59.0 Bumps [updatecli/updatecli-action](https://github.com/updatecli/updatecli-action) from 2.58.0 to 2.59.0. - [Release notes](https://github.com/updatecli/updatecli-action/releases) - [Commits](updatecli/updatecli-action@v2.58.0...v2.59.0) --- updated-dependencies: - dependency-name: updatecli/updatecli-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Update Docker versions * Not to be lost. * not to be lost * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * chore(jenkins): Update Jenkins plugins * Add C++ profile to Docker Compose and Updatecli Fixes #376 Add a new profile in the Docker Compose file for building C++ source code with Jenkins. * **Docker Compose Files:** * Add a `cpp` profile in `docker-compose.yaml` and `build-docker-compose.yaml`. * Include necessary service definitions, dependencies, healthcheck, and volume configurations. * **Dockerfile:** * Create `dockerfiles/cpp/Dockerfile` with necessary C++ build tools including `build-essential`, `cmake`, `gcc`, `g++`, `clang`, `make`, `libstdc++-dev`, and `pkg-config`. * Set environment variables and ensure ownership of the Jenkins agent home directory. * **Updatecli Manifest:** * Add `updatecli/updatecli.d/cpp.yaml` for managing the C++ Dockerfile. * Ensure the manifest includes the necessary dependencies for the C++ build environment. * **GitHub Actions:** * Modify `.github/workflows/github-docker-registry-push.yml` to add a new job for building and pushing the C++ Docker image to ghcr. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/gounthar/quickstart-tutorials/issues/376?shareId=XXXX-XXXX-XXXX-XXXX). * fix(updatecli): Removed cpp manifest. * fix(docker): Update libstdc++ dependency to libstdc++-12-dev * feat(jenkins): Add cpp-agent configuration for Docker image in ssh-agent.yaml --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: GitHub Action <[email protected]>
1 parent ebc47f5 commit bd6b06e

File tree

6 files changed

+124
-0
lines changed

6 files changed

+124
-0
lines changed

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

+10
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,13 @@ jobs:
204204
platforms: linux/amd64, linux/arm64
205205
push: true
206206
tags: ghcr.io/${{ env.REPO_NAME }}/jenkinsci-tutorials:golang_${{ env.BRANCH }}
207+
208+
- name: Build and push the jenkins agent for cpp tutorial
209+
# This step builds and pushes the Jenkins agent for the C++ tutorial
210+
if: contains(env.files, 'dockerfiles/cpp/Dockerfile')
211+
uses: docker/build-push-action@v6
212+
with:
213+
context: ./dockerfiles/cpp
214+
platforms: linux/amd64, linux/aarch64
215+
push: true
216+
tags: ghcr.io/${{ env.REPO_NAME }}/jenkinsci-tutorials:cpp_agent_${{ env.BRANCH }}

build-docker-compose.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,23 @@ services:
205205
retries: 5
206206
volumes:
207207
- 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
208+
cpp:
209+
build: dockerfiles/cpp/.
210+
container_name: desktop-jenkins_agent-1-cpp
211+
profiles:
212+
- cpp
213+
depends_on:
214+
sidekick_service:
215+
condition: service_completed_successfully
216+
jenkins_controller:
217+
condition: service_started
218+
healthcheck:
219+
test: ["CMD-SHELL", "[ -f /home/jenkins/.ssh/authorized_keys ] || exit 1"]
220+
interval: 5s
221+
timeout: 10s
222+
retries: 5
223+
volumes:
224+
- agent-ssh-dir:/home/jenkins/.ssh:ro
208225
volumes:
209226
jenkins_home: null
210227
agent-ssh-dir:

docker-compose.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,23 @@ services:
281281
retries: 5
282282
volumes:
283283
- 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
284+
cpp:
285+
image: ${IMAGE_PREFIX}/${GHCR_USERNAME}/quickstart-tutorials/jenkinsci-tutorials:cpp_agent_${BRANCH_SUFFIX}
286+
container_name: desktop-jenkins_agent-1-cpp
287+
profiles:
288+
- cpp
289+
depends_on:
290+
sidekick_service:
291+
condition: service_completed_successfully
292+
jenkins_controller:
293+
condition: service_started
294+
healthcheck:
295+
test: ["CMD-SHELL", "[ -f /home/jenkins/.ssh/authorized_keys ] || exit 1"]
296+
interval: 5s
297+
timeout: 10s
298+
retries: 5
299+
volumes:
300+
- agent-ssh-dir:/home/jenkins/.ssh:ro
284301
volumes:
285302
jenkins_home: null
286303
empty_jenkins_home: null

dockerfiles/cpp/Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM jenkins/ssh-agent:6.9.0
2+
3+
# Install necessary C++ build tools
4+
RUN apt-get update && apt-get install -y --no-install-recommends \
5+
build-essential \
6+
cmake \
7+
gcc \
8+
g++ \
9+
clang \
10+
make \
11+
libstdc++-12-dev \
12+
pkg-config \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
# Set environment variables
16+
ENV PATH="/usr/local/bin:$PATH"
17+
18+
# Ensure the ownership of the Jenkins agent home directory is set to the Jenkins user
19+
RUN chown -R jenkins:jenkins "${JENKINS_AGENT_HOME}"

extract-profiles.sh

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
set -e
3+
4+
original_file="docker-compose.yaml"
5+
6+
# Function to add a service and its dependencies to the included_services list
7+
add_service_and_dependencies() {
8+
local service=$1
9+
# Mark the service as included
10+
included_services["$service"]=1
11+
# Check if the service has dependencies
12+
if yq e ".services.${service}.depends_on" "$original_file" -e > /dev/null; then
13+
# Read dependencies of the service
14+
local dependencies=($(yq e ".services.${service}.depends_on | keys" "$original_file" -o json | jq -r '.[]'))
15+
# Recursively add dependencies
16+
for dependency in "${dependencies[@]}"; do
17+
if [[ -z "${included_services["$dependency"]}" ]]; then
18+
add_service_and_dependencies "$dependency"
19+
fi
20+
done
21+
fi
22+
}
23+
24+
# Step 1: Collect all dependencies
25+
declare -A all_dependencies
26+
services=$(yq e '.services | keys' "$original_file" -o json | jq -r '.[]')
27+
for service in $services; do
28+
dependencies=$(yq e ".services.$service.depends_on | keys" "$original_file" -o json | jq -r '.[]')
29+
for dependency in $dependencies; do
30+
all_dependencies["$dependency"]=1
31+
done
32+
done
33+
34+
# Step 2: Process each profile and include dependencies
35+
for profile in $(yq e '.services[].profiles[]?' "$original_file" | sort -u); do
36+
echo "Processing profile: $profile"
37+
# Initialize an associative array to track included services
38+
declare -A included_services
39+
# Find and include services matching the profile
40+
matching_services=$(yq e ".services | with_entries(select(.value.profiles[]? == \"$profile\")) | keys" "$original_file" -o json | jq -r '.[]')
41+
for service in $matching_services; do
42+
add_service_and_dependencies "$service"
43+
done
44+
# Correctly format the list of included services for yq query
45+
included_services_keys=$(printf "'%s'," "${!included_services[@]}")
46+
included_services_keys="[${included_services_keys%,}]" # Remove trailing comma and wrap in brackets
47+
48+
# Generate the docker-compose file for the profile
49+
echo "Generating docker-compose-$profile.yaml"
50+
yq e ".services | with_entries(select(.key as \$k | .key == \"$included_services_list\"))" "$original_file" > "docker-compose-$profile.yaml"
51+
done

updatecli/updatecli.d/ssh-agent.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ targets:
8585
matcher: jenkins/ssh-agent
8686
sourceid: jenkins/ssh-agent
8787
scmid: default
88+
jenkins/cpp-agent:
89+
name: '[jenkins/ssh-agent] Bump Docker image tag in "dockerfiles/cpp/Dockerfile"'
90+
kind: dockerfile
91+
spec:
92+
file: dockerfiles/cpp/Dockerfile
93+
instruction:
94+
keyword: FROM
95+
matcher: jenkins/ssh-agent
96+
sourceid: jenkins/ssh-agent
97+
scmid: default
8898
default-agent:
8999
name: '[jenkins/ssh-agent] Bump Docker image tag in "docker-compose.yaml"'
90100
kind: yaml

0 commit comments

Comments
 (0)