我目前正在设置一个由拉取请求触发的管道。一旦管道启动,就会运行测试。测试成功运行后,我有一个想要批准 PR 的脚本。当我尝试使用
fly
命令设置此管道时,出现以下错误:
无效作业:jobs.pr_approver.plan.do[0].get(pr_approver).passed:作业“ci_concourse_test_pr”不与资源“pr_approver”交互
如何重组它以获得所需的结果,即在
pr_approver
成功运行后运行 ci_concourse_test_pr
作业?
这是我的管道
---
resource_types:
- name: pull-request
type: docker-image
source:
repository: teliaoss/github-pr-resource
resources:
- name: ci_concourse_test
type: pull-request
check_every: 168h
webhook_token: {SECRET}
source:
repository: {GITHUB_REPO}
access_token: {SECRET}
v3_endpoint: https://api.github.com/
v4_endpoint: https://api.github.com/graphql
- name: ci_concourse_test_main
type: git
source:
branch: main
uri: {GITHUB_REPO}
private_key: {SECRET}
- name: pr_approver
type: git
source:
branch: main
uri: {GITHUB_REPO}
private_key: {SECRET}
jobs:
- name: ci_concourse_test_pr
plan:
- get: ci_concourse_test
trigger: true
- put: ci_concourse_test
params:
path: ci_concourse_test
status: pending
- task: sample-test
config:
platform: linux
image_resource:
type: docker-image
source:
repository: {DOCKER_REPO}
tag: latest
inputs:
- name: ci_concourse_test
run:
path: python3
args: [ "ci_concourse_test/ci/test.py" ]
on_success:
put: ci_concourse_test
params:
path: ci_concourse_test
status: success
on_failure:
put: ci_concourse_test
params:
path: ci_concourse_test
status: failure
# Attempting to approve the PR
- name: pr_approver
plan:
- get: pr_approver
passed: [ci_concourse_test_pr]
trigger: true
- task: pr_approver
config:
platform: linux
image_resource:
type: docker-image
source:
repository: {GITHUB_REPO}
tag: latest
inputs:
- name: pr_approver
run:
path: python3
args: [ "github_interface/test.py" ]
在此配置中,您告诉第二个作业使用参数
pr_approver
从第一个作业获取输入 passed
,否则第一个作业不会与资源 pr_approver
交互。
要解决这个问题,你有两个解决方案:
pr_approver
作为第一个作业的输入- name: ci_concourse_test_pr
plan:
- get: ci_concourse_test
trigger: true
- put: ci_concourse_test
params:
path: ci_concourse_test
status: pending
- get: pr_approver
- task: sample-test
....