jenkinsci / amazon-ecs-plugin

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

taskDefinitionOverride not getting checked when retain agent is enabled #356

Closed aki59 closed 1 month ago

aki59 commented 1 month ago

Jenkins and plugins versions report

Environment ```text Paste the output here ```

What Operating System are you using (both controller, and any agents involved in the problem)?

Linux Jenkins 2.426.3

Reproduction steps

pipeline {
  agent none

  stages {
    stage('Test') {
        agent {
            ecs {
                inheritFrom 'label-of-my-preconfigured-template'
                taskDefinitionOverride  'custom-td-for the-job-1'
               securitGroups 'awssecg'
               subnets 'awssubmets'
            }
        }
        steps {
            sh 'echo hello'
        }
    }
  }
}

2nd job :-

pipeline {
  agent none

  stages {
    stage('Test'2) {
        agent {
            ecs {
                inheritFrom 'label-of-my-preconfigured-template'
                taskDefinitionOverride  'custom-td-for the-job-2'
               securitGroups 'awssecg'
               subnets 'awssubmets'
            }
        }
        steps {
            sh 'echo hello'
        }
    }
  }
}

Try to run the job 1 with retain agent enabled, it will create an ecs task. Now when running 2nd job after the completion of 1st job same agent is getting picked up although task definition is different.

Expected Results

taskDefinitionOverride should get consider before picking the warmed agent.

Actual Results

taskDefinitionOverride param is not getting checked while picking warmed agent.

Anything else?

Not sure if this is the expected behaviour so just want help in this.

Are you interested in contributing a fix?

Yes

aki59 commented 1 month ago

Found out that we can override label name creation happening via inheritfrom, by adding label field, added that and now I am able to use retained agents with respective to that task definition