Difference between PUT and OUTPUT steps in Concourse

2k Views Asked by At

Could someone tell me the difference between the PUT step and the OUTPUT step in Concourse? For example, in the following type of YAML files why do we need a put step after a get? Can't we use output instead of put? If not what are the purposes of each two?

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 ->
    ....
1

There are 1 best solutions below

0
On BEST ANSWER

The purpose of a PUT step is to push to the given resource while an OUTPUT is the result of TASK step.

A task can configure outputs to produce artifacts that can then be propagated to either a put step or to another task step in the same plan.

This means that you send the resource that you are specifying on the GET step to the task as an input, to perform wherever build or scripts executions and the output of that task is a modified resource that you can later pass to your put step or to another TASK if you don't want to use PUT.

It would also depend on the nature of the defined resource in your pipeline. I'm assuming that you have a git type resource like this:

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)) 

If this is true, the GET step will pull that repo so you can use it as an input for your tasks and if you use PUT against that same resource as you are describing in your sample code, that will push changes to your repo.

Really it depends on the workflow that you want to write but to give an idea it would look something like this:

 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

Then you can use it on either a PUT

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

or a another task whitin the same plan

- 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    

Hope it helps!