Commit 7ea69605 authored by Jonas Ådahl's avatar Jonas Ådahl
Browse files

template: Generate junit report if container registry not enabled

If a project running a pipeline doesn't have the container image
registry enabled, the pipeline will fail with an obscure error message
after having built the whole image, failing to do the last steps.

Avoid this by failing up front, generating a JUnit report, if the
registry isn't enabled.

Closes: #23

Signed-off-by: Jonas Ådahl's avatarJonas Ådahl <jadahl@gmail.com>
parent 97556201
Pipeline #232087 passed with stages
in 1 minute and 45 seconds
......@@ -106,6 +106,28 @@
extends: .fdo.{{distribution}}
stage: build
script:
# check that the container registry is enabled
- |
if [[ -z "$CI_REGISTRY_IMAGE" ]]
then
# the container registry is not enabled in the project, no point to
# continue; let the user know so they can fix their project settings
echo The container registry is not enabled in $CI_PROJECT_PATH, \
enable it in the project general settings panel ;
cat <<EOF > container-build-report.xml ;
<?xml version="1.0" encoding="utf-8"?>
<testsuites tests="1" errors="0" failures="1">
<testsuite name="registry-not-enabled" tests="1" errors="0" failures="1" skipped="0">
<testcase name="registry-not-enabled">
<failure message="The container registry is not enabled in $CI_PROJECT_PATH, enable it in the project general settings panel"/>
</testcase>
</testsuite>
</testsuites>
EOF
exit 1 ;
fi
# log in to the registry
- podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- skopeo login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
......@@ -213,6 +235,11 @@
- sleep 2
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
- set +x
artifacts:
paths:
- container-build-report.xml
reports:
junit: container-build-report.xml
###
# Checks for a pre-existing {{distribution}} container image and builds it if
......
......@@ -101,6 +101,28 @@
extends: .fdo.alpine
stage: build
script:
# check that the container registry is enabled
- |
if [[ -z "$CI_REGISTRY_IMAGE" ]]
then
# the container registry is not enabled in the project, no point to
# continue; let the user know so they can fix their project settings
echo The container registry is not enabled in $CI_PROJECT_PATH, \
enable it in the project general settings panel ;
cat <<EOF > container-build-report.xml ;
<?xml version="1.0" encoding="utf-8"?>
<testsuites tests="1" errors="0" failures="1">
<testsuite name="registry-not-enabled" tests="1" errors="0" failures="1" skipped="0">
<testcase name="registry-not-enabled">
<failure message="The container registry is not enabled in $CI_PROJECT_PATH, enable it in the project general settings panel"/>
</testcase>
</testsuite>
</testsuites>
EOF
exit 1 ;
fi
# log in to the registry
- podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- skopeo login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
......@@ -194,6 +216,11 @@
- sleep 2
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
- set +x
artifacts:
paths:
- container-build-report.xml
reports:
junit: container-build-report.xml
###
# Checks for a pre-existing alpine container image and builds it if
......
......@@ -101,6 +101,28 @@
extends: .fdo.arch
stage: build
script:
# check that the container registry is enabled
- |
if [[ -z "$CI_REGISTRY_IMAGE" ]]
then
# the container registry is not enabled in the project, no point to
# continue; let the user know so they can fix their project settings
echo The container registry is not enabled in $CI_PROJECT_PATH, \
enable it in the project general settings panel ;
cat <<EOF > container-build-report.xml ;
<?xml version="1.0" encoding="utf-8"?>
<testsuites tests="1" errors="0" failures="1">
<testsuite name="registry-not-enabled" tests="1" errors="0" failures="1" skipped="0">
<testcase name="registry-not-enabled">
<failure message="The container registry is not enabled in $CI_PROJECT_PATH, enable it in the project general settings panel"/>
</testcase>
</testsuite>
</testsuites>
EOF
exit 1 ;
fi
# log in to the registry
- podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- skopeo login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
......@@ -194,6 +216,11 @@
- sleep 2
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
- set +x
artifacts:
paths:
- container-build-report.xml
reports:
junit: container-build-report.xml
###
# Checks for a pre-existing arch container image and builds it if
......
......@@ -100,6 +100,28 @@
extends: .fdo.centos
stage: build
script:
# check that the container registry is enabled
- |
if [[ -z "$CI_REGISTRY_IMAGE" ]]
then
# the container registry is not enabled in the project, no point to
# continue; let the user know so they can fix their project settings
echo The container registry is not enabled in $CI_PROJECT_PATH, \
enable it in the project general settings panel ;
cat <<EOF > container-build-report.xml ;
<?xml version="1.0" encoding="utf-8"?>
<testsuites tests="1" errors="0" failures="1">
<testsuite name="registry-not-enabled" tests="1" errors="0" failures="1" skipped="0">
<testcase name="registry-not-enabled">
<failure message="The container registry is not enabled in $CI_PROJECT_PATH, enable it in the project general settings panel"/>
</testcase>
</testsuite>
</testsuites>
EOF
exit 1 ;
fi
# log in to the registry
- podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- skopeo login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
......@@ -192,6 +214,11 @@
- sleep 2
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
- set +x
artifacts:
paths:
- container-build-report.xml
reports:
junit: container-build-report.xml
###
# Checks for a pre-existing centos container image and builds it if
......
......@@ -100,6 +100,28 @@
extends: .fdo.debian
stage: build
script:
# check that the container registry is enabled
- |
if [[ -z "$CI_REGISTRY_IMAGE" ]]
then
# the container registry is not enabled in the project, no point to
# continue; let the user know so they can fix their project settings
echo The container registry is not enabled in $CI_PROJECT_PATH, \
enable it in the project general settings panel ;
cat <<EOF > container-build-report.xml ;
<?xml version="1.0" encoding="utf-8"?>
<testsuites tests="1" errors="0" failures="1">
<testsuite name="registry-not-enabled" tests="1" errors="0" failures="1" skipped="0">
<testcase name="registry-not-enabled">
<failure message="The container registry is not enabled in $CI_PROJECT_PATH, enable it in the project general settings panel"/>
</testcase>
</testsuite>
</testsuites>
EOF
exit 1 ;
fi
# log in to the registry
- podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- skopeo login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
......@@ -202,6 +224,11 @@
- sleep 2
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
- set +x
artifacts:
paths:
- container-build-report.xml
reports:
junit: container-build-report.xml
###
# Checks for a pre-existing debian container image and builds it if
......
......@@ -100,6 +100,28 @@
extends: .fdo.fedora
stage: build
script:
# check that the container registry is enabled
- |
if [[ -z "$CI_REGISTRY_IMAGE" ]]
then
# the container registry is not enabled in the project, no point to
# continue; let the user know so they can fix their project settings
echo The container registry is not enabled in $CI_PROJECT_PATH, \
enable it in the project general settings panel ;
cat <<EOF > container-build-report.xml ;
<?xml version="1.0" encoding="utf-8"?>
<testsuites tests="1" errors="0" failures="1">
<testsuite name="registry-not-enabled" tests="1" errors="0" failures="1" skipped="0">
<testcase name="registry-not-enabled">
<failure message="The container registry is not enabled in $CI_PROJECT_PATH, enable it in the project general settings panel"/>
</testcase>
</testsuite>
</testsuites>
EOF
exit 1 ;
fi
# log in to the registry
- podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- skopeo login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
......@@ -192,6 +214,11 @@
- sleep 2
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
- set +x
artifacts:
paths:
- container-build-report.xml
reports:
junit: container-build-report.xml
###
# Checks for a pre-existing fedora container image and builds it if
......
......@@ -100,6 +100,28 @@
extends: .fdo.ubuntu
stage: build
script:
# check that the container registry is enabled
- |
if [[ -z "$CI_REGISTRY_IMAGE" ]]
then
# the container registry is not enabled in the project, no point to
# continue; let the user know so they can fix their project settings
echo The container registry is not enabled in $CI_PROJECT_PATH, \
enable it in the project general settings panel ;
cat <<EOF > container-build-report.xml ;
<?xml version="1.0" encoding="utf-8"?>
<testsuites tests="1" errors="0" failures="1">
<testsuite name="registry-not-enabled" tests="1" errors="0" failures="1" skipped="0">
<testcase name="registry-not-enabled">
<failure message="The container registry is not enabled in $CI_PROJECT_PATH, enable it in the project general settings panel"/>
</testcase>
</testsuite>
</testsuites>
EOF
exit 1 ;
fi
# log in to the registry
- podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- skopeo login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
......@@ -201,6 +223,11 @@
- sleep 2
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
- set +x
artifacts:
paths:
- container-build-report.xml
reports:
junit: container-build-report.xml
###
# Checks for a pre-existing ubuntu container image and builds it if
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment