Error job failed exit code 1 как устранить ошибку

Skip to content



Open


Issue created Feb 20, 2018 by George Paoli@george.linearsistemas

ERROR: Job failed: exit code 1

Summary

Script executed with success, but job fail.

Steps to reproduce

Here is my attempt, you can check the error, an error message appears: «ERROR: Job failed: exit code 1»

Actual behavior

An error message appears: «ERROR: Job failed: exit code 1»

Expected behavior

Show message «code coverage done!», from my last script configured in .gitlab-ci.yml

Relevant logs and/or screenshots

screenshots

.gitlab-ci.yml source:

image: microsoft/dotnet

stages:
  - build_and_test

build-modulo-materiais:
  stage: build_and_test
  script:
    - cd v1/materiais
    - dotnet build src/api/api.csproj
    - dotnet build test/test.csproj
    - dotnet restore tools/tools.csproj
    - cd tools
    - dotnet minicover instrument --workdir ../ --assemblies test/**/bin/**/*.dll --sources src/**/*.cs
    - dotnet minicover reset
    - dotnet test ../test/test.csproj --no-build
    - dotnet minicover uninstrument --workdir ../
    - dotnet minicover report --workdir ../ --threshold 90 ## JOB FAIL HERE, BUT SCRIPT EXECUTED WITH SUCCESS
    - echo "code coverage done!"

Environment description

Are you using shared Runners on GitLab.com? Yes
Please, see complete in https://gitlab.com/linear-back/pocs/estrutura-projetos-testes-ci-cd/-/jobs/53438671

Used GitLab Runner version

Running with gitlab-runner 10.5.0-rc1 (7a8e43fe)
  on docker-auto-scale (e11ae361)
Using Docker executor with image microsoft/dotnet ...

Edited Feb 20, 2018 by George Paoli

Overview

This drove me crazy and I’m still not sure what the appropriate answer is. I just ran into this issue myself and sunk hours into this issue. I think GitLab messed something up with command substitution (shows a new release yesterday), although I could be wrong about the issue or its timing. It also seems to only occur for some command substitutions and not others, I initially suspected it might be related to outputting to /dev/null, but wasn’t going to dive too deep. It always failed immediately after the command substitution was initiated.


My code

I had code similar to yours (reduced version below), tried manipulating it multiple ways, but each use of command substitution yielded the same failure message:

Cleaning up file based variables          00:01
ERROR: Job failed: exit code 1

Attempts I’ve made include the following:

- folders=$(find .[^.]* * -type d -maxdepth 0 -exec echo {} ; 2>/dev/null)
- >
  while read folder; do
      echo "$folder"
  done <<< "$folders"

And …

- >
  while read folder; do
      echo "$folder"
  done <<< $(find .[^.]* * -type d -maxdepth 0 -exec echo {} ; 2>/dev/null)

Both those versions succeeded on my local machine, but failed in GitLab (I might have typos in above — please don’t scrutinize, it’s reduced version of my actual program).


How I fixed it

Rather than using command substitution $(...), I instead opted for process substitution <(...) and it seems to be working without issue.

- >
  while read folder; do
      echo "$folder"
  done < <(find .[^.]* * -type d -maxdepth 0 -exec echo {} ; 2>/dev/null)

I would try to substitute the same in your code if possible:

- >
  while read dir; do
      # the rest goes here
  done < <(git log -m -1 --name-only -r --pretty="format:" "$CI_COMMIT_SHA")

The issue might also be the line inside the if statement (the echo), you can replace that with the following:

read SERVICE < <(echo "$dir")

Again, not exactly sure this will fix the issue for you as I’m still unsure what the cause is, but it resolved my issue. Best of luck.

I followed Connecting GitLab with a Kubernetes cluster | GitLab and
GitLab Runner and now trying to follow GitLab CI/CD Pipeline Configuration Reference, yet running into following error:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is
the docker daemon running?

job:

Running with gitlab-runner 11.10.1 (1f513601)
  on runner-gitlab-runner-5b8d5bf7db-5phqs 3gRXuKPT
Using Kubernetes namespace: gitlab-managed-apps
Using Kubernetes executor with image docker:latest ...
Waiting for pod gitlab-managed-apps/runner-3grxukpt-project-18-concurrent-1m7ttl to be running, status is Pending
Running on runner-3grxukpt-project-18-concurrent-1m7ttl via runner-gitlab-runner-5b8d5bf7db-5phqs...
Initialized empty Git repository in /builds/X/test/.git/
Fetching changes...
Created fresh repository.
From https://gitlab.X.com/X/test
 * [new branch]      master     -> origin/master
Checking out 72b6895d as master...

Skipping Git submodules setup
$ docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Login Succeeded
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

$ docker build --pull -t "$CI_REGISTRY_IMAGE" .
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
ERROR: Job failed: command terminated with exit code 1

.gitlab-ci.yml:

# This file is a template, and might need editing before it works on your project.
# Official docker image.
image: docker:latest

services:
  - docker:dind

before_script:
  - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY

build-master:
  stage: build
  script:
    - docker build --pull -t "$CI_REGISTRY_IMAGE" .
    - docker push "$CI_REGISTRY_IMAGE"
  only:
    - master

build:
  stage: build
  script:
    - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
    - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
  except:
    - master

Please advise.

asked Jun 8, 2019 at 19:40

alexus's user avatarGeorge Paoli@george.linearsistemas

ERROR: Job failed: exit code 1

Summary

Script executed with success, but job fail.

Steps to reproduce

Here is my attempt, you can check the error, an error message appears: «ERROR: Job failed: exit code 1»

Actual behavior

An error message appears: «ERROR: Job failed: exit code 1»

Expected behavior

Show message «code coverage done!», from my last script configured in .gitlab-ci.yml

Relevant logs and/or screenshots

screenshots

.gitlab-ci.yml source:

image: microsoft/dotnet

stages:
  - build_and_test

build-modulo-materiais:
  stage: build_and_test
  script:
    - cd v1/materiais
    - dotnet build src/api/api.csproj
    - dotnet build test/test.csproj
    - dotnet restore tools/tools.csproj
    - cd tools
    - dotnet minicover instrument --workdir ../ --assemblies test/**/bin/**/*.dll --sources src/**/*.cs
    - dotnet minicover reset
    - dotnet test ../test/test.csproj --no-build
    - dotnet minicover uninstrument --workdir ../
    - dotnet minicover report --workdir ../ --threshold 90 ## JOB FAIL HERE, BUT SCRIPT EXECUTED WITH SUCCESS
    - echo "code coverage done!"

Environment description

Are you using shared Runners on GitLab.com? Yes
Please, see complete in https://gitlab.com/linear-back/pocs/estrutura-projetos-testes-ci-cd/-/jobs/53438671

Used GitLab Runner version

Running with gitlab-runner 10.5.0-rc1 (7a8e43fe)
  on docker-auto-scale (e11ae361)
Using Docker executor with image microsoft/dotnet ...

Edited Feb 20, 2018 by George Paoli

Overview

This drove me crazy and I’m still not sure what the appropriate answer is. I just ran into this issue myself and sunk hours into this issue. I think GitLab messed something up with command substitution (shows a new release yesterday), although I could be wrong about the issue or its timing. It also seems to only occur for some command substitutions and not others, I initially suspected it might be related to outputting to /dev/null, but wasn’t going to dive too deep. It always failed immediately after the command substitution was initiated.


My code

I had code similar to yours (reduced version below), tried manipulating it multiple ways, but each use of command substitution yielded the same failure message:

Cleaning up file based variables          00:01
ERROR: Job failed: exit code 1

Attempts I’ve made include the following:

- folders=$(find .[^.]* * -type d -maxdepth 0 -exec echo {} ; 2>/dev/null)
- >
  while read folder; do
      echo "$folder"
  done <<< "$folders"

And …

- >
  while read folder; do
      echo "$folder"
  done <<< $(find .[^.]* * -type d -maxdepth 0 -exec echo {} ; 2>/dev/null)

Both those versions succeeded on my local machine, but failed in GitLab (I might have typos in above — please don’t scrutinize, it’s reduced version of my actual program).


How I fixed it

Rather than using command substitution $(...), I instead opted for process substitution <(...) and it seems to be working without issue.

- >
  while read folder; do
      echo "$folder"
  done < <(find .[^.]* * -type d -maxdepth 0 -exec echo {} ; 2>/dev/null)

I would try to substitute the same in your code if possible:

- >
  while read dir; do
      # the rest goes here
  done < <(git log -m -1 --name-only -r --pretty="format:" "$CI_COMMIT_SHA")

The issue might also be the line inside the if statement (the echo), you can replace that with the following:

read SERVICE < <(echo "$dir")

Again, not exactly sure this will fix the issue for you as I’m still unsure what the cause is, but it resolved my issue. Best of luck.

I followed Connecting GitLab with a Kubernetes cluster | GitLab and
GitLab Runner and now trying to follow GitLab CI/CD Pipeline Configuration Reference, yet running into following error:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is
the docker daemon running?

job:

Running with gitlab-runner 11.10.1 (1f513601)
  on runner-gitlab-runner-5b8d5bf7db-5phqs 3gRXuKPT
Using Kubernetes namespace: gitlab-managed-apps
Using Kubernetes executor with image docker:latest ...
Waiting for pod gitlab-managed-apps/runner-3grxukpt-project-18-concurrent-1m7ttl to be running, status is Pending
Running on runner-3grxukpt-project-18-concurrent-1m7ttl via runner-gitlab-runner-5b8d5bf7db-5phqs...
Initialized empty Git repository in /builds/X/test/.git/
Fetching changes...
Created fresh repository.
From https://gitlab.X.com/X/test
 * [new branch]      master     -> origin/master
Checking out 72b6895d as master...

Skipping Git submodules setup
$ docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Login Succeeded
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

$ docker build --pull -t "$CI_REGISTRY_IMAGE" .
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
ERROR: Job failed: command terminated with exit code 1

.gitlab-ci.yml:

# This file is a template, and might need editing before it works on your project.
# Official docker image.
image: docker:latest

services:
  - docker:dind

before_script:
  - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY

build-master:
  stage: build
  script:
    - docker build --pull -t "$CI_REGISTRY_IMAGE" .
    - docker push "$CI_REGISTRY_IMAGE"
  only:
    - master

build:
  stage: build
  script:
    - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
    - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
  except:
    - master

Please advise.

asked Jun 8, 2019 at 19:40

alexus's user avatar

alexusalexus

7,20611 gold badges44 silver badges66 bronze badges

2

in my case I had to add following variables into .gitlab-ci.yml:

services:
  - docker:dind

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

answered Jun 11, 2019 at 19:58

alexus's user avatar

alexusalexus

7,20611 gold badges44 silver badges66 bronze badges

GitLab CI is a powerful continuous integration and continuous delivery tool that helps developers automate the process of building, testing, and deploying software. However, sometimes developers might encounter errors while using GitLab CI. One such error is the «Error loading key ‘/dev/fd/63’: invalid format» error, which occurs when the runner is unable to load the private key. This error can prevent the runner from accessing the repository and executing the jobs, causing the job to fail with an exit code 1.

Method 1: Update the runner’s SSH Key

To fix the «Gitlab Ci: how to fix GITLAB CI Error loading key «/dev/fd/63″: invalid format ERROR: Job failed: exit code 1?» error by updating the runner’s SSH key, follow these steps:

  1. First, generate a new SSH key for the runner. You can use the following command to generate a new key:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  1. Once the key is generated, copy the public key to your GitLab account. You can do this by going to your GitLab account settings, selecting «SSH Keys», and then adding the public key.

  2. Next, update the GitLab runner configuration file to use the new SSH key. You can do this by adding the following lines to the [runners.ssh] section of the configuration file:

identity_file = /path/to/private/key

Replace /path/to/private/key with the path to the private key file that was generated in step 1.

  1. Finally, restart the GitLab runner to apply the changes.
sudo gitlab-runner restart

After following these steps, the «Gitlab Ci: how to fix GITLAB CI Error loading key «/dev/fd/63″: invalid format ERROR: Job failed: exit code 1?» error should be resolved.

Method 2: Check the Key Permissions

One of the reasons for this error is incorrect file permissions on the SSH private key. Here are the steps to check and fix the key permissions:

  1. Check the current permissions of the SSH private key file using the ls -l command:
ls -l /path/to/private/key
  1. The output should look something like this:
-rw-------  1 user  user  1675 Aug  3 11:22 /path/to/private/key
  1. The permissions should be set to 600 (-rw——-) for the owner of the file. If the permissions are incorrect, you can change them using the chmod command:
chmod 600 /path/to/private/key
  1. Verify that the permissions have been set correctly using the ls -l command again:
ls -l /path/to/private/key
  1. The output should now show the correct permissions:
-rw-------  1 user  user  1675 Aug  3 11:22 /path/to/private/key
  1. Finally, try running the Gitlab CI pipeline again to see if the error has been resolved.

That’s it! By checking and fixing the key permissions, you should be able to resolve the Gitlab CI Error loading key «/dev/fd/63»: invalid format ERROR: Job failed: exit code 1.

Method 3: Specify the Key in the GitLab CI/CD Configuration

To fix the «Gitlab Ci: how to fix GITLAB CI Error loading key «/dev/fd/63″: invalid format ERROR: Job failed: exit code 1?» error by specifying the key in the GitLab CI/CD configuration, follow these steps:

  1. Create a new environment variable in your GitLab project’s settings with the name SSH_PRIVATE_KEY and the value of your private key.

  2. In your .gitlab-ci.yml file, add the following code:

deploy:
  stage: deploy
  image: alpine
  before_script:
    - apk add --update openssh-client
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d 'r' | ssh-add - > /dev/null
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - ssh-keyscan example.com >> ~/.ssh/known_hosts
  script:
    - ssh user@example.com "echo hello world"
  1. Replace example.com with your server’s hostname or IP address, and user with your SSH username.

  2. Commit and push your changes to GitLab.

This configuration sets up an SSH agent, adds your private key to it, and configures SSH to trust your server’s host key. The script section can be replaced with your actual deployment commands.

Note that if your private key has a passphrase, you will need to add the passphrase to the SSH agent manually or use a different method to provide the passphrase.

Method 4: Use a Different Key for the Runner

To fix the «Gitlab Ci: how to fix GITLAB CI Error loading key «/dev/fd/63″: invalid format ERROR: Job failed: exit code 1?» error, you can use a different key for the runner. Here are the steps to do it:

  1. Generate a new SSH key using the following command:
ssh-keygen -t rsa -C "your_email@example.com" -f my_new_key
  1. Add the new key to your GitLab account by copying the contents of the my_new_key.pub file and pasting it into the «SSH Keys» section of your GitLab profile.

  2. In your GitLab CI/CD configuration file (.gitlab-ci.yml), add the following lines to specify the new key:

variables:
  SSH_PRIVATE_KEY: /path/to/my_new_key
  1. Update the GitLab Runner configuration to use the new key by adding the following lines to the config.toml file:
[[runners]]
  name = "My Runner"
  url = "https://gitlab.com/"
  token = "my_token"
  executor = "shell"
  [runners.ssh]
    identity_file = "/path/to/my_new_key"
  1. Restart the GitLab Runner for the changes to take effect.

With these steps, you should be able to use a different key for the runner and fix the «Gitlab Ci: how to fix GITLAB CI Error loading key «/dev/fd/63″: invalid format ERROR: Job failed: exit code 1?» error.

Запускаю karma тесты для Angular в gitlab CI.

.gitlab-ci.yml:

image: node:14.0.0

cache:
  paths:
    - node_modules/

before_script:
  - npm install
  - apt-get update -qq
  - apt-get install -y -qq rsync
  - apt-get install -y -qq sshpass
  - wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
  - apt install ./google-chrome-stable_current_amd64.deb -y

stages:
  - testing_deploy


build_and_deploy_testing:
  stage: testing_deploy
  script:
    - echo "============== ADD DEVELOP SSH KEY =============="
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d 'r' | ssh-add - > /dev/null
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - echo -e "Host *ntStrictHostKeyChecking nonn" > ~/.ssh/config
    - echo "============== START BUILD AND DEPLOY TESTING =============="
    - ./node_modules/@angular/cli/bin/ng test --progress false --watch=false

Failed job сообщение:

12 01 2021 16:25:31.828:ERROR [launcher]: Cannot start Chrome
    [2172:2172:0112/162531.552480:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

12 01 2021 16:25:31.829:ERROR [launcher]: Chrome stdout: 
12 01 2021 16:25:31.829:ERROR [launcher]: Chrome stderr: [2172:2172:0112/162531.552480:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

12 01 2021 16:25:31.840:ERROR [launcher]: Chrome failed 2 times (cannot start). Giving up.
Cleaning up file based variables
ERROR: Job failed: exit code 1

Как это исправить?

Понравилась статья? Поделить с друзьями:
  • Error heater scania автономка код ошибки
  • Error file write operation failed код ошибки 11
  • Error file read operation failed ошибка 6 как исправить
  • Error file not found with singular glob ошибка gulp
  • Error expected unqualified id before for ошибка