全部產品
Search
文件中心

Alibaba Cloud DevOps:流水線源 sources

更新時間:Sep 16, 2025

流水線源(sources)是資料處理和整合系統中的一個關鍵組成部分,負責從不同的資料來源中捕獲和傳輸資料。

背景資訊

流水線源sources:Flow 目前支援配置代碼源、製品源和Flow流水線源,並且支援配置多個源。

  • 代碼源:支援配置 Codeup、GitHub、GitLab等常見代碼源。

  • 製品源:支援配置雲效packages源、阿里雲ACR鏡像源(企業版)。

  • Flow流水線源:支援配置其他Flow流水線作為源,流水線之間相互觸發運行。

樣本

單流水線源

以下為一個最簡單的流水線源配置樣本:

sources:
  my_repo:
    type: codeup
    name: 代碼源名稱
    endpoint: https://<雲效執行個體id>.devops.alibabacloudcs.com/codeup/abc/Codeup-Demo.git
    branch: master
    triggerEvents:
      - push
      - tagPush
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>

多流水線源

以下為多流水線源配置樣本:

sources:
  repo1:
    type: codeup
    name: 代碼源名稱 
    endpoint: https://<雲效執行個體id>.devops.alibabacloudcs.com/codeup/abc/repo1.git # 雲效執行個體id為一個3到8位的數字和字母的組合。
    branch: master
    triggerEvents:
      - push
      - tagPush
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>
  repo2:
    type: codeup
    name: 代碼源名稱
    endpoint: https://<雲效執行個體id>.devops.alibabacloudcs.com/codeup/abc/repo2.git  # 雲效執行個體id為一個3到8位的數字和字母的組合。
    branch: master
    triggerEvents:
      - push
      - tagPush
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>
defaultWorkspace: repo1

packages 源樣本

以下為雲效packages通用製品作為流水線源的配置樣本:

sources:
  my_packages:
    type: packages
    repoType: generic                                            # 倉庫類型,目前只支援通用製品倉庫generic
    repo: "<your-repo-id>, eg: flow_generic_repo"                # 倉庫id,可以在packages.aliyun.com頁面從倉庫基本資料擷取倉庫id
    artifact: "<your-artifact-name>, eg: Artifacts_1418394"      # 製品名稱
    version: "<your-artifact-version>, eg: 2024-03-28-11-53-39"  # 製品版本,如果填latest,則表示使用最新版本
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>

ACR 源樣本

以下為 阿里雲ACR企業版鏡像作為流水線源的配置樣本:

sources:
  my_acr:
    type: acr
    region: cn-hangzhou
    instance: "<your-acr-ee-instance>, eg: yunxiao"  # ACR執行個體名稱
    namespace: default                               # 命名空間
    imageRepo: "<your-docker-registry>, eg: test"    # 鏡像倉庫名稱
    imageTag: v1.0                                   # 鏡像版本
    versionFilter: .*                                # 鏡像版本的過濾規則,請填寫Regex
    triggerEvents:
      - pushCompleted
      - scanCompleted
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>

Flow 流水線源樣本

以下為 Flow 流水線作為流水線源的配置樣本:

sources:
  ci_pipeline:
    type: flowPipeline
    name: Flow 流水線源名稱
    flowPipeline: <your-flow-pipeline-id>  # 形如:rfkkfe6tj1mcaqtz
    build: lastSuccessfulBuild
    triggerEvents: buildSuccess

詳細說明

sources

流水線源,支援配置多個流水線源資訊,包括源類型、源地址、預設分支等。

defaultWorkspace

當流水線配置了多個代碼源時,必填。預設工作區,後續流水線任務若未指明工作空間,自動進入預設工作區執行任務。填寫具體 <source_id>,如:

sources:
  repo1:
    ......
  repo2:
    ......
defaultWorkspace: repo1

sources.<source_id>

必填。流水線源 id,唯一標識流水線源。流水線運行時,會將源檔案下載至 <source_id> 檔案目錄下(ACR鏡像源不會下載),即/root/workspace/<source_id>。 source_id 只能包含字母、數字和 _ ,且必須以字母開頭,長度限制 30 個字元。

sources.<source_id>.type

必填。流水線源類型,Flow目前支援Codeup、gitHub、gitLab、svn、packages、acr等多種流水線源類型。

流水線源類型

YAML 標識

備忘

範例程式碼源

gitSample

  • 支援多種語言類型的範例程式碼倉庫,如Java、Go、Python、C++、NodeJS、PHP、.NET Core。

  • 不支援觸發事件。

雲效 Codeup

codeup

  • 支援觸發事件:代碼提交、Tag 建立、合并請求完成後、合并請求建立/更新

  • 支援根據分支過濾

  • 支援根據代碼路徑過濾

通用 Git

git

  • 支援觸發事件:代碼提交

  • 支援根據分支過濾

Github

githubApp

  • 支援觸發事件:代碼提交

  • 支援根據分支過濾

Gitlab

gitlab

  • 支援觸發事件:代碼提交、Tag 建立、合并請求完成後

  • 支援根據分支過濾

自建 Gitlab

customGitlab

  • 支援觸發事件:代碼提交、Tag 建立、合并請求完成後

  • 支援根據分支過濾

Bitbucket

bitbucket

  • 支援觸發事件:代碼提交

  • 支援根據分支過濾

Flow 流水線

flowPipeline

  • 支援配置其他Flow流水線作為源,流水線之間相互觸發運行

  • 支援觸發事件:流水線運行成功、失敗、取消

Packages 通用製品

packages

  • 支援配置雲效packages通用製品作為源

  • 不支援觸發事件

阿里雲 ACR 企業版鏡像倉庫

acr

  • 支援配置阿里雲ACR企業版倉庫鏡像作為源

  • 支援觸發事件:鏡像推送完成、鏡像掃描完成

  • 支援根據版本號碼過濾

sources.<source_id>.name

選填。長度限制 30 個字元。流水線源的展示名稱。

sources.<source_id>.endpoint

當流水線源為代碼源時,必填。代碼源地址,支援填寫 SSH 和 HTTPS 地址。如:https://codeup.aliyun.com/abc/Codeup-Demo.git。

範例程式碼庫由雲效提供,代碼源地址如下:
Java:https://atomgit.com/flow-example/spring-boot.git
Go:https://atomgit.com/flow-example/go-gonic.git
Python:https://atomgit.com/flow-example/python-tornado.git
C++:https://atomgit.com/flow-example/gcc-helloworld.git
NodeJS:https://atomgit.com/flow-example/node-expressjs.git
PHP:https://atomgit.com/flow-example/php-laravel-blog.git
.Net Core:https://atomgit.com/flow-example/dotnet-core-sample.git

sources.<source_id>.branch

非必填,當流水線源為代碼源時,預設為 master。 代碼源預設分支,當流水線被定時觸發或被外部系統觸發時,預設使用的運行分支。 填寫分支名,如:

sources:
  my_repo:
    endpoint: https://<雲效執行個體id>.devops.alibabacloudcs.com/codeup/abc/Codeup-Demo.git  # 雲效執行個體id為一個3到8位的數字和字母的組合。
    branch: master

範例程式碼源僅支援 master 分支。

sources.<source_id>.branchesFilter

非必填,指定流水線運行分支的過濾規則,請填寫Regex。僅滿足過濾規則的分支或標籤可以觸發流水線運行,在手工觸發、代碼源觸發、定時觸發、Webhook 觸發各情境均生效。

sources:
  my_repo:
    endpoint: https://<雲效執行個體id>.devops.alibabacloudcs.com/codeup/abc/Codeup-Demo.git  # 雲效執行個體id為一個3到8位的數字和字母的組合。
    branch: release
    branchesFilter: release_*     # 僅可運行以 release_ 開頭的分支

sources.<source_id>.submodule

非必填,預設為 false。當流水線源為代碼源時,是否同時複製子模組。填寫truefalse,如:

sources:
  my_repo:
  	type: codeup
  	endpoint: https://<雲效執行個體id>.devops.alibabacloudcs.com/codeup/abc/Codeup-Demo.git  # 雲效執行個體id為一個3到8位的數字和字母的組合。
    branch: master
    submodule: true

sources.<source_id>.cloneDepth

非必填,預設複製所有版本。僅支援填寫大於等於 0 的數字整數。當流水線源為代碼源時,複製深度值代表複製最近 commit 的版本數,自訂複製深度可加速工作區準備效率,0 表示複製所有版本。 如:

sources:
  my_repo:
    type: codeup
    endpoint: https://<雲效執行個體id>.devops.alibabacloudcs.com/codeup/abc/Codeup-Demo.git  # 雲效執行個體id為一個3到8位的數字和字母的組合。
    branch: master
    cloneDepth: 10

sources.<source_id>.triggerSecret

僅支援Github。

在Github的Webhook配置中添加了Secret後,需要在流水線配置中也添加相同的值,以便在處理Webhook時,進行簽名校正。

支援直接填寫,或者使用變數,比如

  triggerSecret: ${SECRET}

或者

  triggerSecret: theSecret

sources.<source_id>.triggerEvents

非必填,預設無法通過流水線源事件觸發。當發生對應配置的事件後,流水線觸發運行。

觸發事件

YAML 標識

備忘

程式碼推送

push

Tag 建立

tagPush

僅支援部分代碼源

合并請求完成後

mergeRequestMerged

僅支援部分代碼源

合并請求建立/更新

mergeRequestOpenedOrUpdate

僅支援部分代碼源

流水線運行成功

buildSuccess

僅支援 Flow 流水線源

流水線運行失敗

buildFail

僅支援 Flow 流水線源

流水線運行取消

buildCancel

僅支援 Flow 流水線源

ACR鏡像推送完成

pushCompleted

僅支援 ACR 流水線源

ACR鏡像掃描完成

scanCompleted

僅支援 ACR 流水線源

如:

sources:
  my_repo:
    type: codeup
    endpoint: https://<雲效執行個體id>.devops.alibabacloudcs.com/codeup/abc/Codeup-Demo.git  # 雲效執行個體id為一個3到8位的數字和字母的組合。
    branch: master
    triggerEvents: 
      - push
      - tagPush

sources.<source_id>.branchFilter(Deprecated)

說明

本關鍵字已處於 Deprecated 狀態,請使用上述 sources.<source_id>.branchesFilter 關鍵字替代。

非必填,預設不對分支進行過濾。當流水線源為代碼源且開啟代碼源提交觸發時,可以設定分支過濾條件,滿足過濾條件才會觸發流水線運行。填寫分支名,支援正則表達公式,如:

sources:
  my_repo:
    type: codeup
    endpoint: https://<雲效執行個體id>.devops.alibabacloudcs.com/codeup/abc/Codeup-Demo.git  # 雲效執行個體id為一個3到8位的數字和字母的組合。
    branch: master
    triggerEvents: push
    branchFilter: ^feature.*  # 本關鍵字已處於 Deprecated 狀態,請使用 branchesFilter 替代

sources.<source_id>.pathFilter

非必填,預設不對代碼路徑進行過濾。當流水線源為代碼源且開啟代碼源提交觸發時可以設定代碼路徑過濾條件,指定代碼路徑下的代碼檔案才會觸發流水線運行。填寫代碼路徑地址,支援Regex,如:雲效執行個體id為一個3到8位的數字和字母的組合。

sources:
  my_repo:
    type: codeup
    endpoint: https://<雲效執行個體id>.devops.alibabacloudcs.com/codeup/abc/Codeup-Demo.git  # 雲效執行個體id為一個3到8位的數字和字母的組合。
    branch: master
    triggerEvents: push
    pathFilter: ^file_path.*

sources.<source_id>.branchMode

非必填,預設不開啟分支模式。當流水線擁有多個流水線源時,僅允許一個代碼源開啟分支模式。

sources.<source_id>.branchMode.branchModelBranchFilter

非必填,分支模式參數,若代碼源開啟了分支模式,且配置了branchModelBranchFilter,只允許滿足 branchModelBranchFilter 正則條件的分支運行。

sources.<source_id>.branchMode.keepIntegrationAreaBranch

非必填,分支模式參數,值為boolean,預設值為false,值為true時,合并分支後不清空整合區。

sources.<source_id>.branchMode.baseBranch

分支模式參數,若代碼源開啟了分支模式,則必須填寫baseBranchbaseBranch為分支模式中拉取發布分支的基礎分支,如:雲效執行個體id為一個3到8位的數字和字母的組合。

sources:
  my_repo:
    type: codeup
    endpoint: https://<雲效執行個體id>.devops.alibabacloudcs.com/codeup/abc/Codeup-Demo.git   # 雲效執行個體id為一個3到8位的數字和字母的組合。
    branch: master
    branchMode:
      baseBranch: master
      keepIntegrationAreaBranch: false
      branchModelBranchFilter: feature/.*

sources.<source_id>.certificate

當 sources.<source_id>.type 為 gitSample、git 或 flowPipeline 時,非必填;其他情境必填。設定複製代碼源,或調用外部 Jenkins 服務的授權資訊。使用服務串連,則 type 為 serviceConnection,並填寫 服務串連 ID 資訊(服務串連 ID 請前往 企業設定服務串連管理 擷取),如:

sources:
  my_repo:
    type: codeup
    endpoint: https://<雲效執行個體id>.devops.alibabacloudcs.com/codeup/abc/Codeup-Demo.git  # 雲效執行個體id為一個3到8位的數字和字母的組合。
    branch: master
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>

部分代碼源(如通用 Git、自建 GitLab等)支援通過企業公開金鑰複製代碼,則可設定使用企業公開金鑰,type 為 sshKey,如:

sources:
  my_repo:
    type: customGit
    endpoint: https://<雲效執行個體id>.devops.alibabacloudcs.com/codeup/abc/Codeup-Demo.git   # 雲效執行個體id為一個3到8位的數字和字母的組合。
    branch: master
    certificate:
      type: sshKey

sources.<source_id>.flowPipeline

當流水線源為 Flow 流水線時,必填。填寫 Flow 的流水線 ID(由16位隨機字母組成),如:

sources:
  my_ci_pipeline:
    type: flowPipeline
    flowPipeline: atf******cmaofmk
    ......

sources.<source_id>.build

當流水線源為Jenkins源或Flow流水線時,必填。填寫具體的Jenkins任務或Flow流水線構建編號。

觸發事件

YAML 標識

備忘

最後一次成功運行

lastSuccessfulBuild

Flow 流水線

具體執行編號

構建編號數字

Flow 流水線

如:

sources:
  my_jenkins:
    type: jenkins
    jenkinsJob: job-test
    build: lastBuild

sources.<source_id>.repoType

當流水線源為packages製品源時必填,且repoType只支援通用製品類型:generic。

sources:
  my_repo:
    type: packages
    repoType: generic                                            
    repo: flow_generic_repo                
    artifact: Artifacts_1418394
    version: 2024-03-28-11-53-39
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>

sources.<source_id>.repo

當流水線源為packages製品源時必填,填寫具體的倉庫id,可以在packages.aliyun.com頁面從倉庫基本資料擷取倉庫id。

sources:
  my_repo:
    type: packages
    repoType: generic                                            
    repo: flow_generic_repo
    artifact: Artifacts_1418394      
    version: 2024-03-28-11-53-39
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>

sources.<source_id>.artifact

當流水線源為packages製品源時必填,填寫具體的製品名稱。

sources:
  my_repo:
    type: packages
    repoType: generic                                            
    repo: flow_generic_repo                
    artifact: Artifacts_1418394      
    version: 2024-03-28-11-53-39  
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>

sources.<source_id>.version

當流水線源為packages製品源時必填,填寫具體的製品版本號碼。

sources:
  my_repo:
    type: packages
    repoType: generic                                            
    repo: flow_generic_repo                
    artifact: Artifacts_1418394      
    version: 2024-03-28-11-53-39  
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>

sources.<source_id>.region

當流水線源為ACR鏡像源時必填,只能填寫已支援的region。

sources:
  my_repo:
    type: acr
    region: cn-hangzhou
    instance: yunxiao
    namespace: default
    imageRepo: test
    imageTag: 2024-04-07-17-18-26-YAML        
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>

sources.<source_id>.instance

當流水線源為ACR鏡像源時必填,填寫當前服務串連下授權的企業版ACR執行個體名稱。

sources:
  my_repo:
    type: acr
    region: cn-hangzhou
    instance: yunxiao
    namespace: default
    imageRepo: test
    imageTag: 2024-04-07-17-18-26-YAML
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>

sources.<source_id>.namespace

當流水線源為ACR鏡像源時必填,填寫執行個體下的某個命名空間。

sources:
  my_repo:
    type: acr
    region: cn-hangzhou
    instance: yunxiao
    namespace: default
    imageRepo: test
    imageTag: 2024-04-07-17-18-26-YAML
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>

sources.<source_id>.imageRepo

當流水線源為ACR鏡像源時必填,填寫命名空間下的鏡像倉庫名稱。

sources:
  my_repo:
    type: acr
    region: cn-hangzhou
    instance: yunxiao
    namespace: default
    imageRepo: test
    imageTag: 2024-04-07-17-18-26-YAML
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>

sources.<source_id>.imageTag

當流水線源為ACR鏡像源時必填,填寫鏡像倉庫下的某個版本名稱。

sources:
  my_repo:
    type: acr
    region: cn-hangzhou
    instance: yunxiao
    namespace: default
    imageRepo: test
    imageTag: 2024-04-07-17-18-26-YAML
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>

sources.<source_id>.versionFilter

非必填,指定運行ACR鏡像源版本的過濾規則,請填寫Regex。僅滿足過濾規則的版本可以觸發流水線運行,在手工觸發、製品源webhook觸發、定時觸發、Webhook觸發各情境均生效。

sources:
  my_repo:
    type: acr
    region: cn-hangzhou
    instance: yunxiao
    namespace: default
    imageRepo: test
    imageTag: 2024-04-07-17-18-26-YAML
    versionFilter: .*-YAML         # 僅可運行以 -YAML結尾的版本
    triggerEvents:
      - pushCompleted
      - scanCompleted
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>