このコンテンツは選択した言語では利用できません。

Chapter 4. Customizing GitLab pipelines and rebuilding container images


When customizing pipelines in GitLab, rebuilding the container image is a critical step to ensure your changes are included in the updated workflow.

Pipelines in GitLab rely on a specific container image, such as the GitLab runner image, to run the tasks defined in your CI/CD workflow. The GitLab runner image provides the necessary tools, configuration, and scripts required for your pipeline to run. If you modify tasks in the pipeline, you must update and rebuild the container image to include those changes. This ensures that the pipeline tasks are properly executed when the pipeline is triggered.

Rebuilding the container image involves the following steps:

  • Running podman to extract the existing pipeline files.
  • Customizing the pipeline tasks with your requirements.
  • Rebuilding the container image.
  • Pushing the updated image to a container registry.

Prerequisites

Before making changes, ensure that:

  • You have podman installed on your system.
  • You have login credentials for Quay.io to push the updated image.
  • You have forked and cloned the Sample templates repository.
  • Your forked repository is up to date and synced with the upstream repository.

Procedure

  1. Create a directory for the build resources. The location of the directory depends on your role:

    • Platform engineer: If you are rebuilding the image to update the default pipeline for your organization, you can create the directory within the location where you forked the tssc-sample-templates repository. For example, rebuild-image.
    • Developers: If you are rebuilding the image for your own use or a specific project, create a directory in a location outside the organization-wide fork of tssc-sample-templates to avoid conflicts.

      $ mkdir rebuild-image
      Copy to Clipboard Toggle word wrap
  2. Run the following command and copy the container image URL:

    $ less ../tssc-sample-templates/skeleton/ci/source-repo/gitlabci/.gitlab-ci.yml
    Copy to Clipboard Toggle word wrap
    image: quay.io/redhat-tssc/task-runner/
    Copy to Clipboard Toggle word wrap
  3. Copy the existing pipeline content locally by running the following command:

    $ podman run -v $(pwd):/pwd:z <The_url_you_copied_in_step_2> cp -r /work/tssc /pwd
    Copy to Clipboard Toggle word wrap

    This command starts the container by using the <the_url_you_copied_in_step_2> image. It then copies the pipeline files from /work/tssc inside the container to your working directory ($(pwd)). Additionally, if you are not on a system with SELinux enabled (for example, Fedora, RHEL, or CentOS), remove the :z option in the command to ensure compatibility.

  4. Navigate to the rhtap directory and customize the pipelines tasks as required.
  5. Create a Dockerfile in the rebuild-image directory and add the following content to include your changes in the container. Additionally, the base image quay.io/redhat-tssc/task-runner:1.8 is built on ubi/ubi-minimal, which provides a lightweight Universal Base Image (UBI). If you need to install additional software and dependencies, use microdnf. For example, example command:

    FROM quay.io/redhat-tssc/task-runner:1.8
    
    COPY ./tssc /work/tssc
    
    RUN microdnf -y install make
    Copy to Clipboard Toggle word wrap
    FROM
    Uses the existing rhtap-runner container as the starting point.
    COPY
    Copies the updated pipeline tasks from the local rhtap folder into the /work/tssc directory inside the container.
    RUN
    Demonstrates the use of the microdnf to install additional software or dependencies.
  6. Build the new container image by running the following command:

    $ podman build -f Dockerfile -t quay.io/<namespace>/<new_image_name> 
    1
    Copy to Clipboard Toggle word wrap

    The -f Dockerfile option specifies the Dockerfile to use to build the container image. The -f option allows you to explicitly point to the Dockerfile if it’s not named Dockerfile or is located in a different directory. The -t quay.io/<namespace>/<new_image_name> option assigns a tag (name) to the container image for easy identification.

  7. Login to Quay.io by running the following command:

    $ podman login quay.io
    Copy to Clipboard Toggle word wrap
  8. Push the updated image by running the following command:

    $ podman push quay.io/<namespace>/<new_image_name>
    Copy to Clipboard Toggle word wrap

    This uploads the customized container image to Quay.io, making it available for use in GitLab pipelines.

  9. Platform engineer only: Navigate to the .gitlab-ci.yml in the tssc-sample-templates > skeleton > ci > source-repo > gitlabci > directory and replace the container image URL with the one you just created. This makes the new container image the default.

    image: quay.io/<namespace>/<new_image_name>
    Copy to Clipboard Toggle word wrap
  10. For developers only: To update the container image just for a single repository in GitLab, navigate to the source repository > .gitlab-ci.yaml and replace the container image URL with the one you just created.

    image: quay.io/<namespace>/<new_image_name>
    Copy to Clipboard Toggle word wrap
  11. Commit and push the changes to apply the updated pipeline configuration.
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2026 Red Hat
トップに戻る