gitlab jobs failling(sudo:找不到或未能获取命令)

发布于 2025-02-04 07:11:34 字数 2241 浏览 2 评论 0 原文

我正在使用gitlab作业来部署工具。下面的代码返回 sudo:找不到命令。如果我删除 sudo ,我会得到以下内容:

W: Failed to fetch http://deb.debian.org/debian/dists/stable/InRelease  Could not connect to deb.debian.org:80 (199.232.138.132), connection timed out
W: Failed to fetch http://security.debian.org/debian-security/dists/stable-security/InRelease  Could not connect to security.debian.org:80 (151.101.130.132), connection timed out Could not connect to security.debian.org:80 (151.101.66.132), connection timed out Could not connect to security.debian.org:80 (151.101.2.132), connection timed out Could not connect to security.debian.org:80 (151.101.194.132), connection timed out
W: Failed to fetch http://deb.debian.org/debian/dists/stable-updates/InRelease  Unable to connect to deb.debian.org:80:
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package latex209-bin
E: Unable to locate package texlive-latex-base
E: Unable to locate package texlive-latex-extra
E: Unable to locate package ant
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1

这是 .gitlab-ci.yml 文件:

stages:
  - deploy
variables:
  RA_NAME: "My_project"
default:
  before_script:
    - sudo apt-get update -qq && sudo apt-get install -y latex209-bin texlive-latex-base texlive-latex-extra ant && sudo apt-get install zip unzip
    
deploy_Default:
  stage: deploy
  script:
    - sh -x deploy.sh "$RA_NAME" "$(cat RA_VERSION)"
  artifacts:
    paths:
      - "${RA_NAME}_$(cat RA_VERSION).zip"
  only:
    - master
    - dev
    - tags

这已经发生了1周(最有可能来自Gitlab 15.0版本)。
在此之前的每项工作都开始发生通过没有任何问题。现在,没有更改他们都失败的任何东西(即使尝试重播传递>的旧旧的


我尝试添加

build_image:
  script:
    - docker build --network host

和几个类似的配置,但它们都没有。

现在我的问题:为什么 sudo 不再使用我的 .gitlab-- ci.yml 以及我该怎么办。
我应该提到,这些作业是由仅中提到的分支触发的。我可以通过运行管道或重新运行已经运行的来运行它们。我不知道任何其他方式可以运行它们。 Gitlab和Docker的所有工作都是由Gitlab UI完成的

I am using Gitlab Jobs to deploy a tool. The code below returns sudo: command not found. If I remove the sudo I get the following:

W: Failed to fetch http://deb.debian.org/debian/dists/stable/InRelease  Could not connect to deb.debian.org:80 (199.232.138.132), connection timed out
W: Failed to fetch http://security.debian.org/debian-security/dists/stable-security/InRelease  Could not connect to security.debian.org:80 (151.101.130.132), connection timed out Could not connect to security.debian.org:80 (151.101.66.132), connection timed out Could not connect to security.debian.org:80 (151.101.2.132), connection timed out Could not connect to security.debian.org:80 (151.101.194.132), connection timed out
W: Failed to fetch http://deb.debian.org/debian/dists/stable-updates/InRelease  Unable to connect to deb.debian.org:80:
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package latex209-bin
E: Unable to locate package texlive-latex-base
E: Unable to locate package texlive-latex-extra
E: Unable to locate package ant
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1

This is the .gitlab-ci.yml file:

stages:
  - deploy
variables:
  RA_NAME: "My_project"
default:
  before_script:
    - sudo apt-get update -qq && sudo apt-get install -y latex209-bin texlive-latex-base texlive-latex-extra ant && sudo apt-get install zip unzip
    
deploy_Default:
  stage: deploy
  script:
    - sh -x deploy.sh "$RA_NAME" "$(cat RA_VERSION)"
  artifacts:
    paths:
      - "${RA_NAME}_$(cat RA_VERSION).zip"
  only:
    - master
    - dev
    - tags

This has been happening for 1 week (most likely from the Gitlab 15.0 release).
Every Job before this started to happen Passed without any problems. Now, without changing anything they all fail (even trying to rerun old ones that Passed).

I tried adding

build_image:
  script:
    - docker build --network host

and a couple of similar configurations but none of them worked.

Now my question: why sudo doesn't work anymore without changing anything on my .gitlab-ci.yml and what can I do to solve it.
I should mention that these Jobs are triggered by commits to the branches mentioned in only. I can run them by running pipeline or rerun the ones that were already run. I am not aware of any other modality to run them. All the work with Gitlab and this Docker are done by Gitlab UI

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

柒七 2025-02-11 07:11:34

当实例/服务器有网络问题时,就会发生这种情况。如果跑步者没有自我主持,那么Gitlab应该很快就可以解决问题。如果跑步者是自主的,那么您就会遇到网络问题。这是我可以提出的:

注意:不 sudo

  1. 。 nofollow noreferrer“> debian镜像站点列表
  2. 通过 nano /etc/apt/sources.list 编辑来源列表,如果 nano 不可用,则使用 vi
  3. 更改为其他镜像,

例如

http://deb.debian.org/debian/dists/stable/InRelease // <-- remove this
http://ftp.us.debian.org/debian/dists/stable/InRelease // <-- add this
  1. 保存。

This happens when the instance/server has networking issues. If the runner isn't self-hosted then Gitlab should fix the problem fairly soon. If the runner is self-hosted then you've got networking issues. Here's what I can propose:

Note: Try this without sudo

  1. Select the debian mirror close to you from the debian mirror sites list
  2. Edit the sources list via nano /etc/apt/sources.list if nano is not available then use vi
  3. Change to a different mirror

For example

http://deb.debian.org/debian/dists/stable/InRelease // <-- remove this
http://ftp.us.debian.org/debian/dists/stable/InRelease // <-- add this
  1. Save.
相思碎 2025-02-11 07:11:34

我解决了问题。在更新之前,在不指定 .gitlab-ci.yml 中的任何图像的情况下,默认情况下它使用了我的公司Docker Image “在此处输入图像描述”

注意到它使用了另一个 “在此处输入图像描述”

我添加到我的 .gitlab-ci.yml 以下:

image: myCompanyImage

现在像以前一样正常。
如果您遇到这样的问题,请检查其使用的图像以及以前成功运行管道中使用的图像。

I solved the problem. Before the update, without specifying any image in .gitlab-ci.yml, by default it used my company Docker Image enter image description here.

After the update I noticed it used another one enter image description here

I added to my .gitlab-ci.yml the following:

image: myCompanyImage

and now works fine as before.
If you encounter such a problem, check the image it's using and the image used in a previous successfully run pipeline.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文