Yarn install in gitlab pipline - gitlab

I'm using pipline to install my packages and this is my script:
default:
image: node:latest
before_script:
- yarn
Install Dependencies:
stage: install_deps
script:
- yarn
and I got this error:
error An unexpected error occurred:
"https://registry.yarnpkg.com/#ant-design%2ficons: tunneling socket
could not be established, statusCode=407".
What is the problem? What am I doing wrong?

The runner that you are running on - Is that a private runner for your project? 407 means when its trying to reach to the internet, its hitting up against a proxy which requires authentication. You can verify this easyly by running curl on that URL and see the response.

Related

GitLab Runner - ERROR: Failed to remove network for build

Here is my gitlab-ci.yml:
image: vibraniumcore/gcc-cmake-boost-mysqlcon
#image: gitlab/dind
stages:
- test
- build
Run Tests:
stage: test
tags:
- c++
script:
- mkdir build
- cd build
- cmake ..
- cmake --build . --target VibraniumCoreTests
- cd ./Tests
- ./VibraniumCoreTests
Build VibraniumCore:
stage: build
tags:
- c++
script:
- mkdir build
- cd build
- cmake ..
- cmake --build .
Build AuthServer:
stage: build
tags:
- c++
script:
- cd Scripts
- ./build_authserver.sh
Build WorldServer:
stage: build
tags:
- c++
script:
- cd Scripts
- ./build_worldserver.sh
When I try to run my pipeline I get this error:
Running with gitlab-runner 13.1.1 (6fbc7474)
on GCC-CMAKE HdBd6UX6
Preparing the "docker" executor
00:35
ERROR: Failed to remove network for build
ERROR: Preparation failed: error during connect: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.25/info: read unix #->/var/run/docker.sock: read: connection reset by peer (docker.go:894:4s)
Will be retried in 3s ...
ERROR: Failed to remove network for build
ERROR: Preparation failed: error during connect: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.25/info: read unix #->/var/run/docker.sock: read: connection reset by peer (docker.go:894:10s)
Will be retried in 3s ...
ERROR: Failed to remove network for build
ERROR: Preparation failed: error during connect: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.25/info: read unix #->/var/run/docker.sock: read: connection reset by peer (docker.go:894:10s)
Will be retried in 3s ...
ERROR: Job failed (system failure): error during connect: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.25/info: read unix #->/var/run/docker.sock: read: connection reset by peer (docker.go:894:10s)
Any idea why I get this error and how can I fix it?
If you want to have your runner setup with executor="docker", you may encounter the "ERROR: Failed to remove network for build" error if you have not installed docker on your machine hosting the runner.
In Ubuntu, try:
sudo apt install docker.io
And then re-run the pipeline.
I had the same issue.
I used "sudo gitlab-runner register" instead of "gitlab-runner register" and in my case the issue resolved.
This issue is due to the executor="docker" you are using in gitlab runner. try to change to "shell" or "ssh"

Deploying node/express app at DigitalOcean Droplet via CircleCI

I would like to deploy my MERN stack app in DigitalOcean Droplet via CircleCI as CI/CD tool. I read that it needs ssh into the Droplet and run commands for building and deploying the app, but I have tried a several ways to achieve it yet still ends up no luck.
Below is my config.yml for CircleCI
version: 2.1
orbs:
node: circleci/node#4.1.0
jobs:
express_deploy:
docker:
- image: "cimg/node:current"
steps:
- run: node --version
- add_ssh_keys:
fingerprints:
- "$ssh_key_prints"
- run: ssh -oStrictHostKeyChecking=no $username#$ip "cd $directory \ npm install \ node app.js"
workflows:
init:
jobs:
- express_deploy
error: bash: line 0: cd: too many arguments
Some of the others attempts I have tried:
steps:
- run: node --version
- add_ssh_keys:
fingerprints:
- "$ssh_key_prints"
- run: ssh -oStrictHostKeyChecking=no $username#$ip "cd $directory"
- run: npm install
- run: node app.js"
error: module $directory/app.js not found
I wanna know if this approach is wrong or is there a way to fix it?
notes: $ are credential variables that I blurred here, but I tested them independently and they worked fine

WebSocket error when using Playwright on GitLab CI

I am using Playwright with Jest and jest-playwright-preset and trying to get my tests to run in GitLab CI.
My .gitlab-ci.yml:
ui_test:
image: node:latest
script:
- npm install
- npm run test:ui
When I run this locally on my Windows machine everything works fine. However if I try to run in GitLab CI I get the following error:
2020-06-26T21:01:39.770Z pw:api => chromium.launchServer started
2020-06-26T21:01:39.786Z pw:api <= chromium.launchServer succeeded
2020-06-26T21:01:40.182Z pw:api => chromium.connect started
2020-06-26T21:01:40.217Z pw:api <= chromium.connect failed
FAIL browser: chromium ./test.js
● Test suite failed to run
WebSocket error: connect ECONNRESET 127.0.0.1:38267
================== chromium.connect logs ==================
<ws connecting> ws://127.0.0.1:38267/b32ed779b7c87222e0b2b6aa117b0c79
<ws connect error> ws://127.0.0.1:38267/b32ed779b7c87222e0b2b6aa117b0c79 connect ECONNRESET 127.0.0.1:38267
<ws disconnected> ws://127.0.0.1:38267/b32ed779b7c87222e0b2b6aa117b0c79
============================================================
Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs.
at WebSocket.<anonymous> (node_modules/playwright/lib/transport.js:119:24)
at WebSocket.onError (node_modules/playwright/node_modules/ws/lib/event-target.js:128:16)
at ClientRequest.<anonymous> (node_modules/playwright/node_modules/ws/lib/websocket.js:568:15)
EDIT: This has nothing to do with Jest. The same problem will arise when only using Playwright and using the node image instead of the Playwright image.
The node:latest does not have the appropriate system dependencies to run the browsers. You can use the Playwright docker image.
ui-test:
stage: test
image: mcr.microsoft.com/playwright:bionic
script:
- npm install # this should install playwright
- npm run test:ui
(Edited to reflect the official docker image)

Gitlab Preparation failed: Error response from daemon: Conflict. The container name is already in use by container

I am using Gitlab CI in my development for continuous integration. I have my gitlab-runner runnig on a ubuntu instance.
I have one application, where i use MongoDB v3.6. I have to do a database integration test in the test stage of my CI/CD.
prepare:
image: node:11.10.1-alpine
stage: setup
script:
- npm install --quiet node-gyp
- npm install --quiet
- npm install -g yarn
- chmod a+rwx /usr/local/lib/node_modules/yarn/bin/yarn*
- chmod a+rwx /usr/local/bin/yarn*
- yarn install
- cd client
- yarn install
- cd ../
- cd admin
- yarn install
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- node_modules/
- client/node_modules/
- admin/node_modules/
policy: push
app_testing:
image: node:11.10.1-alpine
services:
- name: mongo:3.6
stage: test
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- node_modules/
- client/node_modules/
- admin/node_modules/
script:
- yarn run test
- cd client
- yarn run test
- cd ../
- cd admin
- yarn run test
For every alternate pipeline, i am getting the below error in the app_testing( test ) stage.
ERROR: Job failed (system failure): Error response from daemon: Conflict. The container name "/runner-e7ce6426-project-11081252-concurrent-0-mongo-0" is already in use by container "0964b061b56d8995966f577e7354852130915228bac1a7513a773bbb82aeefaf". You have to remove (or rename) that container to be able to reuse that name.
Below is the full log of the specific job which is failing
Running with gitlab-runner 10.8.0 (079aad9e)
on SharedRunner-XYZGroup e7ce6426
Using Docker executor with image node:11.10.1-alpine ...
Starting service mongo:3.6 ...
Pulling docker image mongo:3.6 ...
Using docker image sha256:57c2f7e051086c7618c26a2998afb689214b4213edd578f82fe4b2b1d19ee7c0 for mongo:3.6 ...
ERROR: Preparation failed: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Will be retried in 3s ...
Using Docker executor with image node:11.10.1-alpine ...
Starting service mongo:3.6 ...
Pulling docker image mongo:3.6 ...
Using docker image sha256:57c2f7e051086c7618c26a2998afb689214b4213edd578f82fe4b2b1d19ee7c0 for mongo:3.6 ...
ERROR: Preparation failed: Error response from daemon: Conflict. The container name "/runner-e7ce6426-project-11081252-concurrent-0-mongo-0" is already in use by container "0964b061b56d8995966f577e7354852130915228bac1a7513a773bbb82aeefaf". You have to remove (or rename) that container to be able to reuse that name.
Will be retried in 3s ...
Using Docker executor with image node:11.10.1-alpine ...
Starting service mongo:3.6 ...
Pulling docker image mongo:3.6 ...
Using docker image sha256:57c2f7e051086c7618c26a2998afb689214b4213edd578f82fe4b2b1d19ee7c0 for mongo:3.6 ...
ERROR: Preparation failed: Error response from daemon: Conflict. The container name "/runner-e7ce6426-project-11081252-concurrent-0-mongo-0" is already in use by container "0964b061b56d8995966f577e7354852130915228bac1a7513a773bbb82aeefaf". You have to remove (or rename) that container to be able to reuse that name.
Will be retried in 3s ...
ERROR: Job failed (system failure): Error response from daemon: Conflict. The container name "/runner-e7ce6426-project-11081252-concurrent-0-mongo-0" is already in use by container "0964b061b56d8995966f577e7354852130915228bac1a7513a773bbb82aeefaf". You have to remove (or rename) that container to be able to reuse that name.
I tried disabling secondary caches, it didn't work for me.
Now i don't know how to fix this issue. As a workaround, i have to trigger a new pipeline every time it fails, which of course no one likes, as the ultimate goal for anyone to automate things is to focus on most important things.
Any help on this would be appreciated.
Thanks in advance.
This is a known issue, see https://gitlab.com/gitlab-org/gitlab-runner/issues/4327. GitLab is re-using the same service container name. This approach fails if the previous container wasn't deleted in time.
If you read through the (long list of) comments you may discover some workarounds of which are among others:
limit concurrency to 1
increase your Runner's machine's IOPS (e.g. switch from HDD to SSD)
As we were facing the same issue with the Docker executor, we currently kind of worked around it by using the Docker+Machine executor. Although you can't really be sure to avoid that error, my experience is that jobs are running more reliably since then. The tradeoff, however, is that for each job a VM is provisioned that wants to be paid.

GitLab CI/Docker on Windows/node container - unknown network http

I'm trying to run basic pipeline that should build my web-project using GitLab CI
My setup:
GitLab CE 10.1.4 on Ubuntu 16.04
GitLab Runner 10.1.0 on Windows 10 1703 with docker executor
Docker 17.09.0-ce-win33 (13620) on same Windows machine
.gitlab-ci.yml:
image: node:latest
cache:
paths:
- node_modules/
build:
script:
- npm install
- npm run build
And I get failed build with this output:
Running with gitlab-runner 10.1.0 (c1ecf97f)
on ****** (9366a476)
Using Docker executor with image node:latest ...
Using docker image sha256:4d72396806765f67139745bb91135098acaf23ce7d627e41eb4da9c62e5d6729 for predefined container...
Pulling docker image node:latest ...
Using docker image node:latest ID=sha256:cf20b9ab2cbc1b6f76e820839ad5f296b4c9a9fd04f3e74651c16ed49943dbc4 for build container...
ERROR: Job failed (system failure): dial http: unknown network http
I've thought that problem might happen because container can't access internet, but https://hub.docker.com/r/byrnedo/alpine-curl/ curl container got the data, so I think it's not the case.
UPD:
Problem occurs when GitLab runner try to attach to container.
Problem was in GitLab CI config (config.toml), docker host.
host = "http://127.0.0.1:2375" - wrong one
should be host = "tcp://127.0.0.1:2375"

Resources