Verified Commit cde708e9 authored by Marek Pikuła's avatar Marek Pikuła
Browse files

oci: Add image build labels

parent 60885d8e
Loading
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -446,6 +446,35 @@ CI Job and Builder
  runners. Default: ``1``.
- ``stage``: CI stage name for the job. Default: ``oci``.

Image labels
^^^^^^^^^^^^

When the image is built with the OCI template, the following OCI image labels
are applied:

.. list-table::

 * - Image Label
   - Value
 * - ``<prefix>.commit``
   - ``$CI_COMMIT_SHA``
 * - ``<prefix>.job_id``
   - ``$CI_JOB_ID``
 * - ``<prefix>.pipeline_id``
   - ``$CI_PIPELINE_ID``
 * - ``<prefix>.pipeline_url``
   - ``$CI_PIPELINE_URL``
 * - ``<prefix>.project``
   - ``$CI_PROJECT_PATH``

``<prefix>`` is ``fdo`` for jobs run on Freedesktop.org, and ``gitlab-ci``
otherwise. This is to use similar labeling convention as `ci-templates
<https://gitlab.freedesktop.org/freedesktop/ci-templates>`__ on FDO.

For the values starting with ``CI_``, see the `GitLab
environment variables documentation
<https://docs.gitlab.com/ee/ci/variables/predefined_variables.html>`__

Example Usage
^^^^^^^^^^^^^

+12 −0
Original line number Diff line number Diff line
@@ -209,6 +209,13 @@ include:
        echo "No environment override file available for this target.";
      fi

    - |
      if [ "$CI_SERVER_HOST" = "gitlab.freedesktop.org" ]; then
        LABEL_PREFIX="fdo"
      else
        LABEL_PREFIX="gitlab-ci"
      fi

    # Build and push the stacked image.
    - |
      set -e
@@ -229,6 +236,11 @@ include:
          $(cat /tmp/build_args) \
          --build-arg FROM_IMAGE_NAME=${FROM_IMAGE_NAME} \
          --build-arg FROM_IMAGE_TAG=${FROM_IMAGE_TAG} \
          --label "${LABEL_PREFIX}.commit=${CI_COMMIT_SHA}" \
          --label "${LABEL_PREFIX}.job_id=${CI_JOB_ID}" \
          --label "${LABEL_PREFIX}.pipeline_id=${CI_PIPELINE_ID}" \
          --label "${LABEL_PREFIX}.pipeline_url=${CI_PIPELINE_URL}" \
          --label "${LABEL_PREFIX}.project=${CI_PROJECT_PATH}" \
          --file ${layer} .
        ${BUILDER} images
        set +x