浏览历史
创建管道的管道
要创建管道的管道,您需要:
- 至少两条管道
- 连接这些管道的资源
就像依赖步骤如何使用资源连接一样,依赖管道也使用资源连接。2022世界杯阿根廷预选赛赛程
在下面的图像中,第一个管道(app_dev_pipeline)以输出资源结束app_buildinfo
.第二个管道(app_prod_pipeline)以相同的资源开始,将其用作输入资源。
信息 |
---|
默认情况下,在运行期间,只有当连接管道的资源有新版本时才会触发依赖管道。 |
管道的管道
例子
这里有两个例子展示了管道中的管道。
示例1
此示例显示了包含8个管道的管道组合管道,使用PropertyBag资源。
在这个例子中:
有三个PropertyBag2022世界杯阿根廷预选赛赛程资源:
扩大 标题 资源定义 代码块 语言 yml 2022世界杯阿根廷预选赛赛程resources:—name: runpopprop type: PropertyBag配置:key1: value1 key2: value2—name: runpopprop2 type: PropertyBag配置:key1: value1 key2: value2—name: runpopprop3 type: PropertyBag配置:key1: value1 key2: value2
有8个相互连接的管道:
扩大 标题 管道的定义 代码块 语言 yml 管道:—name: TRIGGER步骤:—name: TRIGGER类型:Bash配置:outputResources:—name: runpopprop执行:on2022世界杯阿根廷预选赛赛程Execute:—write_output runpopprop runId=$run_number—name: TRIGGER_OUT_1_1步骤:—name: TRIGGER_OUT_1类型:Bash配置:inputResources:—name: runpopprop outputResources:—name: runpopprop3执行:onExecute:—printenv#—write_output runpopprop3 runId=$run_number—name: TRIGGER_OUT_3_3步骤:—name: TRIGGER_OUT_1类型:Bash配置:input2022世界杯阿根廷预选赛赛程Resources:—name: runpopprop3执行:onExecute:—printenv - name: TRIGGER_OUT_1_2步骤:—name: TRIGGER_OUT_2类型:Bash配置:inputResources:—name: runpopprop outputResources:—name: runpopprop2环境变量:SOME_KEY: asd执行:onExecute:—printenv - name: TRIGGER_OUT_1_3步骤:—name: TRIGGER_OUT_2类型:Bash配置:inputResources:—name: runpopprop环境变量:SOME_KEY: asd执行:onExecute:—printenv - name: runpopprop2环境变量:SOME_KEY: asd执行:onExecute:—name: runpopprop环境变量:SOME_KEY: asd执行:onExecute:—printenv - name: runpopprop2环境变量TRIGGER_OUT_1_4步骤:—name: TRIGGER_OUT_2 type: Bash配置:inputResources:—name: ru2022世界杯阿根廷预选赛赛程npopprop outputResources:—name: runpopprop2 environmentVariables: SOME_KEY:“asd”执行:onExecute:—printenv - name: TRIGGER_OUT_3_1步骤:—name: TRIGGER_OUT_3_2 type: Bash配置:inputResources:—name: runpopprop2 environmentVariables: SOME_KEY:“asd”执行:onExecute:—printenv - name: TRIGGER_OUT_3_2步骤:—name: TRIGGER_OUT_3_2 type: Bash配置:inputResources:—name: TRIGGER_OUT_3_2步骤:—name: TRIGGER_OUT_2 type: Bash配置:inputResources:—name: runpopprop2 environmentVariables: SOME_KEY: 'asd' execute: onExecute:—printenv .环境变量
- 管道命名为
触发
生成一个名为runpopprop
. - 资源
runpopprop
是这些管道的输入资源:TRIGGER_OUT_1_1
TRIGGER_OUT_1_2
TRIGGER_OUT_1_3
TRIGGER_OUT_1_4
- 的
触发
管道使用write_output实用函数来触发这四个管道。 - 资源
runpopprop2
连接管道TRIGGER_OUT_1_2
而且TRIGGER_OUT_1_4
到管道TRIGGER_OUT_3_2
,但不会触发。 - 类似地,输出资源
runpopprop3
来自管道TRIGGER_OUT_1_4
不触发管道TRIGGER_OUT_1_4
.
多媒体 | ||||||
---|---|---|---|---|---|---|
|
示例2
此示例显示了包含五条管道的管道的管道,使用几种类型的资源相互连接。2022世界杯阿根廷预选赛赛程
在这个例子中:
这些资源用于2022世界杯阿根廷预选赛赛程连接管道:GitRepo,PropertyBag,图像,BuildInfo,ReleaseBundle,DistributionRule.
扩大 代码块 2022世界杯阿根廷预选赛赛程资源:—name: myGithub type: GitRepo configuration: gitProvider: myGithub path: RjSH1/pop #branches: #include: {{gitBranch}} - name: myBashPropertyBag type: PropertyBag configuration: key1: value1 key2: value2 - name: myPowerShellPropertyBag type: PropertyBag configuration: key1: value1 key2: value2 - name: myImageResource type: Image configuration: registry: myArtifactory sourceRepository: d-docker-local imageName: icarusjuly30.jfrogdev.org/d-docker-local/myimage imageTag: mytag - name:myImageBuildInfo类型:BuildInfo配置:sourceArtifactory: myArtifactory buildName: my_build buildNumber: 1 - name: myImageReleaseBundle类型:ReleaseBundle配置:sourceDistribution: myDistribution名称:demo_rb版本:v1.0.0 #同一发布包的签名版本- name: mySignedReleaseBundle类型:ReleaseBundle配置:sourceDistribution: myDistribution名称:demo_rb版本:v1.0.0 - name: myDistributionRule类型:DistributionRule配置:sourceDistribution: myDistribution serviceName: "*" siteName: "*" cityName: "*" countryCodes: - "CN" - "GB"
有五个相互连接的管道:
扩大 代码块 管路:—name: image_build steps:—name: docker_build type: DockerBuild configuration: affinityGroup: docker_group dockerFileLocation:。dockerFileName: Dockerfile dockerImageName: icarusjuly30.jfrogdev.org/d-docker-local/myimage dockerImageTag: ${run_number} input2022世界杯阿根廷预选赛赛程Resources:—name: myGithub integrations:—name: myArtifactory—name: docker_push type: DockerPush配置:affinityGroup: docker_group targetRepository: d-docker-local autopubishbuildinfo: true integrations:—name: myArtifactory inputSteps:—name: myImageResource—name: myImageBuildInfo—name: bash_ci steps:—name:bash_ci类型:Bash配置:inputResources: - name2022世界杯阿根廷预选赛赛程: myGithub - name: myImageResource outputResources: - name: myBashPropertyBag执行:onExecute: - echo "Testing the image…"- echo "$res_myImageResource_imageTag" - echo "正在更新输出资源…"—write_output myBashPropertyBag runId=$run_number—name: create_release configuration: dependencyMode: waitOnParentSuccess: true steps:—name: bash_step type: Bash configuration: inputResou2022世界杯阿根廷预选赛赛程rces:—name: myImageBuildInfo—name: myBashPropertyBag—name: myPowerShellPropertyBag execution: onExecute:—echo“Bash step”—name: create_bundle type: CreateReleaseBundle configuration: releaseBundleName: myImageReleaseBundle releaseBundleVersion: v1.0。${run_number} dryRun: false sign: true description: "My Docker image ReleaseBundle " inputSteps: - name: bash_step input2022世界杯阿根廷预选赛赛程Resources: - name: myImageBuildInfo outputResources: - name: myImageReleaseBundle - name: sign_release steps: - name: sign type: SignReleaseBundle configuration: inputResources: - name: myImageReleaseBundle outputResources: - name: mySignedReleaseBundle - name: distribute_bundle type: DistributeReleaseBundle configuration: dryRun:- name: myS2022世界杯阿根廷预选赛赛程ignedReleaseBundle触发器:false - name: myDistributionRule
控制管道运行
在配置管道的管道时,您可能希望指定当一个管道相对于由资源连接的其他管道运行时。2022世界杯阿根廷预选赛赛程
的dependencyMode
标记,该标记可以在pipelines.configuration
章节。管道管道YAML。年代指定一个管道何时可以相对于由资源连接的其他管道运行。2022世界杯阿根廷预选赛赛程它有三种设置:waitOnParentComplete
,waitOnParentSuccess
,waitOnChildComplete
.如果这些设置是真正的,如果一个运行已经在使用相同的资源和步骤等待,则不会为其他管道更新的资2022世界杯阿根廷预选赛赛程源创建新的运行。因此,如果一个管道(名为Pipeline_A)连续运行两次,而下面的管道(名为Pipeline_B)连续运行两次waitOnParentComplete
设置为真正的
,则Pipeline_B将只运行一次。当管道运行时,它们将使用最新的资源版本。
当您希望确保每个管道步骤的输入资源在步骤开始执行之前处于稳定状态(没有等待或正在进行的运行)时,可以使用这些标记,以防止资源2022世界杯阿根廷预选赛赛程所指向的工件在步骤执行中间发生变化的情况。这在管道创建将覆盖自身的工件的情况下特别有用。例如,带有“最新”标签的Docker图像或每次上传的同名文件。在这些情况下,某些工件可能会在步骤触发后发生更改,从而导致下载的内容不一致。
的dependencyMode
标签有以下可选的设置:
设置 | 描述 | 默认的 |
---|---|---|
waitOnParentComplete |
如果真正的 ,当输出资源作为该管道的输入的管道正在运行等待或处理时,该管道将不会开始运行。管道只有在父管道运行完成后才会运行。 |
假 |
waitOnParentSuccess |
如果真正的 ,当输出作为该管道输入的资源的管道执行处理运行或最后一次完整运行未成功时,该管道将不会开始运行。只有在父管道运行成功之后,管道才会运行。但是,如果父管道没有被触发,子管道仍然可以作为一个独立的管道被触发。 |
假 |
waitOnChildComplete |
如果真正的 ,当拥有该管道输出的输入资源的管道运行等待或处理时,该管道将不会开始运行,除非该子管道正在等待该管道完成。该管道将仅在子管道运行完成后运行。 |
假 |
代码块 | ||
---|---|---|
|
||
管道:- name: myPipeline configuration:时间顺序:true/false # default false dependencyMode: waitOnParentComplete: true/false # default false waitOnParentSuccess: true/false # default false waitOnChildComplete: true/false # default false steps:… |
信息 |
---|
虽然不建议,如果父管道有 |
例子
例1 -waitOnParentComplete
而且waitOnParentSuccess
在本例中,是第一条管道A_parent创建Docker映像。T贺子管道A_waitOnParent直到父管道A_parent的运行成功完成,因为两者waitOnParentComplete
而且waitOnParentSuccess
设置为真正的
为A_waitOnParent.
代码块 | ||
---|---|---|
|
||
2022世界杯阿根廷预选赛赛程resources:—name: dependencyModeImage type:镜像配置:registry: myDocker imageName: jfrog/test imageTag: "0" - name: dependencyModeRepo type: GitRepo configuration: gitProvider: myGithub path: jfrog/dependencyMode branches: include: ^{{gitBranch}}$ pipelines:—name: A_parent steps:—name: createImage type: Bash configuration: inputResources:—name: dependencyModeImage integrations:—name: myDocker execution: onExecute:—docker build -t ${res_dependencyModeImage_imageName}:${run_number}。—docker push ${res_dependencyModeImage_imageName}:${run_number}—write_output dependencyModeImage imageTag=${run_number}—name: A_waitOnParent configuration: dependencyMode: waitOnParentComplete: true waitOnParentSuccess: true steps:—name: pullImage type: Bash configuration: inputResourc2022世界杯阿根廷预选赛赛程es:—name: dependencymodeimage_imagename}:${res_dependencyModeImage_imageTag} |
例2 -waitOnChildComplete
在这个例子中,t他父母管道B_waitOnChilD一直等到子管道B_Child的运行结束了,自从waitOnChildComplete
设置为真正的
为B_waitOnChild.
代码块 | ||
---|---|---|
|
||
2022世界杯阿根廷预选赛赛程resources:—name: dependencyModePropertyBag type: PropertyBag configuration: runNumber: 0 pipelines:—name: B_waitOnChild configuration: dependencyMode: waitOnChildComplete: true steps:—name: updateProperties type: Bash configuration: outputResources:—name: dependencyModePropertyBag execution: onExecute:—write_output dependencyModePropertyBag runNumber=${run_number}—name: B_Child steps:—name: echoProperty type: Bash configuration: inputResources:—name:dependencyModePropertyBag执行:onExecute: - echo ${res_dependencyModePropertyBag_runNumber} - sleep 5 - name: echoComplete类型:Bash配置:inputSteps: - name: echoProperty执行:onExecute: - echo "complete" |