CI pipeline failure - ERROR: Job failed: exit code 127

I have setup a yml file for CI but the job fails.
See the last few lines at the end of the build step below:

$ npm install netlify-cli -g
/bin/sh: eval: line 146: npm: not found
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 127

When looking at the build failure, it seems the issue is that it can’t install node.js/npm after it installed Plenit at line 12.

- npm install netlify-cli -g

  1. Firstly this install needed? I did install the Netlify cli globally on my PC in the set up process.
  2. If it is required, then could we use an image that includes Node.js and npm such as image: node:latest

See screenshot of the error:

The following is my yml configuration:

default:
   image: docker:stable

pages:
    before_script:
       - apk add --update curl wget && rm -rf /var/cache/apk/*
    stage: deploy
    script:
       - wget -c $(curl -s https://api.github.com/repos/plentico/plenti/releases/latest | grep -o 'http.*linux_64-bit.tar.gz')
       - tar -zxvf *_linux_64-bit.tar.gz
       - ./plenti build
       - npm install netlify-cli -g
       - netlify deploy --prod --dir deploy/public --site=${{ secrets.NETLIFY_SITE_ID }} --auth=${{ secrets.NETLIFY_AUTH_TOKEN }} --timeout=600 --message "Deployed on $(date)"
    artifacts:
      paths:
        - public
    only:
       - main

I referenced the docs from the suggested Plenti pipeline configuration.

This is my first time to configure such a build step so any help is much appreciated.
Best regards,
Ben

@jamestagal it doesn’t look like you have Node/NPM installed on the container. Try changing the image from image: docker:stable to image: node:latest. Or you could install NodeJS manually if you wanted to: node.js - How to install nodejs to install a npm package in a gitlab job? - Stack Overflow

Thanks Jim. That solved the node issue but still not able to pass the build step.

Here’s the log now:

plenti
$ ./plenti build
Total build took 3.568682672s
$ npm install netlify-cli -g
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
added 1280 packages in 18s
210 packages are looking for funding
  run `npm fund` for details
/usr/bin/bash: line 153: --site=${{ secrets.NETLIFY_SITE_ID }}: bad substitution
$ netlify deploy --prod --output ./public --site=${{ secrets.NETLIFY_SITE_ID }} --auth=${{ secrets.NETLIFY_AUTH_TOKEN }} --timeout=600 --message "Deployed on $(date)"
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1

Any ideas?
Thanks
Ben

Now the CI process is passing from Gitlab :slight_smile: but failing in Netlify build step:

12:50:37 AM: ────────────────────────────────────────────────────────────────
12:50:37 AM: ​
12:50:37 AM: ❯ Version
12:50:37 AM:   @netlify/build 29.35.1
12:50:37 AM: ​
12:50:37 AM: ❯ Flags
12:50:37 AM:   baseRelDir: true
12:50:37 AM:   buildId: 65d35c9285b80e10c7954b7f
12:50:37 AM:   deployId: 65d35c9285b80e10c7954b81
12:50:37 AM: ​
12:50:37 AM: ❯ Current directory
12:50:37 AM:   /opt/build/repo
12:50:37 AM: ​
12:50:37 AM: ❯ Config file
12:50:37 AM:   /opt/build/repo/netlify.toml
12:50:37 AM: ​
12:50:37 AM: ❯ Context
12:50:37 AM:   production
12:50:37 AM: ​
12:50:37 AM: build.command from netlify.toml                               
12:50:37 AM: ────────────────────────────────────────────────────────────────
12:50:37 AM: ​
12:50:37 AM: $ ./plenti build
12:50:37 AM: bash: ./plenti: No such file or directory
12:50:37 AM: ​
12:50:37 AM: "build.command" failed                                        
12:50:37 AM: ────────────────────────────────────────────────────────────────
12:50:37 AM: ​
12:50:37 AM:   Error message
12:50:37 AM:   Command failed with exit code 127: ./plenti build (https://ntl.fyi/exit-code-127)
12:50:37 AM: ​
12:50:37 AM:   Error location
12:50:37 AM:   In build.command from netlify.toml:
12:50:37 AM:   ./plenti build
12:50:37 AM: ​
12:50:37 AM:   Resolved config
12:50:37 AM:   build:
12:50:37 AM:     command: ./plenti build
12:50:37 AM:     commandOrigin: config
12:50:37 AM:     publish: /opt/build/repo/public
12:50:37 AM:     publishOrigin: config
12:50:37 AM:   functionsDirectory: /opt/build/repo/netlify/functions
12:50:38 AM: Failed during stage "building site": Build script returned non-zero exit code: 2
12:50:38 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:50:38 AM: Failing build: Failed to build site
12:50:38 AM: Finished processing build request in 15.61s

Hi @jamestagal, I’m confused, what is the Netlify build step? Is a build actually taking place on Netlify? There shouldn’t be any build happening directly on Netlify, it should all happen in GitLab CI instead as discussed here: Netlify backend for CMS Β· Issue #262 Β· plentico/plenti Β· GitHub. Does that make sense? Thanks!

Hi Jim. Yes good question.
When I went through the setup of linking Netlify to the project I do remember being asked questions like:

? Your build command (hugo build/yarn run build/etc): ./plenti build
? Directory to deploy (blank for current dir): public
? No netlify.toml detected. Would you like to create one with these build settings? Yes

This might be the problem.
I have stoppped the builds in Netlify now. Below is a screenshot of the build setttings. Should I delete or clear out the setting here entirely?

Should I delete the netlify.toml file?

Cheers,
Ben

I think as long as the builds are β€œstopped” you should be fine: Stop or activate builds | Netlify Docs. I mean you probably could technically even leave them on, they’ll just fail every time a change is made. Do you see the builds from GitLab appearing in Netlify?

Hi Jim,
yes I see the build complete in Netlify though the initializing fails.

See screenshot.

When looking at the url. https://inspiredfencing.netlify.app/ css or something is missing and if you click on one of the site’s pages it appends that route to the url like https://inspiredfencing.netlify.app/inspiredfencing/about

So possibly there is a issue with the folder structure of the build? It is probably the baseurl causing the issue. Should I remove it from the settings in Netlify and or from my project’s plenti.json file? See screenshot from pervious post for Netlify build settings.

Cheers,
Ben

What are the GitLab CI logs saying?

passed:

$ ./plenti build
Total build took 3.5136396s
$ npm install netlify-cli -g
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
added 1280 packages in 16s
210 packages are looking for funding
  run `npm fund` for details
$ netlify deploy --dir ./public --site $NETLIFY_SITE_ID --auth $NETLIFY_AUTH_TOKEN --prod --timeout=600 --message "Deployed on $(date)"
(node:131) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Deploy path:        /builds/jamestagal/inspiredfencing/public
Functions path:     /builds/jamestagal/inspiredfencing/netlify/functions
Configuration path: /builds/jamestagal/inspiredfencing/netlify.toml
Functions folder "/builds/jamestagal/inspiredfencing/netlify/functions" specified but it doesn't exist! Will proceed without deploying functions
Deploying to main site URL...
- Uploading blobs to deploy store...
​
Netlify Build                                                 
────────────────────────────────────────────────────────────────
​
❯ Version
  @netlify/build 29.33.7
​
❯ Flags
  auth: nfp_3sLVKiQvydUxTuukiYLkr5b9EJzfTYiA4a8e
  deployId: 65d35ba68011b511a3cdc3d5
  dir: ./public
  message: Deployed on Mon Feb 19 13:46:11 UTC 2024
  open: false
  prod: true
  prodIfUnlocked: false
  site: de91722a-c66e-44b9-9861-173a8a4d985e
  skipFunctionsCache: false
  timeout: 600
​
❯ Current directory
  /builds/jamestagal/inspiredfencing
​
❯ Config file
  /builds/jamestagal/inspiredfencing/netlify.toml
​
❯ Context
  dev
βœ” Finished uploading blobs to deploy store
- Hashing files...
- Looking for a functions cache...
βœ” No cached functions were found
βœ” Finished hashing 
- CDN diffing files...
βœ” CDN requesting 9 files
- Uploading 9 files
βœ” Finished uploading 9 assets
- Waiting for deploy to go live...
βœ” Deploy is live!
Build logs:        https://app.netlify.com/sites/inspiredfencing/deploys/65d35ba68011b511a3cdc3d5
Function logs:     https://app.netlify.com/sites/inspiredfencing/functions
Unique deploy URL: https://65d35ba68011b511a3cdc3d5--inspiredfencing.netlify.app
Website URL:       https://inspiredfencing.netlify.app
Uploading artifacts for successful job
00:03
Uploading artifacts...
public: found 223 matching artifact files and directories 
WARNING: Upload request redirected                  location=https://gitlab.com/api/v4/jobs/6204312074/artifacts?artifact_format=zip&artifact_type=archive new-url=https://gitlab.com
WARNING: Retrying...                                context=artifacts-uploader error=request redirected
Uploading artifacts as "archive" to coordinator... 201 Created  id=6204312074 responseStatus=201 Created token=glcbt-65
Cleaning up project directory and file based variables
00:01
Job succeeded

I notice that there is no Netlify functions folder so not sure if that is an issue?

Oh that’s good! So is it actually working on Netlify? Is the site showing up?

Yes. though something is broken.
And as I said above clicking on one of the routes appends that to the url. See screeenshot below.
https://inspiredfencing.netlify.app/

You want it to be https://inspiredfencing.netlify.app/about not https://inspiredfencing.netlify.app/inspiredfencing/about right? Just remove all the baseurl stuff:

  • settings in plenti.json
  • {env.baseurl} in layouts/global/head.svelte (or wherever you’re defining your html <head>

ok
after removing the baseurl from the project, the GitLab CI fails.

$ ./plenti build
Total build took 3.572814098s
$ npm install netlify-cli -g
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
added 1280 packages in 17s
210 packages are looking for funding
  run `npm fund` for details
$ netlify deploy --dir ./public --site $NETLIFY_SITE_ID --auth $NETLIFY_AUTH_TOKEN --prod --timeout=600 --message "Deployed on $(date)"
(node:132) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
 β€Ί   Error: Site not found. Please rerun "netlify link"
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1

I see the ```Please rerun β€œnetlify link” so I did that locally:

 netlify link
(node:77905) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Site already linked to "inspiredfencing"
Admin url: https://app.netlify.com/sites/inspiredfencing

This time the GitLab CI passed:

And Success! :smiley:
https://inspiredfencing.netlify.app/
Thanks Jim. That worked removing the baseurl settings.

I really appreciate your time to look at this.

Excellent! I’m glad it worked!

If you run into that error again (DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.), you might be able to change the version of node you’re using: node.js - punycode is deprecated in npm - what should I replace it with? - Stack Overflow

1 Like

Hallo sir, please help me i get error