简体   繁体   English

Gitlab CI 失败并出现错误:作业失败:退出代码 1

[英]Gitlab CI fails with ERROR: Job failed: exit code 1

I am pretty new to gitlab ci and I have a project with a pre-existing gitlab configuration which was running fine but after pushing a few code changes, it has now completely stopped working and I can't figure out why.我是 gitlab ci 的新手,我有一个项目,该项目具有预先存在的 gitlab 配置,运行良好,但在进行了一些代码更改后,它现在完全停止工作,我不明白为什么。 Here is the .gitlab-ci.yml这是.gitlab-ci.yml

stages:
  - build
  - deploy

variables:
  DOCKER_HOST: tcp://localhost:2375

assets:
  stage: build
  image: node:10-alpine
  script:
    - npm ci
    - NODE_ENV=production npm run build
  artifacts:
    expire_in: 1 day
    paths:
      - public/assets
  tags:
    - docker

package:
  stage: deploy
  image: php:7.3-cli-alpine
  dependencies:
    - assets
  before_script:
    - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    - php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
    - php composer-setup.php --install-dir=/usr/local/bin --filename=composer
    - php -r "unlink('composer-setup.php');"
  script:
    - composer install --prefer-dist --no-progress --optimize-autoloader --no-scripts
    - rm -fr .git
  artifacts:
    expire_in: 1 day
    paths:
      - .
  tags:
    - docker

docker:
  stage: deploy
  image: docker:latest
  services:
    - docker:18-dind
  dependencies:
    - assets
  script:
    - docker build -t $CI_REGISTRY_IMAGE:latest .
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    - docker push $CI_REGISTRY_IMAGE:latest
  only:
    - master
  tags:
    - docker

deploy:
  stage: deploy
  image: php:7.3-cli-alpine
  dependencies:
    - assets
  before_script:
    - curl -LO https://deployer.org/deployer.phar
    - mv deployer.phar /usr/local/bin/dep
    - chmod +x /usr/local/bin/dep
    - apk add --update openssh rsync
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - ssh-keyscan -t rsa domain.co.uk >> /root/.ssh/known_hosts
  script:
    - dep deploy -p --tag="$CI_COMMIT_TAG"
  only:
    - tags
  tags:
    - docker

I am consistently getting the following error and I am wondering what has changed and if it is the server or gitlab-ci causing the following issue.我一直收到以下错误,我想知道发生了什么变化,是服务器还是 gitlab-ci 导致了以下问题。 I checked the server and it's running fine but there is no docker installed there and I presume the docker is not supposed to be installed on the server for what it is trying to do anyways?我检查了服务器,它运行良好,但那里没有安装 docker,我认为 docker 不应该安装在服务器上,因为它无论如何都想做什么?

Checking out a50d58fd as master...
 Skipping Git submodules setup
Downloading artifacts for assets (447059035)...
00:01
 Downloading artifacts from coordinator... ok        id=447059035 responseStatus=200 OK token=cp4GCzgJ
$ docker build -t $CI_REGISTRY_IMAGE:latest .
00:02
 time="2020-02-24T03:53:41Z" level=error msg="failed to dial gRPC: cannot connect to the Docker daemon. Is 'docker daemon' running on this host?: dial tcp [::1]:2375: connect: connection refused"
 error during connect: Post http://localhost:2375/v1.40/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&session=sja0dvuf6gm0w8tneigulo3ha&shmsize=0&t=registry.gitlab.com%2Fnir.npl%2Fbrayleys-honda%3Alatest&target=&ulimits=null&version=1: context canceled
 ERROR: Job failed: exit code 1

Check if this is similar to this thread from a year ago :检查这是否与一年前的这个线程相似:

It seems docker updated their latest stable images and gitlab has not updated their runners yet, changing the images to be on the 18 major fixes these issues, eg:似乎 docker 更新了他们最新的稳定图像,而 gitlab 还没有更新他们的跑步者,将图像更改为 18 个主要修复这些问题,例如:

image: docker:18-git

variables:
  DOCKER_HOST: tcp://docker:2375/
  DOCKER_DRIVER: overlay2

services:
  - docker:18-dind

In you case, a year later, that would be docker:19-dind , especially if you are using image: docker:latest , which is not a good practice, because "latest" can vary at any time.在你的情况下,一年后,那将是docker:19-dind ,特别是如果你使用image: docker:latest ,这不是一个好的做法,因为“最新”可以随时变化。
image: docker:19-git would be preferable. image: docker:19-git会更好。

暂无
暂无

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

相关问题 gitlab-ci-multi-runner 9.2.0:错误:作业失败:退出代码252 - gitlab-ci-multi-runner 9.2.0: ERROR: Job failed: exit code 252 错误:作业失败:命令以退出代码1终止 - ERROR: Job failed: command terminated with exit code 1 Gitlab CI - 错误:作业失败:执行程序需要 OSType=linux,但 Docker 引擎仅支持 OSType=windows - Gitlab CI - ERROR: Job failed: executor requires OSType=linux, but Docker Engine supports only OSType=windows Docker:错误:作业失败:命令以退出代码 1 终止 - Docker: ERROR: Job failed: command terminated with exit code 1 Gitlab Runner失败并显示错误:作业失败(系统故障):发生内部错误:对等重置连接 - Gitlab Runner fails with ERROR: Job failed (system failure): Internal error occurred: connection reset by peer GitLab CI docker 构建 - docker:未找到 - 退出代码 127 - GitLab CI docker build - docker: not found - exit code 127 在 gitlab ci 作业中使用 kubectl 创建 ImagePullSecret 时出现奇怪错误 - Strange Error while creating ImagePullSecret with kubectl in gitlab ci job 在 GitLab 上部署 Docker 项目失败,退出代码为 137? - Deploying Docker project on GitLab fails with 137 exit code? Gitlab上的Kubernetes执行程序错误:作业失败:图片提取失败 - Kubernetes executor on Gitlab ERROR: Job failed: image pull failed (误报)使用gitlab-ci运行docker-compose:构建作业失败但管道成功 - (False Positive) Running docker-compose with gitlab-ci: Build job fails but pipeline succeeds
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM