【问题标题】:Difference between PUT and OUTPUT steps in ConcourseConcourse 中 PUT 和 OUTPUT 步骤的区别
【发布时间】:2019-12-02 15:33:56
【问题描述】:

有人能告诉我 Concourse 中的 PUT 步骤和 OUTPUT 步骤之间的区别吗?例如,在以下类型的 YAML 文件中,为什么我们需要在 get 之后添加 put 步骤?我们不能用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】:

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

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

    这意味着您将在 GET 步骤中指定的资源作为输入发送到任务,以执行构建或脚本执行以及该任务的输出 是修改后的资源,如果您不想使用 PUT,您可以稍后将其传递给您的 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 步骤将拉取该 repo,以便您可以将其用作任务的输入,如果您对示例代码中描述的同一资源使用 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    
    

    希望对你有帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-23
      • 2021-08-29
      • 2021-09-22
      • 1970-01-01
      相关资源
      最近更新 更多