CI Runner - use G++ 4.8 for npm install step - node.js

I want to have CI Runner use G++ 4.8 for npm install step. I am messing around witht he .gitlab-ci.yml - here is my current version:
before_script:
- . /etc/profile.d/_environment.sh
- . /etc/profile.d/runner.sh
- nvm use v5.3.0
build:
script:
- scl enable devtoolset-2 bash
- g++ --version
- npm install
- gulp build
tags:
- shell
style-analysis:
script:
- gulp style
tags:
- shell
Unforutnately my build is failing. The step "scl enable devtoolset-2 bash" should sweitch to G++ 4.8 and it does when I runner it on the console directly. The next line "g++ --version" is meant to capture the version so I can debug what is happening here. It is not show version 4.8 instead 4.4. Whcih will cause my build to fail. Here is the "head" of the output
gitlab-ci-multi-runner 0.7.2 (998cf5d)
Using Shell executor...
Running on hqdevrunner01...
Fetching changes...
Removing node_modules/
HEAD is now at 082a6fa remove allow failure
From https://hqdevgit01.services.com/operations/-technical-operations-portal
082a6fa..9e36ed9 master -> origin/master
Checking out 9e36ed91 as master...
Previous HEAD position was 082a6fa... remove allow failure
HEAD is now at 9e36ed9... g++4.8 and c++ 11 feaures enabled as part of build
$ . /etc/profile.d/_environment.sh
$ . /etc/profile.d/runner.sh
$ nvm use v5.3.0
Now using node v5.3.0 (npm v3.3.12)
$ scl enable devtoolset-2 bash
$ npm install
npm WARN deprecated lodash#1.0.2: lodash#<2.0.0 is no longer maintained. Upgrade to lodash#^3.0.0
npm WARN install Couldn't install optional dependency: Unsupported
npm WARN engine xmlbuilder#2.4.4: wanted: {"node":"0.8.x || 0.10.x || 0.11.x"} (current: {"node":"5.3.0","npm":"3.3.12"})
npm WARN deprecated lodash-node#2.4.1: This package is no longer maintained. See its readme for upgrade details.
> ursa#0.9.1 install /home/gitlab-runner/builds/6acc3401/0/operations/-technical-operations-portal/node_modules/chef-api/node_modules/ursa
> node-gyp rebuild
make: Entering directory `/home/gitlab-runner/builds/6acc3401/0/operations/-technical-operations-portal/node_modules/chef-api/node_modules/ursa/build'
CXX(target) Release/obj.target/ursaNative/src/ursaNative.o
In file included from ../src/ursaNative.h:10,
from ../src/ursaNative.cc:3:
../node_modules/nan/nan.h:41:3: error: #error This version of node/NAN/v8 requires a C++11 compiler
In file included from /home/gitlab-runner/.node-gyp/5.3.0/include/node/node.h:42,
from ../src/ursaNative.h:9,
from ../src/ursaNative.cc:3:
It looks as though the value from one step is not carried forward to the next step. For instance - as if they happen in their own shells.

GITLAB is actively working to move this project forward. At this point, the work in one step is not carried forward to other steps. I beleive the theory is that each step can be carried our in parallel on different CI Runners.
My solution: MEGA STEP
build:
script:
- scl enable devtoolset-2 bash
- g++ --version
- npm install
- gulp build
- gulp style
tags:
- shell
Its a work arond for now.

Related

Anyone else getting this error? .... Error: std::bad_alloc ... ERROR: job failed exit code 1 deploying Gatsby site

I am new to gatsby and not sure why I am getting this error :
Error: std::bad_alloc ... ERROR: job failed exit code 1. It occurs after the command gatsby build is executed..
**Here is my gitlab-ci.yml (in Visual Studio)
**
`stages: # List of stages for jobs, and their order of execution
- build
- test
- deploy
build-website: # This job runs in the build stage, which runs first.
stage: build
image: node:latest
script:
- echo "Compiling the code..."
- npm install
- npm install -g gatsby-cli
- gatsby build --verbose
artifacts:
paths:
- public
- echo "Compile complete."
unit-test-job: # This job runs in the test stage.
stage: test # It only starts when the job in the build stage completes successfully.
script:
- echo "Running unit tests... This will take about 60 seconds."
- sleep 60
- echo "Code coverage is 90%"
lint-test-job: # This job also runs in the test stage.
stage: test # It can run at the same time as unit-test-job (in parallel).
script:
- echo "Linting code... This will take about 10 seconds."
- sleep 10
- echo "No lint issues found."
deploy-job: # This job runs in the deploy stage.
stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
environment: production
script:
- echo "Deploying application..."
- echo "Application successfully deployed."
**Here is the output and Error: **
`Running with gitlab-runner 15.7.1 (6d480948)
on TODDs-iMac.local 2swxxWzH
Preparing the "docker" executor
00:02
Using Docker executor with image node:latest ...
Pulling docker image node:latest ...
Using docker image sha256:548714e444f4d0c77d9a6bd243b10715663c73425b28ca648a224f5e31510882 for node:latest with digest node#sha256:d5222e1ebd7dd7e9683f47a8861a4711cb4407a4830cbe04a582ca4986245700 ...
Preparing environment
00:01
Running on runner-2swxxwzh-project-41617098-concurrent-0 via TODDs-iMac.local...
Getting source from Git repository
00:05
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /builds/Toddrickson/my-static-website/.git/
Checking out a69c6eb5 as main...
Removing .cache/compiled/
Removing node_modules/.bin/ansi-html
Removing node_modules/#lmdb/lmdb-linux-x64/
Removing node_modules/#msgpackr-extract/msgpackr-extract-linux-x64/
Removing node_modules/#parcel/cache/node_modules/#lmdb/lmdb-linux-x64/
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:35
Using docker image sha256:548714e444f4d0c77d9a6bd243b10715663c73425b28ca648a224f5e31510882 for node:latest with digest node#sha256:d5222e1ebd7dd7e9683f47a8861a4711cb4407a4830cbe04a582ca4986245700 ...
$ echo "Compiling the code..."
Compiling the code...
$ npm install
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: react-server-dom-webpack#0.0.0-experimental-c8b778b7f-20220825
npm WARN Found: react#18.2.0
npm WARN node_modules/react
npm WARN react#"^18.2.0" from the root project
npm WARN 7 more (#gatsbyjs/reach-router, gatsby, gatsby-link, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react#"0.0.0-experimental-c8b778b7f-20220825" from react-server-dom-webpack#0.0.0-experimental-c8b778b7f-20220825
npm WARN node_modules/react-server-dom-webpack
npm WARN react-server-dom-webpack#"0.0.0-experimental-c8b778b7f-20220825" from gatsby#5.2.0
npm WARN node_modules/gatsby
npm WARN
npm WARN Conflicting peer dependency: react#0.0.0-experimental-c8b778b7f-20220825
npm WARN node_modules/react
npm WARN peer react#"0.0.0-experimental-c8b778b7f-20220825" from react-server-dom-webpack#0.0.0-experimental-c8b778b7f-20220825
npm WARN node_modules/react-server-dom-webpack
npm WARN react-server-dom-webpack#"0.0.0-experimental-c8b778b7f-20220825" from gatsby#5.2.0
npm WARN node_modules/gatsby
added 3 packages, changed 1 package, and audited 1363 packages in 9s
212 packages are looking for funding
run `npm fund` for details
14 vulnerabilities (1 low, 12 moderate, 1 high)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
$ npm install -g gatsby-cli
added 328 packages in 18s
53 packages are looking for funding
run `npm fund` for details
$ gatsby build --verbose
verbose 0.689606309 set gatsby_log_level: "verbose"
verbose 0.691542062 set gatsby_executing_command: "build"
verbose 0.692319145 loading local command from: /builds/Toddrickson/my-static-website/node_modules/gatsby/dist/commands/build.js
verbose 3.321975841 running command: build
verbose 3.323810293 Running build in "production" environment
error There was an unhandled error during compilation for /builds/Toddrickson/my-static-website. Please run the command with the --verbose flag again.
std::bad_alloc
Error: std::bad_alloc
not finished compile gatsby files - 0.140s
ERROR: Job failed: exit code 1`
`
**tried making updates .....**
`TODDs-iMac:~ Toddrickson$ docker --version
Docker version 20.10.21, build baeda1f
TODDs-iMac:~ Toddrickson$ gitlab-runner --version
Version: 15.7.1
Git revision: 6d480948
Git branch: 15-7-stable
GO version: go1.18.9
Built: 2022-12-19T12:29:15+0000
OS/Arch: darwin/amd64
TODDs-iMac:~ Toddrickson$ npm --version
8.19.2
TODDs-iMac:~ Toddrickson$ gatsby --version
Gatsby CLI version: 5.1.0
TODDs-iMac:~ Toddrickson$
`
Still getting this error.
I would suggest this question be marked as a duplicate of Why clean install of Gatsby throws warnings for react-server-dom-webpack. It was answered by a man who raised an official issue on Gatsby GitHub page related to those warnings and received an official response by a member of Gatsby team that this issue has everything to do with an experimental build of react-server-dom-webpack which Gatsby is using for Partial Hydration. The official comment on the matter can be found here

/usr/bin/env: “node”: Permission denied

When I use gitlab runner to package node products, an exception occurs.
I tried to provide gitlab runner permission, but it could not solve the problem for me.
Running with gitlab-runner 15.0.0 (febb2a09)
on deepin-wx mxWVNTaN
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:00
Running on deepin-wx...
Getting source from Git repository
Fetching changes with git depth set to 50...
重新初始化已存在的 Git 仓库于 /home/gitlab-runner/builds/mxWVNTaN/0/lich/npm_project_deploy/.git/
Checking out 2530949b as master...
正删除 node_modules/
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:28
$ echo $CI_JOB_STAGE
build
$ whoami
root
$ whereis node
node: /usr/bin/node /root/soft/node-v16.15.0/bin/node
$ node -v
v16.15.0
$ npm config set user 0
$ npm config set unsafe-perm true
$ npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass
$ npm install --registry=http://registry.npm.taobao.org
npm WARN deprecated source-map-url#0.4.1: See supported. Upgrade to v2.x.x.
added 1381 packages in 27s
$ chmod -R 755 ./*
$ npm run build
> npm_project_deploy#0.1.0 build
> vue-cli-service build
/usr/bin/env: “node”: 权限不够
ERROR: Job failed: exit status 1
screenshoot
screenshoot
If you’ve already tried to change the gitlab-runner users permissions - then you could try adding sudo to your npm based commands. I wouldn’t recommend this though.
I think using a shell runner is not the right way to go if you are looking to create real ci (unless you are creating a fresh host for each ci pipeline).
I would recommend looking into the gitlab runner docker executor and using a docker image that has node and the rest of the things you need in an environment set up.

Unable to build job on jenkins for node application

I am using node version 4.4.5 and npm version is 5.3.0.
jenkins version is 2.46.2.
At the time of build I am getting this exception:
/bin/sh -xe /tmp/hudson7756731843340614304.sh
+ PATH=/sbin:/usr/sbin:/usr/bin:/usr/local/bin
+ npm install
/tmp/hudson7756731843340614304.sh: 6: /tmp/hudson7756731843340614304.sh: npm: not found
Build step 'Execute shell' marked build as failure
The execute shell consist of:
#echo "PATH is :$PATH"
#echo "node version is :'node -v' "
#echo "npm version is:'npm -v' "
PATH=/sbin:/usr/sbin:/usr/bin:/usr/local/bin
npm install
npm run coverage
zip -r EngagementSystemNodeApi.zip .
What need to be done plz suggest.
Don't run npm from the commandline. Install and use Jenkins NodeJS plugin. It allows you to configure multiple versions of node and it puts them on the PATH
have you set the enviroment variable in the jenkins machine?

/.bin/webpack Webpack command not found after Node nvm update in prod env

After upgrading my project from using Node v5.0.0 to 6.10.2 (via nvm), my Travis build is now failing with the error:
/home/travis/build/Widen/gray-wolf/node_modules/.bin/webpack --config config/webpack.config.js -p
make: /home/travis/build/Widen/gray-wolf/node_modules/.bin/webpack: Command not found
make: *** [webpack] Error 127
In our MAKE scripts, the commands ultimately being called are as followed:
npm install (this does not seem to be failing)
$(NPM_BIN)/webpack --config config/webpack.config.js -p
Following npm install, one of the lines is:
webpack#2.3.3 node_modules/webpack before the webpack command fails
The ways where this is not failing are
nvm version is set to 5.0.0 instead of 6.10.2
It's in a stage environment instead of prod environment
The initial failure happened alongside a large amount of updated dependencies, so I limited the change to only update Node with nvm with the following commands in my .travis.yml file:
install:
- . $HOME/.nvm/nvm.sh
- nvm install 6.10.2
- nvm use 6.10.2
The only difference being the version number. Following that failure, I'm getting another similar failure with eslint. It seems likely that the failures have the same cause.
make: /home/travis/build/Widen/gray-wolf/node_modules/.bin/eslint: Command not found
If you are in a prod environment but the travis flag of IS_CI is set to true, use the (deprecated) --production=false flag.

How to run Golang and Karma tests within one project on Travis CI

I think my question is related to these ones but the solution did not work in my case: How to run Node.js and Ruby tests within one project on Travis CI and Is it possible to set up travis to run tests for several languages?
I have a github repo that contains a little Golang application with a tiny Angularjs frontend. I want to run both go-tests and Karma-tests.
I see two options:
Run two travis-ci builds for one repo (I could not figure out how to
do that)
Run both tests in one build (did not work since the node version in travis-ci is too old (0.10).
The build runs for 60+ minutes and then stops with "FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory". The build shows tons of warnings like this one: npm WARN engine escodegen#1.8.0: wanted: {"node":">=0.12.0"} (current: {"node":"0.10.36","npm":"1.4.28"})
I tried to run the build as node_js but then the "go get xyz" does not work.
my .travis.yml file:
language: go
go:
- 1.5
env:
- TRAVIS_NODE_VERSION="0.12"
install:
- export PATH=$HOME/gopath/bin:$PATH
- go get golang.org/x/tools/cmd/cover
- go get -v github.com/axw/gocov
- go install github.com/axw/gocov/gocov
- go get github.com/GeertJohan/go.rice
# we do not need the rice tool!
- go get github.com/xeipuuv/gojsonschema
- go get github.com/finklabs/ttime
- go get github.com/finklabs/graceful
- go get github.com/gorilla/mux
before_script:
- npm install bower
- npm install --dev
- bower install
script:
- gocov test | gocov report
- npm test
sometimes the problem sits in front of the machine... I found a great workaround and I want to share it with you.
I created an account on https://drone.io/ in the settings tab I selected a build for "Go1" and added the following commands:
# install gogrinder dependencies
go get ./...
# install test dependencies
go get golang.org/x/tools/cmd/cover
go get -v github.com/axw/gocov
go install github.com/axw/gocov/gocov
# install nodejs requirements
npm -d install
./node_modules/bower/bin/bower install
# run the tests on the go code
gocov test | gocov report
# run the tests on the Angularjs frontend
npm test
Now I am back on track with a CI server that runs both Golang and Karma tests.
I gave a solution to this on http://entulho.fiatjaf.alhur.es/guias/how-to-use-node-along-with-other-language-on-travis-ci/ a long time ago, but it still works today:
Basically you just add
install:
- . $HOME/.nvm/nvm.sh
- nvm install stable
- nvm use stable
- npm install
to your .travis.yml, which must be set to a different language, and it will install node and npm.

Resources