PageRenderTime 27ms CodeModel.GetById 18ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/tutorials/basic/11-task-inputs-bonus/README.md

https://bitbucket.org/igtbdigital/concourse-ci
Markdown | 113 lines | 92 code | 21 blank | 0 comment | 0 complexity | 2cbcba50a3cc155c140c1637f9503d24 MD5 | raw file
  1Task inputs
  2===========
  3
  4The pipelines in this tutorial show a task that imports resources and how it can access the files from those resources.
  5
  6http://concourse.ci/build-plans.html
  7
  8```
  9$ ./run.sh ls-abc-xyz
 10...
 11running ls -opR .
 12.:
 13total 8
 14drwxr-xr-x 3 vcap 4096 Apr  8 04:52 gist-abc/
 15drwxr-xr-x 3 vcap 4096 Apr  8 04:53 gist-xyz/
 16
 17./gist-abc:
 18total 12
 19-rw-r--r-- 1 vcap 8 Apr  8 04:52 a.md
 20-rw-r--r-- 1 vcap 8 Apr  8 04:52 b.md
 21-rw-r--r-- 1 vcap 8 Apr  8 04:52 c.md
 22
 23./gist-xyz:
 24total 12
 25-rw-r--r-- 1 vcap 8 Apr  8 04:53 x.md
 26-rw-r--r-- 1 vcap 8 Apr  8 04:53 y.md
 27-rw-r--r-- 1 vcap 8 Apr  8 04:53 z.md
 28```
 29
 30The job `job-with-inputs` has a build plan that:
 31
 32-	pulls in (`get`s) two resources (`type: git`) and
 33-	they are made available to the task `ls-abc-xyz`.
 34
 35The two `get` resources are described:
 36
 37```yaml
 38- { get: gist-abc, resource: resource-gist-a-b-c }
 39- { get: gist-xyz, resource: resource-gist-x-y-z }
 40```
 41
 42They come from resources `resource-gist-a-b-c` and `resource-gist-x-y-z`; and are renamed `gist-abc` and `gist-xyz` respectively (their name within this particular job build plan).
 43
 44The purpose of the `ls-abc-xyz` task is to show how the resources `resource-gist-a-b-c` and `resource-gist-x-y-z` are passed through to subsequent steps.
 45
 46Looking at the output above you can see that the content of each resource are nested inside subfolders of the renamed build plan resources (`gist-abc` and `gist-xyz`).
 47
 48### Explicit task inputs
 49
 50The task `ls-abc-xyz` declares explicitly that it wants both resources via its `inputs` configuration:
 51
 52```yaml
 53- task: ls-abc-xyz
 54  config:
 55    platform: linux
 56    image_resource:
 57      type: docker-image
 58      source: {repository: ubuntu}
 59    inputs:
 60    - name: gist-abc
 61    - name: gist-xyz
 62    run:
 63      path: ls
 64      args: ["-opR", "."]
 65```
 66
 67The `ls-abc-xyz` task explicitly shows that it has access to the files from the two resources (see output above). The files are in the root of the fetched repositories; but during the build plan they are now nested beneath a folder.
 68
 69We can demonstrate that a task only has access to resource inputs that it specifies by removing `gist-xyz` from the list of `inputs` above.
 70
 71```
 72$ run.sh ls-abc
 73...
 74initializing
 75running ls -opR .
 76.:
 77total 4
 78drwxr-xr-x 3 vcap 4096 Apr  8 05:17 gist-abc/
 79
 80./gist-abc:
 81total 12
 82-rw-r--r-- 1 vcap 8 Apr  8 05:17 a.md
 83-rw-r--r-- 1 vcap 8 Apr  8 05:17 b.md
 84-rw-r--r-- 1 vcap 8 Apr  8 05:17 c.md
 85```
 86
 87Bonus - pretty print via resource script
 88----------------------------------------
 89
 90```
 91$ ./run.sh pretty-ls
 92...
 93initializing
 94running bash pretty-ls/pretty_ls.sh .
 95./gist-abc
 96./gist-xyz
 97./pretty-ls
 98./gist-abc/a.md
 99./gist-abc/b.md
100./gist-abc/c.md
101./gist-xyz/x.md
102./gist-xyz/y.md
103./gist-xyz/z.md
104./pretty-ls/pretty_ls.sh
105initializing
106running bash pretty-ls/pretty_ls.sh .
107./gist-xyz
108./pretty-ls
109./gist-xyz/x.md
110./gist-xyz/y.md
111./gist-xyz/z.md
112./pretty-ls/pretty_ls.sh
113```