Running `fdk pack` on gitlab CI fails with error

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.

1 Like

Hey @radudascalu,

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.

I did see you raised another concern about fdv v8.4.0 restricting your dependency package from a private registry, is this the only reason were trying with fdk v8.2.0 or any other specific reason also contributed in downgrading fdk?

2 Likes

Hey @zach_jones_noel, Yes, that is the only reason why I was trying to use fdk v8.2.0.

Thanks @radudascalu for confirming about it.

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?

And about the private registry from GitLab, we have not supported that in previous versions of fdk as well.

Hi @zach_jones_noel ,

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.

Hey @radudascalu,

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.

Hi @zach_jones_noel,

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.

fdk-gitlab.log (3.4 KB)
fdk-local.log (20.2 KB)
gitlab-output-raw.txt (53.1 KB)

Thanks for the logs @radudascalu.

Hi @radudascalu,

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?

1 Like

Hi @zach_jones_noel ,

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.

job.txt (53.1 KB)
fdk.log (3.5 KB)

Thanks for the logs @radudascalu, we will check internally and get back to you.

Hey @radudascalu,

I understand this is taking longer than expected, thanks for understanding and patience. :slight_smile:

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?

Hi @zach_jones_noel ,

As far as I know we didn’t add any sort of ‘addon’ in our app’s root directory. What exactly should this be? A file or a folder?

Hi @radudascalu,

.fdk is a directory in your app’s root directory which contains these addons. Will DM you for more details.

Hi @radudascalu,

We were able to replicate the issue and looks like your build script is missing a fdk command that downloads the addon.

Sharing the modified build script snippet.

build:
  stage: release
  script:
    - cp .npmrc.dist .npmrc
    - fdk
    - fdk pack
  artifacts:
    paths:
      - dist/*-widget.zip

This should resolve your issue.

Another check points for this is -

  • Ensuring your GitLab scripts have home directory write access.
  • Ensuring GitLab has access to download files from S3.

Let us know if you were able to successfully build from your GitLab CI.

2 Likes

Thank you @zach_jones_noel , it finally works now! simply running fdk before fdk pack was the missing part.

1 Like

Awesome! Thanks for confirming @radudascalu :slight_smile:

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.