Skip to content

Commit

Permalink
Add metadata labels (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
timja authored Sep 13, 2021
1 parent eea0278 commit 0341117
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 5 deletions.
9 changes: 9 additions & 0 deletions 11/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,12 @@ RUN mkdir /home/${user}/.jenkins && mkdir -p ${AGENT_WORKDIR}
VOLUME /home/${user}/.jenkins
VOLUME ${AGENT_WORKDIR}
WORKDIR /home/${user}

LABEL \
org.opencontainers.image.vendor="Jenkins project" \
org.opencontainers.image.title="Official Jenkins Agent Base Docker image" \
org.opencontainers.image.description="This is a base image, which provides the Jenkins agent executable (agent.jar)" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.url="https://www.jenkins.io/" \
org.opencontainers.image.source="/~https://github.com/jenkinsci/docker-agent" \
org.opencontainers.image.licenses="MIT"
9 changes: 9 additions & 0 deletions 11/archlinux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,12 @@ RUN mkdir /home/${user}/.jenkins && mkdir -p ${AGENT_WORKDIR}
VOLUME /home/${user}/.jenkins
VOLUME ${AGENT_WORKDIR}
WORKDIR /home/${user}

LABEL \
org.opencontainers.image.vendor="Jenkins project" \
org.opencontainers.image.title="Official Jenkins Agent Base Docker image" \
org.opencontainers.image.description="This is a base image, which provides the Jenkins agent executable (agent.jar)" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.url="https://www.jenkins.io/" \
org.opencontainers.image.source="/~https://github.com/jenkinsci/docker-agent" \
org.opencontainers.image.licenses="MIT"
9 changes: 9 additions & 0 deletions 11/bullseye/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,12 @@ RUN mkdir /home/${user}/.jenkins && mkdir -p ${AGENT_WORKDIR}
VOLUME /home/${user}/.jenkins
VOLUME ${AGENT_WORKDIR}
WORKDIR /home/${user}

LABEL \
org.opencontainers.image.vendor="Jenkins project" \
org.opencontainers.image.title="Official Jenkins Agent Base Docker image" \
org.opencontainers.image.description="This is a base image, which provides the Jenkins agent executable (agent.jar)" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.url="https://www.jenkins.io/" \
org.opencontainers.image.source="/~https://github.com/jenkinsci/docker-agent" \
org.opencontainers.image.licenses="MIT"
9 changes: 9 additions & 0 deletions 11/windows/nanoserver-1809/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,12 @@ RUN New-Item -Type Directory $('{0}/.jenkins' -f $env:AGENT_ROOT) | Out-Null ; `
VOLUME ${AGENT_ROOT}/.jenkins
VOLUME ${AGENT_WORKDIR}
WORKDIR ${AGENT_ROOT}

LABEL `
org.opencontainers.image.vendor="Jenkins project" `
org.opencontainers.image.title="Official Jenkins Agent Base Docker image" `
org.opencontainers.image.description="This is a base image, which provides the Jenkins agent executable (agent.jar)" `
org.opencontainers.image.version="${VERSION}" `
org.opencontainers.image.url="https://www.jenkins.io/" `
org.opencontainers.image.source="/~https://github.com/jenkinsci/docker-agent" `
org.opencontainers.image.licenses="MIT"
9 changes: 9 additions & 0 deletions 11/windows/windowsservercore-ltsc2019/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,12 @@ RUN New-Item -Type Directory $('{0}/.jenkins' -f $env:AGENT_ROOT) | Out-Null ; `
VOLUME ${AGENT_ROOT}/.jenkins
VOLUME ${AGENT_WORKDIR}
WORKDIR ${AGENT_ROOT}

LABEL `
org.opencontainers.image.vendor="Jenkins project" `
org.opencontainers.image.title="Official Jenkins Agent Base Docker image" `
org.opencontainers.image.description="This is a base image, which provides the Jenkins agent executable (agent.jar)" `
org.opencontainers.image.version="${VERSION}" `
org.opencontainers.image.url="https://www.jenkins.io/" `
org.opencontainers.image.source="/~https://github.com/jenkinsci/docker-agent" `
org.opencontainers.image.licenses="MIT"
9 changes: 9 additions & 0 deletions 8/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,12 @@ RUN mkdir /home/${user}/.jenkins && mkdir -p ${AGENT_WORKDIR}
VOLUME /home/${user}/.jenkins
VOLUME ${AGENT_WORKDIR}
WORKDIR /home/${user}

LABEL \
org.opencontainers.image.vendor="Jenkins project" \
org.opencontainers.image.title="Official Jenkins Agent Base Docker image" \
org.opencontainers.image.description="This is a base image, which provides the Jenkins agent executable (agent.jar)" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.url="https://www.jenkins.io/" \
org.opencontainers.image.source="/~https://github.com/jenkinsci/docker-agent" \
org.opencontainers.image.licenses="MIT"
9 changes: 9 additions & 0 deletions 8/bullseye/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,12 @@ RUN mkdir /home/${user}/.jenkins && mkdir -p ${AGENT_WORKDIR}
VOLUME /home/${user}/.jenkins
VOLUME ${AGENT_WORKDIR}
WORKDIR /home/${user}

LABEL \
org.opencontainers.image.vendor="Jenkins project" \
org.opencontainers.image.title="Official Jenkins Agent Base Docker image" \
org.opencontainers.image.description="This is a base image, which provides the Jenkins agent executable (agent.jar)" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.url="https://www.jenkins.io/" \
org.opencontainers.image.source="/~https://github.com/jenkinsci/docker-agent" \
org.opencontainers.image.licenses="MIT"
9 changes: 9 additions & 0 deletions 8/windows/windowsservercore-ltsc2019/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,12 @@ RUN New-Item -Type Directory $('{0}/.jenkins' -f $env:AGENT_ROOT) | Out-Null ; `
VOLUME ${AGENT_ROOT}/.jenkins
VOLUME ${AGENT_WORKDIR}
WORKDIR ${AGENT_ROOT}

LABEL `
org.opencontainers.image.vendor="Jenkins project" `
org.opencontainers.image.title="Official Jenkins Agent Base Docker image" `
org.opencontainers.image.description="This is a base image, which provides the Jenkins agent executable (agent.jar)" `
org.opencontainers.image.version="${VERSION}" `
org.opencontainers.image.url="https://www.jenkins.io/" `
org.opencontainers.image.source="/~https://github.com/jenkinsci/docker-agent" `
org.opencontainers.image.licenses="MIT"
10 changes: 5 additions & 5 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ target "archlinux_jdk11" {
dockerfile = "11/archlinux/Dockerfile"
context = "."
args = {
REMOTING_VERSION = REMOTING_VERSION
VERSION = REMOTING_VERSION
}
tags = [
equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${REMOTING_VERSION}-${BUILD_NUMBER}-archlinux": "",
Expand All @@ -71,7 +71,7 @@ target "alpine_jdk8" {
dockerfile = "8/alpine/Dockerfile"
context = "."
args = {
REMOTING_VERSION = REMOTING_VERSION
VERSION = REMOTING_VERSION
}
tags = [
equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${REMOTING_VERSION}-${BUILD_NUMBER}-alpine-jdk8": "",
Expand All @@ -85,7 +85,7 @@ target "alpine_jdk11" {
dockerfile = "11/alpine/Dockerfile"
context = "."
args = {
REMOTING_VERSION = REMOTING_VERSION
VERSION = REMOTING_VERSION
}
tags = [
equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${REMOTING_VERSION}-${BUILD_NUMBER}-alpine": "",
Expand All @@ -102,7 +102,7 @@ target "debian_jdk8" {
dockerfile = "8/bullseye/Dockerfile"
context = "."
args = {
REMOTING_VERSION = REMOTING_VERSION
VERSION = REMOTING_VERSION
}
tags = [
equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${REMOTING_VERSION}-${BUILD_NUMBER}-jdk8": "",
Expand All @@ -118,7 +118,7 @@ target "debian_jdk11" {
dockerfile = "11/bullseye/Dockerfile"
context = "."
args = {
REMOTING_VERSION = REMOTING_VERSION
VERSION = REMOTING_VERSION
}
tags = [
equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${REMOTING_VERSION}-${BUILD_NUMBER}": "",
Expand Down
6 changes: 6 additions & 0 deletions tests/agent.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ Describe "[$global:JDK $global:FLAVOR] use build args correctly" {
$exitCode | Should -Be 0
}

It 'version in docker metadata' {
$exitCode, $stdout, $stderr = Run-Program 'docker.exe' "inspect -f `"{{index .Config.Labels \`"org.opencontainers.image.version\`"}}`" $global:AGENT_IMAGE"
$exitCode | Should -Be 0
$stdout.Trim() | Should -Match $TEST_VERSION
}

AfterAll {
Pop-Location -StackName 'agent'
Cleanup($global:AGENT_CONTAINER)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ function get_sut_image {
make --silent show | jq -r ".target.${IMAGE}.tags[0]"
}

function get_remoting_version() {
test -n "${IMAGE:?"[sut_image] Please set the variable 'IMAGE' to the name of the image to test in 'docker-bake.hcl'."}"

make --silent show | jq -r ".target.${IMAGE}.args.VERSION"
}

function cleanup {
docker kill "$1" &>/dev/null ||:
docker rm -fv "$1" &>/dev/null ||:
Expand Down
10 changes: 10 additions & 0 deletions tests/tests.bats
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ SUT_IMAGE=$(get_sut_image)

ARCH=${ARCH:-x86_64}

@test "[${SUT_IMAGE}] test version in docker metadata" {
local expected_version
expected_version=$(get_remoting_version)

local actual_version
actual_version=$(docker inspect --format '{{ index .Config.Labels "org.opencontainers.image.version"}}' "${SUT_IMAGE}")

assert_equal "${expected_version}" "${actual_version}"
}

@test "[${SUT_IMAGE}] checking image metadata" {
local VOLUMES_MAP
VOLUMES_MAP="$(docker inspect -f '{{.Config.Volumes}}' "${SUT_IMAGE}")"
Expand Down

0 comments on commit 0341117

Please sign in to comment.