简体   繁体   English

运行 GitLab CI/CD 管道时“无法找到 package git”

[英]“Unable to locate package git” when running GitLab CI/CD pipeline

I am trying to set up a GitLab CI/CD pipeline with this following .gitlab-ci.yml file:我正在尝试使用以下.gitlab-ci.yml文件设置 GitLab CI/CD 管道:

stages:
  - test

image: "ros:foxy-ros-base-focal"

before_script:
  - apt-get -y update && apt-get install -y \
    git wget qt5-default \
    python3-osrf-pycommon \
    python3-catkin-tools \
    python3-rosdep \
    python3-vcstool \
    python3-pip \
    python3-colcon-common-extensions \
    apt-utils
  - rm -rf /var/lib/apt/lists/*
  - /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; colcon build"
  - echo "source /root/dev_ws/install/setup.bash" >> /opt/ros/${ROS_DISTRO}/setup.bash

test_a:
  stage: test
  script:
    - pip3 install pytest
    - python -m pytest test_utils.py -vv -s

I am starting from the ROS2 Foxy Base Focal Docker image.我从 ROS2 Foxy Base Focal Docker 图像开始。 However, despite running apt-get update , I still can't find many of the packages, including git as well as several other ROS2 packages.然而,尽管运行apt-get update ,我仍然找不到很多包,包括git以及其他几个 ROS2 包。 Full log here:完整日志在这里:

Running with gitlab-runner 13.8.0 (775dd39d)
  on docker-auto-scale fa6cab46
Preparing the "docker+machine" executor
00:27
Using Docker executor with image ros:foxy-ros-base-focal ...
Pulling docker image ros:foxy-ros-base-focal ...
Using docker image sha256:59cf2af10ce4181bf4effbc683375f5e201bfe072c808c75fb3ee903b98265b9 for ros:foxy-ros-base-focal with digest ros@sha256:4f924ff4fdee6b7c999ad6bc013741bdf8430466c7a27842ac6255255ce9ae66 ...
Preparing environment
00:02
Running on runner-fa6cab46-project-23977848-concurrent-0 via runner-fa6cab46-srm-1611897044-53c1946d...
Getting source from Git repository
00:02
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/imda_dsl/vama-2/scene-understanding/scene-understanding-manager/.git/
Created fresh repository.
Checking out fc385931 as dev...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:05
$ apt-get -y update && apt-get install -y \ git wget qt5-default \ python3-osrf-pycommon \ python3-catkin-tools \ python3-rosdep \ python3-vcstool \ python3-pip \ python3-colcon-common-extensions \ apt-utils
Get:1 http://packages.ros.org/ros2/ubuntu focal InRelease [4670 B]
Get:2 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]
Get:4 http://packages.ros.org/ros2/ubuntu focal/main amd64 Packages [451 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:6 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [161 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB]
Get:10 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [598 kB]
Get:11 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [659 kB]
Get:12 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [13.3 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1275 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [33.4 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1003 kB]
Get:16 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [21.1 kB]
Get:17 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [194 kB]
Get:18 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [920 kB]
Get:19 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [4301 B]
Fetched 17.4 MB in 2s (7001 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package  git
E: Unable to locate package  python3-osrf-pycommon
E: Unable to locate package  python3-catkin-tools
E: Unable to locate package  python3-rosdep
E: Unable to locate package  python3-vcstool
E: Unable to locate package  python3-pip
E: Unable to locate package  python3-colcon-common-extensions
E: Unable to locate package  apt-utils
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1

Installing packages or even running update commands in your .gitlab-ci.yml is generally against best practices for a CI/CD container because each and every job that runs will have to do the same thing, costing a lot of time as you run more pipelines..gitlab-ci.yml中安装包甚至运行更新命令通常违反 CI/CD 容器的最佳实践,因为运行的每个作业都必须做同样的事情,运行更多会花费大量时间管道。 If you can't find an existing Docker image that has the packages you need (so as an example, python3 and git), you can create your own images.如果您找不到包含所需软件包的现有 Docker 映像(例如,python3 和 git),您可以创建自己的映像。 If you need to extend the image from your job, ros:foxy-ros-base-focal , create a Dockerfile file with the following contents:如果您需要扩展作业中的图像ros:foxy-ros-base-focal ,请创建一个Dockerfile文件,其中包含以下内容:

FROM ros:foxy-ros-base-focal
MAINTAINER your name "your email"
RUN apt-get update -yqq
RUN apt-get install -yqq git

You can install/configure whatever else you need to do in there too, then when you're done build the image:您也可以在那里安装/配置您需要做的任何其他事情,然后在您完成构建映像后:

docker build /path/to/dir-with-dockerfile -t tagname:version

Once the build is done you can verify the tag is correct with docker images , then you can push it to a registry (docker hub, gitlab's registry if enabled, private registry, etc) with:构建完成后,您可以使用docker images验证标签是否正确,然后您可以将其推送到注册表(docker hub、gitlab 的注册表(如果启用)、私有注册表等):

docker login my.hub.example.com

docker push my.hub.example.com/tagname:version

Then in your .gitlab-ci.yml file, you can use the tagname:version image in your jobs:然后在您的.gitlab-ci.yml文件中,您可以在作业中使用tagname:version图像:

stages:
  - test

image: "tagname:version"
...

If you have to auth to use your registry, you'll have to review the docs here https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#define-an-image-from-a-private-container-registry , and the general docs for using docker images in your pipelines is here: https://docs.gitlab.com/ee/ci/docker/using_docker_images.html如果您必须授权使用您的注册表,则必须在此处查看文档https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#define-an-image-from-a-private -container -registry , and the general docs for using docker images in your pipelines is here: https://docs.gitlab.com/ee/ci/docker/using_docker_images.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 GitLab CI/CD 管道在构建时找不到 GCC - GitLab CI/CD Pipeline can't find GCC when building Debian package Gitlab CI/CD 管道给出 Dockerfile 错误 - Gitlab CI/CD pipeline giving Dockerfile error 当用户单击应用程序中的按钮时,如何使用 GitLab CI 或 Jenkins 触发管道 CI/CD? - How can I trigger Pipeline CI/CD using GitLab CI or Jenkins when a user click on button in application? GitLab CI/CD 管道错误,同时安装 npm 包 [package.json 文件未找到] - GitLab CI/CD pipeline error while installing npm packages [package.json file not found] 如何在 gitlab ci/cd 管道上的 docker 构建期间解锁 git-crypt 文件 - How to unlock git-crypt files during docker build on gitlab ci/cd pipeline gitlab CI/CD:使用 git 的 docker 镜像 - gitlab CI/CD: docker image with git 在不同的 docker 容器中运行 Jfrog cli 并在 Gitlab CI/CD 管道中使用该 cli - Running Jfrog cli in different docker container and using that cli in the Gitlab CI/CD pipeline 在 Gitlab CI/CD 中运行 Docker 容器时出现问题 - Problem running a Docker container in Gitlab CI/CD 在CI / CD管道中使用Docker运行SonarQube - Running SonarQube with Docker in CI/CD pipeline 从Gitlab CI / CD管道执行docker命令时权限被拒绝 - Permission denied when executing docker commands from Gitlab CI/CD pipeline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM