Build & Deploy Your MTA

Run cds build to compile the CDS model, use mbt to package the MTA archive, and deploy with cf deploy. Understand what each step produces.

Build & Deploy Your MTA

Deploying a CAP app to BTP is a three-step process: compile → package → deploy.

Step 1 — Install the MTA Build Tool

npm install -g mbt
mbt --version   # 1.x.x

Step 2 — Run cds build

cds build compiles your .cds model into deployable artifacts:

cds build --production

This creates a gen/ folder:

gen/
├── srv/        ← compiled Node.js service (ready for CF push)
│   ├── package.json
│   └── ...
└── db/         ← compiled HANA artifacts (hdbcds, hdbtable)
    └── src/

Always run cds build before packaging — the gen/ folder is what gets deployed, not your source.

Step 3 — Build the MTA archive

mbt build

This reads mta.yaml, runs any build commands, and produces:

mta_archives/
└── my-cap-app_1.0.0.mtar    ← the deployable archive

The .mtar is a ZIP file containing all modules and their manifests.

Step 4 — Deploy to Cloud Foundry

# Install the CF MTA plugin (once)
cf install-plugin multiapps

# Deploy
cf deploy mta_archives/my-cap-app_1.0.0.mtar

The deployer:
1. Creates service instances listed in resources (if they don't exist)
2. Uploads each module
3. Binds services to apps
4. Starts apps in dependency order

Monitor the deployment

cf deploy mta_archives/my-cap-app_1.0.0.mtar --retries 0 -f

Flags:
- --retries 0 — fail fast instead of retrying
- -f — skip confirmation prompt (for CI/CD)

Check deployment status

cf mtas          # list all MTAs in current space
cf mta my-cap-app  # details of one MTA

Full build + deploy script

Save as deploy.sh:

#!/bin/bash
set -e

echo "▶ Building CDS model..."
cds build --production

echo "▶ Packaging MTA..."
mbt build

echo "▶ Deploying to BTP..."
cf deploy mta_archives/*.mtar -f

echo "✅ Done!"
chmod +x deploy.sh
./deploy.sh
Sign in for progress tracking & Q&A →