Use Git to manage code in an Airflow instance
In an Airflow instance, associate a Git account and bind a code repository to enable version management and team collaboration through Git.
Overview
DMS Airflow supports two code management approaches:
Approach 1: Create and edit DAG code files directly in the workspace.
Approach 2: Bind an existing Git repository to manage code.
This topic describes the second approach. For information about how to create and edit DAG code files directly, see Step 2: Add a linked account.
Procedure
Step 1: Add an associated account
Associated accounts are independent. Even if other users work in the same workspace, they cannot view the resources under your associated account.
In the upper-right corner of the workspace, click your account avatar, and then click the
icon next to Associated Accounts to create an associated account.In the Create Service Provider Account dialog box, select the account Type. DMS supports the following three account types:
GitHub
Yunxiao Code Management (Codeup)
Self-hosted GitLab
Select the Creation Method, which determines how the account is imported into the workspace. DMS supports the following two methods:
Username and Password
User Token
Configure the password or token.
If you select Username and Password as the Creation Method, enter the Username and Password of the account.
If you select User Token as the Creation Method, enter the Username and Access Token of the account.
Click OK.
Step 2: Create a code repository
In the left-side navigation pane of the workspace, click the
icon to go to the File Explorer page.In the CODE section, click the
icon and select Add existing Git repository to create a code repository.In the Create Code Repository dialog box, configure the following parameters:
path: The path of the code repository. Default value:
/Workspace/code. Click Edit to modify the path.Directory Name (required): Enter the directory name of the code repository.
Git Repository URL (required): The URL of the Git repository to add. SSH and HTTP/HTTPS URLs are supported.
NoteIf you use an HTTP/HTTPS URL, you must enter the Username and Token for accessing the repository.
Private Repository: Specify whether the Git repository is private. Select this option if your code repository uses a non-public Git service.
Click OK. The repository is created when its name appears in the repository list.
Step 3: Repository operations and code deployment
Repository operations (Git repositories only)
In the CODE section, click
masternext to the target repository name to switch branches, create a branch, edit code, or save code (equivalent to running the git push command).Move the pointer over the repository name and click the
icon. Select Repository Information. In the dialog box that appears, confirm the environment and parameter settings.
Code deployment
In the upper-right corner of the CODE section, click the
button.In the dialog box that appears, select the Deployment Branch, configure the Excluded Directories, and then click Deploy.
NoteThe dialog box indicates that deployment may take up to 10 minutes. Uncommitted changes in the current branch are automatically committed and pushed.