SAP-samples / btp-cap-multitenant-saas

Sample project that demonstrates how to setup a multitenant application for a Software-as-a-Service scenario, leveraging the Kyma and Cloud Foundry Runtimes of the SAP Business Technology Platform. Developers learn how to implement their own CAP (mtxs) based SaaS app including an SaaS API and integration with various essential SAP BTP service of...
Apache License 2.0
89 stars 42 forks source link

Having issue in mbt build command #59

Closed Deepanshu2906 closed 1 month ago

Deepanshu2906 commented 1 month ago

I have implemented a sample Customized project. I have created all UI and backend service without annotations. Added destination to consume some API's from S/4 Hana system on BTP. I have different folder structure that I clone from your repo. while configuring mta.yaml I am facing issue that in many modules you have user path as path: ../../code/gen/srv. I have no gen folder before runnning$ mbt build -e ./mtaext/trial-basic-private.mtaext command . So how to solve that issue. Did I missed any command to generate gen folder inside Code directory before build and deploy ? Please guide.

alperdedeoglu commented 1 month ago

Hi @Deepanshu2906, From what you said, I understand that you have almost entirely different application.

If you want that /gen folders to be generated, you should run following command on the root directory of your application:.

cds build --production

This will build your project accordingly and put your builded artifacts under /gen folder.

MoudhafferMG commented 1 month ago

@alperdedeoglu What about for the BTP CI/CD service? I tried having a custom pre build step but I guess it does not work since it is not stashed for the build.

I chose the MTA build tool. The pipeline will execute the mbt build which is supposed to run a cds build internally (in order to build the db-deployer and srv modules). I found that it's not the case and I have to explicitly add a custom build step in the mta.yaml file.

name: <appname>-db-deployer
# ------------------------------------------------------------
  type: hdb
  path: ./
  requires:
    - name: <appname>-db
  parameters:
    buildpack: nodejs_buildpack
  build-parameters:
    builder: custom
    build-result: gen/db
    commands:
    - npx cds build --production
    ignore: ["node_modules/"]

Running the CI/CD job will halt the job at the MTA validation step (gen/db and gen/srv not found). Creating empty folders in the repo enables to avoid this, but the build artifacts are empty (db-deployer & srv). running the job with the custom script works partially works since the path property of the DB deployer must point to the root, thus the mbt tool will add the entire gen folder in the db-deployer archive. (gen/db/data.zip)

Thanks in advance for your feedback.

alperdedeoglu commented 1 month ago

All documented here, for this specific project.

MoudhafferMG commented 1 month ago

@alperdedeoglu thanks for your reply. Actually I found a good approach to the gen folder and the issues with the mbt build.

in the MTA file I added this :

build-parameters:
  before-all:
    - builder: custom
      commands:
        - npm install
        - npx cds build --production

It works locally, and I no longer have the CI/CD job issue. I guess the mbt tool will run those commands before the MTA validation step thus creating the gen folder and its subfolders, which is exactly what I needed.

Hope this can help someone