Hello!
I’m currently trying to run fdk pack in gitlab’s CI pipeline, in order to generate the .zip as an artefact. It unfortunately stops with an error right now.
I’m currently trying to use fdk 8.2.0 as the latest version (8.4.0) doesn’t allow me to use a dependency from a private registry inside manifest.json. The gitlab-ci pipeline file is as following:
default:
image: node:14.17.0
before_script:
- npm config set @express-service:registry=https://gitlab.com/api/v4/packages/npm/
- npm config set -- '//gitlab.com/api/v4/packages/npm/:_authToken' ${NPM_TOKEN}
- npm ci --cache .npm --prefer-offline
- npm config set user 0
- npm config set unsafe-perm true # needed in order to install fdk globally
- npm install https://dl.freshdev.io/cli/fdk-8.2.0.tgz -g
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .npm/
variables:
NPM_TOKEN: ${CI_JOB_TOKEN}
stages:
- release
build:
stage: release
script:
- cp .npmrc.dist .npmrc
- fdk pack
artifacts:
paths:
- dist/*-widget.zip
The error I’m getting is:
$ fdk --skip-update-check pack
(node:176) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'addon' of undefined
at Object.<anonymous> (/usr/local/lib/node_modules/fdk/lib/utils/event-util.js:16:52)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/usr/local/lib/node_modules/fdk/lib/utils/app-util.js:10:19)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/usr/local/lib/node_modules/fdk/lib/cli/validate.js:7:23)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:176) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:176) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Could you please help me understand what I might be doing wrong or why it’s behaving like this in the CI environment? The error doesn’t occur when developing locally.
Thanks for bringing this to our notice! I can truly understand the error at build time result in an unsuccessful CI build, apologies for the roadblock. Let me take a dig at this and get back to you.
It is best recommended to be on the latest version.
However, we will take a look at this. To understand things better, is this error prompted only during your CI build but works good during your local fdk pack?
Thanks for the reply. I just upgraded the pipeline to use the latest fdk version and currently using the following command to pack our custom app: fdk --skip-update-check pack --skip-validation manifest-dependency.
I can confirm that the error is still the same on the gitlab pipeline and that when running locally it works fine.
Thanks for patiently waiting while we are looking at this.
fdk pack --skip-update-check pack --skip-validation manifest-dependency was designed to be a internal flag for us, you can continue to build it locally but we are still checking the error on a pipeline build. You were mentioning that it works fine locally right? Can you share that fdk.log and also the complete log from pipeline build with the same build command (the initial error log shared has fdk pack in the pipeline file).
Just confirming, the node versions on your local development environment and GitLab CI/CD is the same?
Just a heads up - these flags are not part of the best practices to build an app and there could be chances that something might error like in this instance.
I know this issue and the private registry from GitLab build failing are interconnected, I’ll merge the two topics.
Yes, I’m using node 14.17 both locally and in the pipeline. Thanks for the advice, I will work on removing the --skip-validation flag in the future. Please find attached the fdk.log from the local build, from the pipeline build and the full pipeline output from gitlab.
Thanks for your patience while we were checking things internally.
We strongly recommend you to use npm based dependencies and if you need to use private dependencies, then you would have to pack them in the app where the zip file of the complete app can be upto 5MB.
App builds using fdk pack --skip-update-check pack --skip-validation manifest-dependency, like I had previously mentioned these flags were designed for internal purposes and not for a production build. Can you please confirm if the error still persists when you pack the dependencies into the app without external dependencies?
I have finally got rid of the external dependency and of the --skip-validation flag. The error still persists and looks the same. Here are the fdk.log and the Gitlab pipeline log.
I understand this is taking longer than expected, thanks for understanding and patience.
Looks like the app is using an Addon which missing in .fdk can you look into your app’s root directory where this would we and check if the addon is present? If that is available, can you share the addon version?