Gitlab CI execution error but pipeline success - gitlab

I have a simple project .gitlab-ci.yaml
variables:
GIT_STRATEGY: clone
stages:
- build
build-and-run-tests:
stage: build
tags:
- windows
script:
- call npm install
- call npm run build-client-in-target
- call npm run run-tests-on-target
when I start the build pipeline, it fails while executing build-client-in-target, but the pipeline continues with success status

you should move all preprocessing to before_script tag
and remove the call command
https://docs.gitlab.com/ee/ci/yaml/#before_script-and-after_script
variables:
GIT_STRATEGY: clone
stages:
- build
build-and-run-tests:
stage: build
tags:
- windows
before_script:
- npm install
- npm run build-client-in-target
script:
- npm run run-tests-on-targe

Related

How to run GitLab build stages in parallel?

I've been running my end to end script for 3+ hours and i want to shortened it by running it on parallel. I've researched a ton of hours but i can't do it properly cypress cloud is supporting parallelization but this is not my option since it's paid service
I also tried this npm cypress-gitlab-parallel-runner but no luck it runs in series
I also tried it to do manually with different job in the same stage but it runs sequentially
Heres the snippet:
stages:
- build
- test
build:
stage: build
image: cypress/browsers:node18.12.0-chrome107
script:
- npm ci && npm install
test1:
image: cypress/browsers:node18.12.0-chrome107
stage: test
script:
- npm ci
- npm run test-run1
test2:
image: cypress/browsers:node18.12.0-chrome107
stage: test
script:
- npm ci
- npm run test-run2
How can I run an e2e script on parallel?

Gitlab: How to execute multiple stages without installing dependencies again?

I'm trying to configure my gitlab ci to use multiple stages but it just doesnt seem to work. Any idea what needs to be corrected here?
gitlab-ci.yml
cache:
key: "NPM_MODULES_CACHE"
paths:
- $(pwd)/node_modules/
stages:
- install
- test
- build
Install:
stage: install
rules:
- if: '$CI_COMMIT_BRANCH == "aws/pipeline-test"'
script:
- npm install
Test:
stage: test
script:
- npm run test
Build:
stage: build
rules:
- if: '$CI_COMMIT_BRANCH == "aws/pipeline-test"'
script:
- npm run build
artifacts:
paths:
- dist/
First stage execute fine but second and third stages are not executing at all.
ADDITIONALLY:
how can i configure this where 'install' and 'test' stages are executed on code commit from any feature branch, BUT 'build' stage executes only after changes are merged to master branch?? ideally without running npm install between stages
Any help is super appreciated :)

how to continue running scripts if one of them fails? GITLAB CI

here is my yml file:
stages:
- testing
- deploy
docker_job:
stage: testing
tags:
- docker
image: atools/chrome-headless:java11-node14-latest
before_script:
- npm ci
- npx playwright install
- npm install allure-commandline --save-dev
script:
- npm run BookingTestDEV --project=BookingTesting
- npx playwright test --project=BookEngineTests
- npm run BookingTestNEO --project=BookingTesting
after_script:
- npx allure generate allure-results --clean
rules:
- when: always
allow_failure: true
artifacts:
when: always
paths:
- ./allure-report
expire_in: 7 day
pages:
stage: deploy
script:
- mkdir public
- mv ./allure-report/* public
artifacts:
paths:
- public
rules:
- when: always
if first script
- npm run BookingTestDEV --project=BookingTesting fails, other will be skipped, how to run them anyway ? is there any analog of if(): always like on github ?
In most cases, the pipeline should fail if one of the commands throws an exit code that is not 0. However, in some cases, the rest of the commands should run anyway. A possible solution for this would be to add || true at the end of the command.
For example:
script:
- npm run BookingTestDEV --project=BookingTesting || true
- npx playwright test --project=BookEngineTests
- npm run BookingTestNEO --project=BookingTesting

Run deploy automatically when branch receives MR on Gitlab

I want to run automatically my deploy job on Gitlab when my branch receives a merge by merge request. How can I do this?
deploy-tests:
tags:
- aws-sdk
stage: deploy
only:
- stage
cache: {}
script:
- cd ngapp
- call npm ci
- call npm run-script i18n
- call npm run-script lint
- call build.bat tests
- copy .htaccess dist
- copy Web.config dist
- deploy.bat tests
If you want your pipeline to be executed when it receives an MR.
You need to pass the keyword merge_requests at your only clause. (https://docs.gitlab.com/ee/ci/yaml/#onlyrefs--exceptrefs)
Change
deploy-tests:
tags:
- aws-sdk
stage: deploy
only:
- stage
cache: {}
script:
- cd ngapp
...
To
deploy-tests:
tags:
- aws-sdk
stage: deploy
only:
- merge_requests
- stage
cache: {}
script:
- cd ngapp
...

GitLab CI: configure yaml file on NodeJS

I have problem with test scss-lint in my project on nodejs.
When tests reach scss-lint, it gives an error.
How to make sure that tests do not fall with the successful result of the test itself?
My gitlab-ci.yml
image: node:wheezy
cache:
paths:
- node_modules/
stages:
- build
- test
gem_lint:
image: ruby:latest
stage: build
script:
- gem install scss_lint
artifacts:
paths:
- node_modules/
only:
- dev
except:
- master
install_dependencies:
stage: build
script:
- npm install
artifacts:
paths:
- node_modules/
only:
- dev
except:
- master
scss-lint:
stage: test
script:
- npm run lint:scss-lint
artifacts:
paths:
- node_modules/
only:
- dev
except:
- master
You are doing it wrong.
Each job you define (gem_lint, install_dependencies, and scss-lint) is run with its own context.
So your problem here is that during the last step, it doesn't find the scss-lint gem you installed because it switched its context.
You should execute all the scripts at the same time in the same context :
script:
- gem install scss_lint
- npm install
- npm run lint:scss-lint
Of course for this you need to have a docker image that has both npm and gem installed maybe you can find one on docker hub), or you can choose one (for example : ruby:latest) and add as the first script another one that would install npm :
- curl -sL https://deb.nodesource.com/setup_6.x | bash -

Resources