jenkinsci / amazon-ecs-plugin

Amazon EC2 Container Service Plugin for Jenkins
https://plugins.jenkins.io/amazon-ecs
MIT License
192 stars 226 forks source link

Tag Task #261

Closed charbl closed 2 years ago

charbl commented 2 years ago

What feature do you want to see added?

Is there any way we can add tag to the TASK? So that when the task is run, it will contain tags that represent the project that the job was run under?

Upstream changes

No response

Stericson commented 2 years ago

PR merged. Thanks!

charbl commented 1 year ago

So, I see now that you can add tags to the ECS agent templates. Can this reference an environment variable for the value? I am looking to "Tag" the job running in the ECS agent .... Jenkins job targets ECS on-demand worker (ECS spins up instance from plugin and template), but I want the Job to mark the task with a tag. We have several diff orgs that use a single instance of Jenkins which offers On-Demand agents. As org one runs a job (on-demand ECS), I would like to mark (tag) that task with org one. I want to break down usage across the orgs when it comes to usage and cost. Can we do this now? If not, can we add?

Stericson commented 1 year ago

@charbl, do you want to reference environment variables defined on the Primary Jenkins Node (Main) or some environment variable within the worker node?

charbl commented 1 year ago

Would like to declare the Env Variable value as the job kicks off and when the task definition is created for the ECS job, it pulls the value of the Env Var into the tag, and then the task is run on ECS using the tagged def. So, we have 3 orgs that use a shared Jenkins. This Jenkins runs On-Demand agents (with plugin) and when Org1 starts a job that runs on the On-demand workers, I want Org1 to set the Env Var to "Org1-PrjA". Job/Task run and are marked with a tag that has name = "Project" with value "Org1-PrjA". So, I would guess the Env Var is on the worker node? Just need to be able to set it to a value before the task is defined and run.