Trigger events in Concourse

一笑奈何 提交于 2020-01-07 04:07:51

问题


I'm trying to fire events when a task/resource is executed. Currently the idea is to trigger an event in the script of the task.

As I need the metadata variables (BUILD_ID, BUILD_NAME) as part of the information to be sent in the event, I've created a resource (the only way to access to the metadata) and passed it to the task. But the problem is that I cannot access to theses variables in the tasks.

Any idea o strategy to solve this?


回答1:


If you want to access data within your resource, you need to pass the resource to the task you are executing.

Check out this example https://gist.github.com/gdenn/91e9d5369f7e0e289960e56cd69e942f

We have the job demo_job which holds a resource some_git_resource and a task use_demo_resource_and_do_something.

In order to let the task access the data inside some_resource, you need to declare the resource as input of the task.

You do so by specifying the variable name and path in line 15 & 16. With the name property you reference the resource name and with the path variable you specify the path for the resource folder in your docker container.

Upload the pipeline and trigger the job. Once it is running use the fly hijack command to log into the docker container of the task use_demo_resource_and_do_something. You will notice that your container has a folder called some_git_resource in the root.

If you only have one input for your task you could also set the path to . But keep in mind that this will only work for single inputs. If you want to use multiple inputs in your task, you have to use a proper path.

If you have trouble with your scripts inside the tasks, try hijacking the container. Often you get some more insight why your task is not working this way. To hijack demo_task inside the demo_job use this command fly -t <your_target> hijack -j demo_job/demo_task

For further informations checkout the concourse task documentation.



来源:https://stackoverflow.com/questions/45882044/trigger-events-in-concourse

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!