文档

流水线源 sources

流水线源sources:Flow 目前支持配置代码源、Jenkins源、Flow流水线源三种类型的流水线源,并且支持配置多个源。

  • 代码源:支持配置 Codeup、github、gitlab、gitee 等常见代码源。

  • Jenkins源:支持配置外部 Jenkins 服务触发流水线运行。

  • Flow流水线源:支持配置其他Flow流水线作为源,流水线之间相互触发运行。

示例

单流水线源示例

以下为一个最简单的流水线源配置示例:

sources:
  my_repo:
    type: codeup
    name: 代码源名称
    endpoint: https://codeup.aliyun.com/abc/Codeup-Demo.git
    branch: master
    triggerEvents:
      - push
      - tagPush
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>
多流水线源示例

以下为多流水线源配置示例:

sources:
  repo1:
    type: codeup
    name: 代码源名称
    endpoint: https://codeup.aliyun.com/abc/repo1.git
    branch: master
    triggerEvents:
      - push
      - tagPush
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>
  repo2:
    type: codeup
    name: 代码源名称
    endpoint: https://codeup.aliyun.com/abc/repo2.git
    branch: master
    triggerEvents:
      - push
      - tagPush
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>
defaultWorkspace: repo1
Jenkins 源示例

以下为 Jenkins 任务作为流水线源的配置示例:

sources:
  my_jenkins:
    type: jenkins
    name: Jenkins 源名称
    jenkinsJob: job/job-test
    build: lastSuccessfulBuild
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>
Flow 流水线源示例

以下为 Flow 流水线作为流水线源的配置示例:

sources:
  ci_pipeline:
    type: flowPipeline
    name: Flow 流水线源名称
    flowPipeline: 1479575
    build: lastSuccessfulBuild
    triggerEvents: buildSuccess

详细说明

sources

流水线源,支持配置多个流水线源信息,包括源类型、原地址、默认分支等。

defaultWorkspace

当流水线配置了多个代码源时,必填。默认工作区,后续流水线任务若未指明工作空间,自动进入默认工作区执行任务。填写具体 <source_id>,如:

sources:
  repo1:
    ......
  repo2:
    ......
defaultWorkspace: repo1
sources.<source_id>

必填。流水线源 id,唯一标识流水线源。流水线运行时,会将源文件下载至 <source_id> 文件目录下,即/root/workspace/<source_id>。 source_id 只能包含字母、数字和 _ ,且必须以字母开头,长度限制 30 个字符。

sources.<source_id>.type

必填。流水线源类型,Flow 目前支持 codeup、github、gitlab、jenkins 等多种流水线源类型。

流水线源类型

YAML 标识

备注

云效 Codeup

codeup

支持触发事件:代码提交、Tag 创建、合并请求完成后、合并请求新建/更新

支持根据分支过滤

支持根据代码路径过滤

阿里云 Code

aliyunCode

支持触发事件:代码提交、Tag 创建

支持根据分支过滤

自建 Gitlab

customGitlab

支持触发事件:代码提交、Tag 创建

支持根据分支过滤

码云

gitee

支持触发事件:代码提交

支持根据分支过滤

通用 Git

git

支持触发事件:代码提交、Tag 创建

支持根据分支过滤

Github

github

支持触发事件:代码提交

支持根据分支过滤

Gitlab

gitlab

支持触发事件:代码提交

支持根据分支过滤

Bitbucket

bitbucket

支持触发事件:代码提交

支持根据分支过滤

Jenkins

jenkins

支持配置外部 Jenkins 服务触发流水线运行

Flow 流水线

flowPipeline

支持配置其他Flow流水线作为源,流水线之间相互触发运行;支持触发事件:流水线运行成功、失败、取消

sources.<source_id>.name

选填。长度限制 30 个字符。流水线源的展示名称。

sources.<source_id>.endpoint

当流水线源为代码源时,必填。代码源地址,支持填写 SSH 和 HTTPS 地址。如:https://codeup.aliyun.com/abc/Codeup-Demo.git。

sources.<source_id>.branch

非必填,当流水线源为代码源时,默认为 master。 代码源默认分支,当流水线被定时触发或被外部系统触发时,默认使用的运行分支。 填写分支名,如:

sources:
  my_repo:
    endpoint: https://codeup.aliyun.com/abc/Codeup-Demo.git
    branch: master
sources.<source_id>.submodule

非必填,默认为 false。当流水线源为代码源时,是否同时克隆子模块。填写truefalse,如:

sources:
  my_repo:
  	type: codeup
  	endpoint: https://codeup.aliyun.com/abc/Codeup-Demo.git
    branch: master
    submodule: true
sources.<source_id>.cloneDepth

非必填,默认克隆所有版本。仅支持填写大于等于 0 的数字整数。当流水线源为代码源时,克隆深度值代表克隆最近 commit 的版本数,自定义克隆深度可加速工作区准备效率,0 表示克隆所有版本。 如:

sources:
  my_repo:
    type: codeup
    endpoint: https://codeup.aliyun.com/abc/Codeup-Demo.git
    branch: master
    cloneDepth: 10
sources.<source_id>.triggerEvents

非必填,默认无法通过流水线源事件触发。当发生对应配置的事件后,流水线触发运行。

触发事件

YAML 标识

备注

代码推送

push

Tag 创建

tagPush

仅支持部分代码源

合并请求完成后

mergeRequestMerged

仅支持部分代码源

合并请求新建/更新

mergeRequestOpenedOrUpdate

仅支持部分代码源

流水线运行成功

buildSuccess

仅支持 Flow 流水线源

流水线运行失败

buildFail

仅支持 Flow 流水线源

流水线运行取消

buildCancel

仅支持 Flow 流水线源

如:

sources:
  my_repo:
    type: codeup
    endpoint: https://codeup.aliyun.com/abc/Codeup-Demo.git
    branch: master
    triggerEvents: 
      - push
      - tagPush
sources.<source_id>.branchFilter

非必填,默认不对分支进行过滤。当流水线源为代码源且开启代码源提交触发时,可以设置分支过滤条件,满足过滤条件才会触发流水线运行。填写分支名,支持正则表达公式,如:

sources:
  my_repo:
    type: codeup
    endpoint: https://codeup.aliyun.com/abc/Codeup-Demo.git
    branch: master
    triggerEvents: push
    branchFilter: ^feature.*
sources.<source_id>.pathFilter

非必填,默认不对代码路径进行过滤。当流水线源为代码源且开启代码源提交触发时可以设置代码路径过滤条件,指定代码路径下的代码文件才会触发流水线运行。填写代码路径地址,支持正则表达公式,如:

sources:
  my_repo:
    type: codeup
    endpoint: https://codeup.aliyun.com/abc/Codeup-Demo.git
    branch: master
    triggerEvents: push
    pathFilter: ^file_path.*
sources.<source_id>.branchMode

非必填,默认不打开分支模式。当流水线拥有多个流水线源时,仅允许一个代码源打开分支模式。

sources.<source_id>.branchMode.baseBranch

分支模式参数,若代码源打开了分支模式,则必须填写baseBranchbaseBranch为分支模式中拉取发布分支的基础分支,如:

sources:
  my_repo:
    type: codeup
    endpoint: https://codeup.aliyun.com/abc/Codeup-Demo.git
    branch: master
    branchMode:
      baseBranch: master
sources.<source_id>.certificate

必填。设置克隆代码源,或调用外部 Jenkins 服务的授权信息。使用服务连接,则 type 为 serviceConnection,并填写服务连接 ID 信息,如:

sources:
  my_repo:
    type: codeup
    endpoint: https://codeup.aliyun.com/abc/Codeup-Demo.git
    branch: master
    certificate:
      type: serviceConnection
      serviceConnection: <your-service-connection-id>

部分代码源(如通用 Git、自建 Gitlab等)支持通过企业公钥克隆代码,则可设置使用企业公钥,type 为 sshKey,如:

sources:
  my_repo:
    type: customGit
    endpoint: https://codeup.aliyun.com/abc/Codeup-Demo.git
    branch: master
    certificate:
      type: sshKey
sources.<source_id>.jenkinsJob

当流水线源为 Jenkins 源时,必填。 填写 Jenkins 的 Job 信息,如:

sources:
  my_jenkins:
    type: jenkins
    jenkinsJob: job-test
    ......
sources.<source_id>.flowPipeline

当流水线源为 Flow 流水线时,必填。填写 Flow 的流水线 ID,如:

sources:
  my_ci_pipeline:
    type: flowPipeline
    flowPipeline: 14795**
    ......
sources.<source_id>.build

当流水线源为 Jenkins 源或 Flow 流水线时,必填。填写具体 Jenkins 任务和 Flow 流水线构建编号。

触发事件

YAML 标识

备注

最后一次运行

lastBuild

Jenkins 源

最后一次成功运行

lastSuccessfulBuild

Jenkins 源或 Flow 流水线

具体执行编号

构建编号数字

Jenkins 源或 Flow 流水线

如:

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

  • 本页导读 (0)
文档反馈