In this tutorial I will show you how to execute task scripts and using task inputs to have the ability to pass data to concourse for processing.
For my other content on concourse, have a look at the concourse category.
Task Inputs
First, let’s run a task on concourse that does not rely on any inputs.
1 2 3 4 5 6 7 8 9 |
|
Running execute with the configuration from above:
1 2 3 4 5 6 7 |
|
As you can see we have executed the command uname -a
on one of the containers in Concourse.
Tasks Inputs: Specify Path
Now lets say, we have data that needs to be transferred to the container where we are running our tasks. For that we are using inputs.
In this example, we will set the input parameter in our task definition, and override the path with the cli. We will create a couple of files in a folder, then list them in the container where the task is running.
Creating the data:
1 2 |
|
Our task definition:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
As you can see our input name is called my-input
and we will use the cli to map the local folder my-data-folder
to the parameter name:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
As you can see from the above output, the folder was uploaded and placed inside the container where we ran our task.
Task Inputs: Parent Directory
Then we can use parent directories. Running a task that relies on the input path which will be our current working directory. Note: the input name should be the same as the current working directory
The input name will be the only thing that differs, which will look like:
1 2 |
|
Running the task:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
The source code for this can be found at https://github.com/ruanbekker/concourse-tutorial/tree/master/02-task-inputs
Task Scripts:
In conjunction with inputs, we can let our task configuration reference a script that we want to execute, and using inputs, we can upload the current working directory to concourse, so then the container has context about the data that it needs.
Our task configuration task_show_hostname.yml
1 2 3 4 5 6 7 8 9 10 11 |
|
Our executable script 03-task-scripts/task_show_hostname.sh
1 2 3 4 |
|
Make sure to apply the executable permissions to the script:
1
|
|
With this configuration, it uploads the current working directory to concourse, and the data inside the directory gets placed on the container’s working directory: 03-task-scripts, which is the name of the input.
1 2 3 4 5 6 7 8 |
|
The source code for this example can be found at https://github.com/ruanbekker/concourse-tutorial/tree/master/03-task-scripts
That’s it for Task Inputs and Task Scripts on Concourse, please feel free to have a look at my other content about Concourse
Thank You
Please feel free to show support by, sharing this post, making a donation, subscribing or reach out to me if you want me to demo and write up on any specific tech topic.