How mulesoft-consulting/mulesoft_deploymentascode works
Project type and purpose
• This is a DevOps/Infrastructure-as-Code framework (called “Mule Deployments as Code”) written in Node.js.
• Its purpose is to manage and automate MuleSoft CloudHub deployments by declaring the desired target state in a YAML file, then using CI/CD to apply that state against Anypoint Platform.
File structure
• Top-level config and CI definitions:
• .circleci/ (CircleCI pipeline config)
• Jenkinsfile (Jenkins pipeline)
• .muleci/ (deployment scripts and shared logic)
• _config.yml (static site or documentation config)
• Source of truth for environment state:
• deployment_descriptor.yml (defines target state: apps, runtimes, workers)
• app_properties/ (per-application property files keyed by branch/environment)
• Miscellaneous support files:
• app_properties/*/*.properties
README for additional insights
• Describes end-to-end flow: commit to Git → CI trigger → execute .muleci/deployment.sh → Anypoint-CLI calls → CloudHub.
• Explains state reconciliation: deploy if missing, update if changed (version, workers, region, properties).
Main components
a. Git repository (configuration repo)
– Contains deployment_descriptor.yml, app_properties/, CI scripts.
b. CI/CD Server(s)
– CircleCI or Jenkins
– Reads .circleci/config.yml or Jenkinsfile
– Runs shell script .muleci/deployment.sh
c. Deployment Framework (Node.js)
– .muleci/mule_common.js, anypoint_deployment_*.js
– Parses descriptor, loads property files, drives Anypoint-CLI
d. Artifact Repository
– Maven-style repo (Nexus, JFrog) where application zip packages are hosted
e. Anypoint-CLI
– Command-line tool interfacing with Anypoint Platform REST APIs
f. CloudHub / Anypoint Runtime Manager
– Target environment where Mule applications are deployed/updated
g. App Properties Store
– Files in app_properties/[app]/[app]-[branch].properties
Relationships and data flows
1. Developer pushes changes to Git (branches per environment).
2. CI/CD server checks out the config repo and runs the pipeline.
3. CI invokes deployment.sh, which in turn:
– Loads deployment_descriptor.yml
– Looks up matching property files under app_properties/
– Calls Node.js scripts in .muleci/
– Invokes Anypoint-CLI commands (login, get/deploy/update applications)
4. Anypoint-CLI communicates with CloudHub APIs to ensure target state.
5. If a new package version is needed, the framework pulls the ZIP from the artifact repository.
Architectural patterns & design principles
• Infrastructure-as-Code: config as the single source of truth, idempotent operations
• GitOps/Declarative approach: commit describes desired state
• Separation of concerns:
• CI pipeline config vs. deployment scripts vs. environment descriptor vs. app properties
• Extensibility: adding new deployment targets or properties by dropping in new JS modules or YAML entries
Diagramming recommendations
• Use clear labels: “Git Repo”, “CI Server”, “.muleci Scripts”, “Artifact Repo”, “Anypoint-CLI”, “CloudHub”
• Git → CI trigger
• CI → Deployment scripts
• Scripts → Anypoint-CLI → CloudHub API
• Scripts → Artifact Repo
• Blue: Source/configuration (Git, YAML, properties)
• Green: Execution/runtime (CI, Node.js)
• Orange: External services (Artifact repo, CloudHub)
• Rectangles for services/processes
• Clouds for external platforms