DataWorks code synchronization and merge connects your workspace to a Git repository. Every save or deploy automatically commits changes to designated Git branches, and you can merge Git branch changes back into DataWorks.
This feature is available only in DataWorks Enterprise Edition.
Overview
DataWorks and Git integration includes two workflows for managing code within a workspace and merging code across workspaces:
-
Sync from DataWorks to Git: When you save or deploy code in DataWorks, the changes are automatically committed to a protected branch in the Git repository. This process is performed by a dedicated Git account and a serverless resource group with network access.
-
Merge from Git to DataWorks: Merge code changes from the main branch or an independent branch of your Git repository back into DataWorks.
DataWorks automatically creates and manages the following three branches in your Git repository, using protected branch rules to prevent manual changes:
-
dataworks_${region}_${projectId}_save: Corresponds to the code after a save operation in DataWorks. -
dataworks_${region}_${projectId}_release_dev: Corresponds to code that is successfully deployed to the development environment. -
dataworks_${region}_${projectId}_release_prod: Corresponds to code that is successfully deployed to the production environment.
Configuration and initialization
Step 1: Prepare resources and network
Code synchronization tasks run on a serverless resource group and require network access to your Git repository and OSS.
-
Prepare a serverless resource group and configure the network.
-
Prepare a DataWorks serverless resource group and associate it with the target workspace.
-
Ensure that the resource group can access the SSH port of the Git server. Only port 22 is supported.
-
Public Git repository (for example, Alibaba Cloud DevOps CodeUp or GitHub.com): Configure an Internet NAT Gateway and an EIP for the resource group's VPC to enable public network access.
-
Private Git repository: Ensure that the resource group and the Git server can communicate over the private network (VPC). For more information, see Network connectivity solutions.
-
-
-
Prepare an OSS data source. The code synchronization feature uses OSS for temporary storage.
-
Create an OSS bucket in the same region as the DataWorks workspace.
-
On the Data Source Management page of the DataWorks workspace, create an OSS data source that points to the bucket.
NoteMake sure that the access credentials used by the OSS data source have the following permissions:
oss:GetObject,oss:ListObjects,oss:PutObject, andoss:DeleteObject.
-
Step 2: Prepare the Git environment
Create a dedicated account on the Git platform, configure SSH keys, and set up branch protection rules.
-
Create a dedicated Git account and generate SSH keys.
-
Create an account on the Git platform (for example, Alibaba Cloud DevOps CodeUp or GitLab) that is dedicated to automatic code commits (for example,
dataworks_pusher), and configure a valid email address. -
Generate an SSH key pair in RSA algorithm mode for the account. Do not set a passphrase during the key generation process.
-
Purpose: Generate the SSH public key and private key for authentication.
-
Command:
# Replace "your_user_email@example.com" with the account email configured in the previous step ssh-keygen -t rsa -C "your_user_email@example.com" # When prompted for a passphrase, press Enter to skip # Enter passphrase (empty for no passphrase): [Enter] # Enter same passphrase again: [Enter] -
Result: After the command is executed, the
id_rsa(private key) andid_rsa.pub(public key) files are generated in the~/.ssh/directory. The contents of these two files will be used in subsequent steps.# Copy and save the public and private key contents, which will be needed in later steps cat ~/.ssh/id_rsa.pub cat ~/.ssh/id_rsa
-
-
-
Add the public key on the Git platform.
Log on to the Git platform and add the public key generated in the previous step (the contents of the
id_rsa.pubfile) on the SSH key management page of thedataworks_pusheraccount. -
Create a code repository and configure branch protection rules.
-
Create a Git repository dedicated to DataWorks code management, for example,
DataWorks_code. -
Set up branch protection rules in the repository to prevent direct modifications to branches that are automatically managed by DataWorks. This operation must be performed by a repository administrator.
ImportantIncorrectly configured branch protection rules may cause branches that are automatically managed by DataWorks to be accidentally modified, which can break synchronization consistency.
-
Branch name pattern:
dataworks_* -
Allowed to push: Select specified members and add the
dataworks_pusheraccount. -
Allowed to merge: Select No one.
-
-
Step 3: Configure and initialize code synchronization
Only tenant administrators and workspace administrators can configure code synchronization for the current workspace. Other roles do not have the permissions to add or modify these settings.
Establish a connection between the DataWorks workspace and the Git repository, and start initialization.
Go to the Workspaces page in the DataWorks console. In the top navigation bar, select a desired region. Find the desired workspace and choose in the Actions column.
-
(Optional) Connectivity test. Before you formally configure the settings, you can create a temporary Shell node in Data Studio and use the prepared serverless resource group for debugging to verify network connectivity and the validity of the SSH private key.
Test network connectivity: Run the
telnetcommand. If the log displays "Connected to ...", the network is connected. After the network is connected, you can stop the task.# Replace with your Git server domain or IP, e.g., Codeup address: codeup.aliyun.com telnet your_git_server_domain 22Take Alibaba Cloud DevOps (CodeUp) as an example. If the following content appears in the log, the network is connected, and you can stop the task. Otherwise, you need to check whether the network configuration is successful.|
2025-11-03 19: 09:28 INF0 ALISA_TASK_PRI0RITY=0: 2025-11-03 19:09:28 INF0 --- Invoking Shell command line now --2025-11-03 19:09:28 INF0 Trying 118..50... Connected to codeup-aliyun.com. Escape character is '^]'. SSH-2.0-G0 -
In the left-side navigation pane, click
Code Management to go to the Code Synchronization configuration page. Configure the following parameters:Name
Description
SSH Address
The SSH address of the target Git repository.
Private key
Paste the complete content of the private key (
id_rsafile) generated in Step 2.ImportantThe private key content must include
-----BEGIN OPENSSH PRIVATE KEY-----and-----END OPENSSH PRIVATE KEY-----.OSS Data Source
Select the OSS data source that you have prepared.
NoteIf a message appears stating that the current resource group is not authorized to access the OSS data source, click the authorization link to grant the required permissions.
OSS Path
Specify an OSS path for storing code metadata. Example:
dataworks-workspace-code.General Resource Group
Select the serverless resource group that you prepared earlier.
-
After the configuration is complete, click Start Synchronization. After synchronization is enabled, you need to initialize the Git repository. Click Initialization. The system automatically creates the branches required by DataWorks in the Git repository and synchronizes the code in the current workspace. This process may take several minutes. During this period, click the
button in the upper-right corner to view the initialization logs.NoteAfter you disable synchronization, you must reinitialize the feature to enable it again. Before reinitialization, clear the file contents in OSS.
After the configuration takes effect, DataWorks automatically creates and manages the following three branches in your Git repository. Do not manually create or modify them:
-
dataworks_${region}_${projectId}_save: Corresponds to the code after a save operation in DataWorks. -
dataworks_${region}_${projectId}_release_dev: Corresponds to code that is successfully deployed to the development environment. If the workspace is in basic mode, the dev branch is not generated. -
dataworks_${region}_${projectId}_release_prod: Corresponds to code that is successfully deployed to the production environment.
From this point on, every save and deploy operation in DataWorks automatically synchronizes the corresponding code and configuration changes to the relevant branch in Git.
Click the default save branch to view the saved node code, workflows, directories, and other information in the current workspace.
-
Step 4: Verify code synchronization
-
Create a Shell node for data development and name it shell_test.
-
Enter the following code in the code editor and click the Save button on the toolbar.
echo 'Code push test.' -
Log on to Git, go to the target repository, select the save branch, and find the shell_test folder. You can see that the folder contains three files:
shell_test.sh (code file),shell_test.spec.json (scheduling configuration file), anddataworks.properties (variable file). Clickshell_test.shto view the shell_test node and its code content, which indicates that the synchronization is successful. -
To verify the synchronization status of the other two branches, deploy nodes to the corresponding environments. For more information about how to deploy nodes, see Deploy nodes.
Scenarios and features
Reverse merge
DataWorks supports merging the latest changes from a remote Git branch back into the platform.
This capability works with both the main synchronization branch and feature branches created from it. Developers can work on independent branches, perform code reviews, and then integrate tested code back into DataWorks for efficient team collaboration.
This feature requires synchronization to be enabled and is available to users with the Developer role or higher.
-
Merge entry
In , expand the Code Merge section.
-
Merge preview
In the Branch input box, enter the name of the branch to merge, such as feature_cn-shanghai_branch. Click merge preview. The system compares the additions, modifications, and deletions between the source branch and the default DataWorks
savebranch.-
No conflicts: The interface displays a diff of the changes, clearly listing the nodes to be added, modified, or deleted along with the code change details.
-
Conflicts detected: The interface displays the conflicts along with the specific conflicting content. In this case, you need to go back to your local environment, resolve the conflicts manually in Git, and then initiate the merge again.
-
-
Confirm merge
-
After verifying that the preview is correct, click Confirm merge.
-
The system starts the merge task, and you can monitor the merge progress in real time.
-
All historical merge records are displayed in the code merge history section below. You can view the owner, merge status, and branch details at any time.
-
Cross-workspace merge
Git synchronization supports cross-workspace and cross-region cloning of DataWorks projects, letting you use a standardized code set as a template that can be reused across business scenarios. For example, you can deploy a common user analysis model to independent workspaces of different business lines, each running on its own compute resources and data sources.
-
Initialization setup
-
Create two projects: git_cross_project_1 and git_cross_project_2. Cross-region creation is supported.
-
Follow Step 1 to configure the resource group and OSS data source in each workspace. The two data sources can use the same configuration. Configure the network connectivity as well.
-
Follow Step 2 to prepare one Git repository as the shared code management repository for both workspaces.
-
Follow Step 3 to configure Git synchronization for both workspaces (use the same SSH address and private key for both), and make sure the initialization succeeds. At this point, branches for both workspaces, 270256 (project1) and 270257 (project2), appear in the Git repository.
-
-
Cross-project merge policy
-
When merging code branches across projects, only node code, basic properties, and scheduling configurations are merged. Runtime configurations are not merged into the target workspace.
-
Because the compute resources, resource groups, and data sources used by the two workspaces may differ, you need to configure a resource mapping file
merge_mapping.-
Open the terminal on your local computer, clone the save branch of the source workspace to your local machine, and switch to the save branch of the source workspace project1, such as
dataworks_cn_shenzhen_270256_save.# Clone the remote Git repository to your local machine git clone git@your_git_server_domain:64dc86a16800a4a57137536/cross_project_shenzhen.git # Switch to the save branch of project1 git checkout <your branch name> -
Create the merge_mapping mapping file.
# cross_project_shenzhen is the repository name cd cross_project_shenzhen # Create the directory mkdir -p DATAWORKS_SYSTEM_CONFIG/merge_mapping # Create the mapping file, e.g., cn_shenzhen_270256_to_cn_shenzhen_270257.properties vi DATAWORKS_SYSTEM_CONFIG/merge_mapping/<region>_<projectId>_to_<region>_<projectId>.propertiesConfigure the file content based on your actual setup. Modify the actual values on both sides of
=. Multiple values are supported for each type.# Data source # spec.datasource.name.<project1 data source name>=<project2 data source name> spec.datasource.name.mysql_01=mysql_02 # Resource group # spec.runtimeResource.resourceGroup.<project1 resource group ID>=<project2 resource group ID> spec.runtimeResource.resourceGroup.group_524257424564736=Serverless_res_group_524257424564736_764027070300961 # Node output name prefix # spec.output-prefix.<project1 name>=<project2 name> spec.output-prefix.git_cross_project_1=git_cross_project_2 # Project prefix for tables in MaxCompute SQL # script.project-identifier.<project1 name>=<project2 name> script.project-identifier.git_cross_project_1=git_cross_project_2 # Image # spec.script.runtime.container.imageId.<image ID used in project1>=<image ID used in project2> spec.script.runtime.container.imageId.Default=System_python311_ubuntu2204_20251201 # RAM role # spec.script.runtime.linkedRoleArn.<RAM role ARN used in project1>=<RAM role ARN used in project2> spec.script.runtime.linkedRoleArn.acs:ram::1107550004253538:role/aliyundataworksaccessingenirole=acs:ram::1107550004253538:role/aliyundataworksaccessingossrolePush the code to the Git repository.
# Stage current directory changes in git git add . # Commit the mapping file git commit -m "add mapping files" # Push the branch content to the remote Git repository git push
-
-
Merge code across projects
-
Go to DataStudio of the target workspace git_cross_project_2. Click Code Management in the left-side navigation pane, and find the Code Merge tab.
-
In the branch input box, enter the name of the save branch of the source workspace, such as
dataworks_cn_shenzhen_270256_save. -
Click merge preview. After confirming that the preview is correct, merge the code from workspace git_cross_project_1 into workspace git_cross_project_2. For details about the merge operation, see Merge from Git to DataWorks.
-
-
Billing
Billable resources include:
-
Serverless resource group: Synchronization tasks use a resource specification of 1 CU. The fees vary depending on the billing method of the purchased resource group. For more information, see Serverless resource group billing.
-
Internet NAT gateway and EIP: If your Git repository is on the public network, corresponding traffic fees are incurred. For more information, see NAT gateway billing.
-
OSS storage: Used to store code synchronization data. Fees are charged based on storage capacity and the number of requests. For more information, see OSS billing overview.
FAQ
-
Q: The initialization shows success, but no branches are created in the Git repository. What do I do?
A: Follow the Connectivity test section to check whether telnet and SSH connections are successful. Focus on verifying that the network configuration (NAT gateway/VPC) of the serverless resource group is correct.
-
Q: A conflict is reported when I merge code. How do I resolve it?
A: In your local development environment, pull the DataWorks save branch (dataworks_${region}_${projectId}_save) to your local machine. Merge it with your development branch (using git merge or git rebase) and resolve the conflicts. Then push your development branch to the remote repository, and go back to the DataWorks page to initiate the merge again.