All Products
Search
Document Center

Alibaba Cloud DevOps:Code source trigger

Last Updated:May 16, 2025

This topic describes how to enable code source trigger for a pipeline, as well as triggering events and filtering conditions.

Enable code source trigger for a pipeline

If you enable code source trigger for a pipeline and configure a webhook, the pipeline will be triggered when you submit code to the specified branch and code repository.

Enable code source trigger in Codeup

  1. On the My Pipelines page, click the name of the target pipeline.

  2. In the upper-right corner, click Edit.

  3. Click Add Pipeline Source.

  4. Set Select Code Source to Codeup and turn on Enable Code Source Trigger. Then Flow will add the webhook URL to the related code repository.

image

image

Enable code source trigger for a pipeline for other types of code repository

  1. In the Add Pipeline Source panel, turn on Enable Code Source Trigger and copy the webhook URL.

    image

  2. Configure the webhook URL in the code repository.

Alibaba Cloud DevOps allows code source trigger for GitLab, GitHub, Gitee, and General Git code repository types. See the following tabs for how to configure webhooks for these code repositories.

Configure a webhook in GitLab

  1. Log on to the GitLab console and open the code repository.

  2. In the left-side navigation pane, navigate to Settings > Integrations.

  3. Paste the webhook URL of the pipeline to the URL field.

image

Configure a webhook in GitHub

  1. Log on to the GitHub console. Open the code repository.

  2. In the left-side navigation pane, navigate to Settings > Webhooks.

  3. Click Add Webhook and paste the webhook URL of the pipeline to the Payload URL field.

  4. Select application/json for Content Type.

image

Configure a webhook in Gitee

  1. Log on to the Gitee console and open the code repository.

  2. Naviget to Settings > Webhooks, and paste the webhook URL of the pipeline to the URL field.

Configure a webhook in General Git

Take GitLab as an example.

  1. Log on to the GitLab console and open the code repository.

  2. In the left-side navigation pane navigate to Settings > Integrations.

  3. Paste the webhook URL of the pipeline to the URL field.

Configure a webhook in SVN

  1. In the Add Pipeline Source panel, turn on Enable Code Source Trigger and copy the webhook URL.

    image

  2. Find the hook script template in the hooks directory of the SVN server repository. Remove the suffix when you use the hook script template.

    image.png

  3. Take the post-commit Shell script as an example. When SVN detects code changes, including submissions, branch creations, and tag creations, SVN runs the script.

    #!/bin/sh
    
    # Pass the path of the code repository and the revision number of the submission to the script.
    REPOS="$1"
    REV="$2"
    
    # Extract the first changed directory path (typically the top-level directory)  
    CHANGED_DIRS=$(svnlook dirs-changed -r "$REV" "$REPOS")
    
    # Get the branch name from the output if the branch naming aligns with the standard format: branches/branch name.
    FIRST_CHANGED_PATH=$(echo "$CHANGED_DIRS" | head -n 1)
    
    # Use sed to get the branch name if the path is in the branches/branch name format.
    BRANCH_NAME=$(echo $FIRST_CHANGED_PATH | sed 's#.*/\(branches/.*\)/#\1#')
    
    # Write the curl command to request the webhook URL provided by your pipeline. 
    curl --location --request POST 'http://example.com/scm/webhook/MwfQPTxxxxxxxxx' \
    --header 'Content-Type: application/json' \
    --data-raw "{
      \"ref\": \"refs/heads/$BRANCH_NAME\",
      \"repository\": {
        \"clone_url\": \"svn://8.142.XX.XXXcom/svn/repos/demo\"
      }
    }"

Triggering events

Use the triggering events setting to filter Webhook events from code repositories. Supported event types vary by code source, as shown in the table below:

Alibaba Cloud Code

Alibaba Cloud DevOps Codeup

General Git

GitHub

GitLab

Coding

Bitbucket

Self-managed GitLab

SVN

Code commit

Tag creation

Merge request creation or update

Request-merge completion

Triggering logic

  • Code commit: When pushing a local branch to a remote branch (or modifying files via the code management platform's web interface), the system matches the target branch with the configured filter. If matched, the pipeline is triggered using the target branch.

  • Tag creation: When pushing a local tag to the server (or creating a tag via the web interface), the system matches the tag name with the filter. If matched, the pipeline is triggered using the tag as the code version.

  • Merge request created/updated: When creating or updating a merge request via the web interface (e.g., merging dev into master), the system matches the target branch with the filter. If matched, the pipeline is triggered using the source branch.

  • Merge request completed: Similar to "Merge Request Created/Updated," but the pipeline uses the target branch.

Filter conditions

Branch or tag filtering

Filtering conditions triggered by code submission support regular expressions. Examples:

  • To match multiple branches, such as master and dev, use master|dev.

  • To match branches that start with '"feature", use ^feature.*.

Code path filtering

Code path filtering allows you to specify which code sources' push events should trigger actions. This feature is currently only supported for Codeup.

Pipelines are triggered only when changes occur in paths matching the filtering rules. Filtering conditions support regular expressions. For example: A filtering rule of ^auth-srv/.* triggers pipelines only if files in the auth-srv directory or its subdirectories are modified.