When your team manages Airflow tasks in DMS, deploying changes manually across environments is error-prone and slow. DMS supports automated CI/CD by integrating with Alibaba Cloud DevOps Flow and Jenkins — so every code push to your repository automatically triggers a deployment to your DMS Airflow workspace.
This tutorial walks you through setting up both pipeline types. Each pipeline uses the dms_cicd_tool binary to call the DMS API and deploy the configured branch to your workspace.
Choose a pipeline
| Tool | When to use |
|---|---|
| Alibaba Cloud DevOps Flow | Your team already uses Alibaba Cloud services and wants a fully managed CI/CD solution within the Alibaba Cloud ecosystem |
| Jenkins | Your team runs an existing Jenkins server or requires a self-hosted CI/CD solution |
Before you begin
Gather the following before starting either pipeline configuration:
An Airflow environment in DMS. See Create and manage an Airflow instance.
Your Alibaba Cloud AccessKey ID and AccessKey secret. See View AccessKey pairs of a RAM user.
Your DMS workspace ID. See Workspace ID.
Your REPOS project ID. See View the REPO project ID.
Your deployment branch name.
Configure an Alibaba Cloud DevOps pipeline
Flow is an enterprise-level, automated continuous integration and continuous delivery tool that helps enterprises automate the entire process from code development to deployment in a production environment, improving development efficiency, accelerating delivery speed, and reducing error rates.
Step 1: Create a pipeline
Log on to the Flow console.Flow
On the My Pipelines page, click Create Pipeline in the upper-right corner. For more information, see Create your first pipeline.
On the Visualization Orchestration tab, select Empty Template in the left navigation pane and click Create.
After the pipeline is created, you are redirected to the pipeline configuration page.
Step 2: Configure a trigger source
Choose one of the following methods to trigger pipeline runs automatically when code is pushed.
Manually configure a webhook
On the pipeline Trigger Settings page, turn on the Webhook Trigger switch.
Copy the generic webhook URL, then click Save Only in the upper-right corner.
In your GitHub repository, go to Settings > Webhooks and click Add webhook.
Paste the webhook URL into the Payload URL field, select a Trigger Type, and click Add webhook. Leave other parameters at their default values.
Associate a GitHub repository
On the Flow ConfigurationFlow page, click Add Pipeline Source.
On the Code Source page, select GitHub and click Add.
On first use, add a service connection to authorize access to GitHub before adding a repository.
Select your code repository and Default Branch, enable Enable Code Source Trigger, and copy the webhook URL.
In the destination GitHub repository, go to Settings > Webhooks and click Add webhook.
Paste the webhook URL into the Payload URL field, select a Trigger Type, and click Add.
Associate a GitLab repository
On the Flow Configuration page, click Add Pipeline Source.
On the Code Source page, select Self-managed GitLab.
Set Code Repository and Default Branch. For Credential Type, select Organization Public Key — this key is generated in your GitLab account settings.
Enable Enable Code Source Trigger and copy the webhook URL.
In the destination GitLab repository, go to Settings > Webhooks, paste the webhook URL into the Webhook URL field, select a trigger source, and click Add Webhook.
Step 3: Configure global environment variables
Global environment variables are available across all task nodes in the pipeline.
On the Flow Edit page, click Variables And Cache.
In the String Variable section, click New Variable.
Add the following variables with their values and click Add.
| Variable name | Required | Description |
|---|---|---|
ALIBABA_CLOUD_ACCESS_KEY_ID | Yes | Your Alibaba Cloud AccessKey ID |
ALIBABA_CLOUD_ACCESS_KEY_SECRET | Yes | Your Alibaba Cloud AccessKey secret |
DMS_CICD_PROJECT_ID | Yes | REPOS project ID of the workspace |
DMS_CICD_BRANCH_NAME | Yes | Deployment branch |
DMS_CICD_WORKSPACE_ID | Yes | Workspace ID |
Step 4: Configure the task flow
Each task node in the flow corresponds to a deployment environment (for example, dev or staging).
On the flow configuration page, select and delete the Empty Task node in Stage 1.
In the new stage, click New Task and select the Execute Command node.
On the node configuration page, set the following parameters. Leave others at their default values. In the task step text box, enter the following script. This script downloads and runs
dms_cicd_tool, which calls the DMS API to deploy the configured branch to your workspace.Parameter Value Task name A name reflecting the environment context, for example, dev environmentBuild cluster Keep the default: Singapore Build Cluster Download pipeline Select Do Not Download Pipeline Sources Task step Enter the script below wget 'https://dms-cicd-tool-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/dms_cicd_tool' chmod +x ./dms_cicd_tool ./dms_cicd_toolIn the Environment Variables section, click Add > Custom Parameter to configure the following optional node-level variables.
These are local variables — they apply only to this task node.
Variable name Description Required Example DMS_CICD_DEPLOY_COMMONRemarks for the deployment task No DEV environment deployment testDMS_CICD_DEPLOY_PARAMAdditional parameters for the deployment task No {"param1":"value1"}To deploy to multiple environments, repeat steps 2–4 to create additional task nodes.
Click Save and Run in the upper-right corner.
Step 5: Run the pipeline and view run history
Once the trigger source is configured, the pipeline runs automatically on each code push. To run it manually, click Save and Run on the pipeline configuration page.
To view run history, go to the run history page and click View to see details for each run, including duration and task node logs. In the task node section, click Log to see the run result and any deployment failure details.
In the Execute Command section of a task node log:
A successful run shows:
XXX successA failed run shows:
XXX failed
Configure a Jenkins pipeline
Step 1: Configure the pipeline script
Log on to Jenkins. If Jenkins is not installed, download it from the official Jenkins website.
In the left navigation pane, click New Item.Save and Run
Enter a task name and select the Pipeline tab.
Replace the placeholder values in the script below with your actual credentials and IDs. Paste the script into the text box and click Save.
ImportantStore sensitive credentials such as
ALIBABA_CLOUD_ACCESS_KEY_IDandALIBABA_CLOUD_ACCESS_KEY_SECRETas Jenkins credentials rather than entering them as plaintext in the pipeline script.
pipeline {
agent any
environment {
DMS_CICD_PROJECT_ID=<your-project-id>
DMS_CICD_BRANCH_NAME="master"
ALIBABA_CLOUD_ACCESS_KEY_ID="<your-access-key-id>"
ALIBABA_CLOUD_ACCESS_KEY_SECRET="<your-access-key-secret>"
DMS_CICD_WORKSPACE_ID=<your-workspace-id>
}
stages {
stage('Build') {
steps {
sh 'wget "https://dms-cicd-tool-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/dms_cicd_tool"'
sh 'chmod +x ./dms_cicd_tool'
echo 'Build step finished'
}
}
stage('Deploy') {
steps {
sh './dms_cicd_tool'
echo 'Deploy finished'
}
}
}
}Replace the following placeholders:
| Placeholder | Description |
|---|---|
<your-project-id> | REPOS project ID of the workspace |
<your-access-key-id> | Your Alibaba Cloud AccessKey ID |
<your-access-key-secret> | Your Alibaba Cloud AccessKey secret |
<your-workspace-id> | Your DMS workspace ID |
Step 2: Configure a trigger
After the trigger is configured, Airflow tasks run automatically on each code push. You can also run tasks manually in the Airflow workspace.
Install the required plugin
In the pipeline project, go to Manage Jenkins > Manage Plugins, install the Generic Webhook Trigger plugin, and set the GitLab token. Obtain the token from the steps in Associate a GitLab repository.
Configure a GitHub trigger
In your GitHub repository, go to Settings > Webhooks and click Add webhook.
Paste the generic webhook URL into the Payload URL field, enter the token in the Secret field, and select a Trigger Type.
Click Add webhook.
Configure a GitLab trigger
In your GitLab repository, go to Settings > Webhooks.
Paste the generic webhook URL into the Payload URL field, enter the token in the Secret field, and select a Trigger Source.
Click Add Webhook.
Other operations
View the REPO project ID
Go to the workspace and click the
icon in the left-side menu bar. In the REPOS section, click the
icon next to the destination repository to view the REPO Project ID.