What are the limitations of the forge runtime?

I am trying to use a forge plugin for BitBucket dynamic pipelines. The npm module I am using is a wrapper around an executable binary as it is written in GoLang and there is no pure JS version of this functionality. Therefore, during the npm install, it downloads the correct binary that matches the runtime platform and sticks it in the node_module bin folder. This works locally with “forge tunnel”, but it doesn’t seem to work when deployed to BitBucket. I am thinking there may be some limitations with certain node module in the forge runtime?

Hi @ShawnCastrianni, are you able to provide us with the error that you are running into and if possible, the npm module that you are looking to use?

The npm module I am using is a wrapper around an executable binary as it is written in GoLang and there is no pure JS version of this functionality

Also, are you aware of how your Node.js application is interfacing with this GoLang binary?

I cannot find any error when testing within BB. The plugin just tries to execute the golang binary and returns an exit code of 1. The npm module is node-ytt-cli which can process yaml files with special annotations. This npm module has an install hook function to install the binary into the nodule_module/bin folder and tries to execute that binary during normal operation with another nodule module called shelljs using shell.exec(). The source code of this node module is very small and located here: GitHub - daretodave/node-ytt.

By the way, I am trying to use this npm module to dramatically extend bitbucket-pipelines.yml capabilities with special ytt annotations that support looping, conditions, etc. BB should have this builtin, but I am trying to what I can in the meantim.

For example, with this ytt functionality, I could write a dynamic pipeline that could process the bitbucket-pipelines.yml that looked like:

#@yaml/text-templated-strings
pipelines:
  branches:
    dynamic:
      #@ for i in range(0, 5):
      - step:
          name: Step (@= str(i) @)
          script:
            - echo "This is step (@= str(i) @)"
      #@ end

which then produces this:

Hi @ShawnCastrianni, sorry for the late reply and thanks for the additional context.

It’s a bit hard for me to figure out what caused the command to exit with a code of 1, as I am unaware of how your app is using the binary.

Are you able to modify the node-ytt package a bit by adding a console.log for what was written to stdout and stderr for the exec call, i.e. update the line to something like:

console.log(`stderr: ${result.stderr}`);
console.log(`stdout: ${result.stdout}`);

before it throws due to the return code being non-0.