build-timeout: 15
cosign-password-id: cosign-password
cosign-private-key-id: cosign-private-key
+ cosign-public-key-id: cosign-public-key
disable-job: false
git-url: "$GIT_URL/$PROJECT"
stream: master
- text:
credential-id: "{cosign-password-id}"
variable: COSIGN_PASSWORD
+ - file:
+ credential-id: "{cosign-public-key-id}"
+ variable: COSIGN_PUBLIC_KEY
scm:
- lf-infra-gerrit-scm:
- text:
credential-id: "{cosign-password-id}"
variable: COSIGN_PASSWORD
+ - file:
+ credential-id: "{cosign-public-key-id}"
+ variable: COSIGN_PUBLIC_KEY
scm:
- lf-infra-github-scm:
--- /dev/null
+---
+fixes:
+ - |
+ When a container release is checked, the job will also check for a cosign
+ signature. This fixes an issue where a docker image could be successfully
+ pushed, but cosign would fail. This would lead to a failed job, and upon
+ re-running the job, it would pass when the container was found on the server,
+ without ever checking the status of the signature.
echo "$name"
echo "$version"
echo "INFO: Merge will release $name $version as $VERSION"
+ curl -O -L "https://github.com/sigstore/cosign/releases/latest/download/cosign-linux-amd64"
+ sudo mv cosign-linux-amd64 /usr/local/bin/cosign
+ sudo chmod +x /usr/local/bin/cosign
# Attempt to pull from releases registry to see if the image has been released.
if docker pull "$CONTAINER_PUSH_REGISTRY"/"$lfn_umbrella"/"$name":"$VERSION"; then
- echo "INFO: $VERSION is already released for image $name, Continuing..."
+ echo "INFO: $VERSION is already released for image $name, checking signature..."
+ image_digest=$(docker inspect --format='{{index .RepoDigests 0}}' \
+ "$CONTAINER_PUSH_REGISTRY"/"$lfn_umbrella"/"$name":"$VERSION")
+ cosign verify --key "$COSIGN_PUBLIC_KEY" "$image_digest"
+ cosign_verified=$?
+ if [ "$cosign_verified" -eq 0 ]; then
+ echo "INFO: $name:$VERSION is already signed, continuing..."
+ elif [ "$cosign_verified" -eq 10 ] && [[ "$JOB_NAME" =~ "merge" ]]; then
+ # Exit code 10 indicates the package was found without signature
+ echo "INFO: No signature found for $name:$VERSION. Attempting to sign..."
+ export COSIGN_PASSWORD
+ cosign sign -y --key "$COSIGN_PRIVATE_KEY" "$image_digest"
+ else
+ echo "INFO: Could not verify signature, cosign exited with code $cosign_verified."
+ fi
else
echo "INFO: $VERSION not found in releases, release will be prepared. Continuing..."
docker pull "$CONTAINER_PULL_REGISTRY"/"$lfn_umbrella"/"$name":"$version"
echo "docker tag $container_image_id $CONTAINER_PUSH_REGISTRY/$lfn_umbrella/$name:$VERSION"
echo "docker push $CONTAINER_PUSH_REGISTRY/$lfn_umbrella/$name:$VERSION"
if [[ "$JOB_NAME" =~ "merge" ]]; then
- curl -O -L "https://github.com/sigstore/cosign/releases/latest/download/cosign-linux-amd64"
- sudo mv cosign-linux-amd64 /usr/local/bin/cosign
- sudo chmod +x /usr/local/bin/cosign
- export COSIGN_PASSWORD
docker tag "$container_image_id" "$CONTAINER_PUSH_REGISTRY"/"$lfn_umbrella"/"$name":"$VERSION"
docker push "$CONTAINER_PUSH_REGISTRY"/"$lfn_umbrella"/"$name":"$VERSION"
image_digest=$(docker inspect --format='{{index .RepoDigests 0}}' \
"$CONTAINER_PUSH_REGISTRY"/"$lfn_umbrella"/"$name":"$VERSION")
+ export COSIGN_PASSWORD
cosign sign -y --key "$COSIGN_PRIVATE_KEY" "$image_digest"
fi
echo "#########################"