会话中PUT和OUTPUT步骤之间的差异

问题描述 投票:0回答:1

有人可以告诉我在Concourse中PUT步骤与OUTPUT步骤之间的区别吗?例如,在以下类型的YAML文件中,为什么在put之后需要get步骤?我们不能用output代替put吗?如果不是,那么两者的目的是什么?

jobs:
  - name: PR-Test
    plan:
    - get: some-git-pull-request
      trigger: true
    - put: some-git-pull-request
      params:
        context: tests
        path: some-git-pull-request
        status: pending

    ....
     <- some more code to build ->
    ....
continuous-integration concourse concourse-git-resource concourse-pipeline concourse-task
1个回答
0
投票

PUT步骤的目的是推送到给定的资源,而OUTPUTTASK步骤的结果。

一个任务可以配置输出以生成工件,然后可以将该工件传播到同一计划中的放置步骤或另一个任务步骤。

这意味着您将在GET步骤上指定的资源作为输入发送给任务,以执行构建或脚本执行的地方以及该任务的输出是修改后的资源,如果您不想使用PUT,可以稍后将其传递给放置步骤或传递给另一个TASK

这还取决于管道中已定义资源的性质。我假设您具有这样的git类型资源:

resources:

    - name: some-git-pull-request
      type: git
      source:
        branch:   ((credentials.git.branch))
        uri:      ((credentials.git.uri))
        username: ((credentials.git.username))
        password: ((credentials.git.pass)) 

如果是这样,则GET步骤将拉该存储库,因此您可以将其用作任务的输入,如果对示例代码中描述的相同资源使用PUT,则会将更改推送到存储库中。

确实取决于您要编写的工作流程,但是要给出一个想法,它看起来像这样:

 jobs:
  - name: PR-Test
    plan:
    - get: some-git-pull-request
      trigger: true 
    - task: test-code
      config:
        platform: linux
        image_resource:
          type: docker-image
          source:
            repository: yourRepo/yourImage
            tag: latest
        inputs:
          - name: some-git-pull-request                   
        run:
          path: bash  
          args:
          - -exc
          - |  
            cd theNameOfYourRepo
            npm install -g mocha
            npm test
        outputs:
          - name: some-git-pull-request-output

然后您可以在任一PUT上使用它

  - put: myCloud
    params:
      manifest: some-git-pull-request-output/manifest.yml
      path: some-git-pull-request-output

或另一项与同一计划有关的任务

- task: build-code
  config:
    platform: linux
    image_resource:
      type: docker-image
      source:
        repository: yourRepo/yourImage
        tag: latest
    inputs:
      - name: some-git-pull-request-output                   
    run:
      path: bash  
      args:
      - -exc
      - |  
        cd some-git-pull-request-output/
        npm install
        gulp build

    outputs:
      - name: your-code-build-output    

希望有帮助!

© www.soinside.com 2019 - 2024. All rights reserved.