Loading

How to deploy a Mule 4 app's JAR file completely via API to RTF

Veröffentlichungsdatum: Nov 18, 2024
Aufgabe

GOAL

You are using Mule 4 and RTF. You want to setup a CI/CD pipeline through API calls to deploy an app into RTF from your current local system.
 
Schritte

1. Run the following curl command to put the JAR file into your Exchange: 

a) Organization ID (<YOUR_ORG_ID>): How to know my Organization ID (Org ID) on the Anypoint Platform
b) Bearer token (<YOUR_ACCESS_TOKEN>): How to generate your Authorization Bearer token for Anypoint Platform
c) Environment ID (<YOUR_ENVIRONMENT_ID>) can be retrieved with this API call.
Example:

$ curl -H "Authorization: Bearer <YOUR_ACCESS_TOKEN>" https://anypoint.mulesoft.com/accounts/api/organizations/<YOUR_ORG_ID>/environments

d) Please refer to the API documentation - https://anypoint.mulesoft.com/exchange/portals/anypoint-platform/f1e97bc6-315a-4490-82a7-23abe036327a.anypoint-platform/exchange-experience-api/minor/2.3/pages/Asset%20Creation/

$ curl -v \
-H 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \
-H 'x-sync-publication: true' \
-F 'files.pom=@/<file-path>/pom.xml' \
-F 'files.mule-application.jar=@/<file-path>/<application-jar>' \
https://anypoint.mulesoft.com/exchange/api/v2/organizations/:organizationId/assets/:groupId/:assetId/:version

3. Final step is to deploy into RTF. Most of the options to fill in are the same repeats as of the previous 2 steps. There are two values to be aware of (targetID and publicUrl):

a) targetID (<TARGET_ID>): The following is the example curl to get targetID of the Runtime Fabric to be deployed in. The value is in the result key "uid".
Example:

$ curl -L -X GET 'https://anypoint.mulesoft.com/runtimefabric/api/organizations/<YOUR_ORG_ID>/fabrics/' \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \
-H 'X-ANYPNT-ORG-ID: <YOUR_ORG_ID>' \
-H 'Connection: keep-alive' 
b) publicUrl (<YOUR_DOMAIN_URL>): This should be the application URL to appear when app is selected from the Runtime Manager. For more information on these settings values (which can differ significantly for your RTF depending on your setup), please take a look at the official API documentation for AMC Application Manager for this endpoint: Link.
c) runtimeVersion (<RUNTIME_VERSION>) value can be retrieved from RTF runtime release notes, or through an API call following the article How to Get Mule Runtime Tags for Latest RTF Runtime Versions Via API.

Here is the final deploy request example:
$ curl -L -X POST 'https://anypoint.mulesoft.com/amc/application-manager/api/v2/organizations/<YOUR_ORG_ID>/environments/<YOUR_ENVIRONMENT_ID>/deployments' \
-H 'Accept: application/json, text/plain, */*' \
-H 'Content-Type: application/json;charset=utf-8' \
-H 'Authorization: bearer <YOUR_ACCESS_TOKEN>' \
-H 'X-ANYPNT-ENV-ID: <YOUR_ENVIRONMENT_ID>' \
-H 'X-ANYPNT-ORG-ID: <YOUR_ORG_ID>' \
-H 'Connection: keep-alive' \
--data-raw '{
    "name": "<APP-NAME>",
    "labels": [
        "beta"
    ],
    "target": {
        "provider": "MC",
        "targetId": "<TARGET_ID>",
        "deploymentSettings": {
            "resources": {
                "cpu": {
                    "reserved": "300m",
                    "limit": "1700m"
                },
                "memory": {
                    "reserved": "3400Mi",
                    "limit": "3400Mi"
                }
            },
            "clustered": false,
            "enforceDeployingReplicasAcrossNodes": false,
            "http": {
                "inbound": {
                    "publicUrl": "<YOUR_DOMAIN_URL>"
                }
            },
            "jvm": {},
            "runtimeVersion": "<RUNTIME_VERSION>",
            "lastMileSecurity": false,
            "updateStrategy": "rolling",
            "disableAmLogForwarding": false
        },
        "replicas": 1
    },
    "application": {
        "ref": {
            "groupId": "<YOUR_ORG_ID>",
            "artifactId": "<APP-NAME>",
            "version": "1.0.0",
            "packaging": "jar"
        },
        "assets": [],
        "desiredState": "STARTED",
        "configuration": {
            "mule.agent.application.properties.service": {
                "applicationName": "<APP-NAME>",
                "properties": {},
                "secureproperties": {}
            }
        }
    }
}'

Note, the AMC Application Manager API 

For more information about the payload properties, please check: Detailed Payload Description and Example for RTF AMC Deployment API

Nummer des Knowledge-Artikels

001115979

 
Laden
Salesforce Help | Article