We are using both scripted and declarative jenkins pipeline and using dynamic ecs agent for slave.
Following is the configuration :
ecsTaskTemplate(
inheritFrom: dynamiclabelNp
overrides: [],
taskDefinitionOverride: "arn:aws:redacted:redacted:task-definition/td:9"
) {
node(dynamiclabelNp) {
stage("I dunno why you say goodbye"){
sh 'echo hello'
}
}
}
And for declarative pipeline:
pipeline {
agent none
stages {
stage('Test') {
agent {
ecs {
inheritFrom dynamiclabelNp,
overrides: [],
taskDefinitionOverride: "arn:aws:redacted:redacted:task-definition/td:9"
}
}
steps {
sh 'echo hello'
}
}
}
}
Now for declarative pipeline the node is coming up with a random name and picking the above task definition. But for scripted it is showing all node in label “dynamic-agent-test” is offline and if I see the logs it shows that task definition (arn:aws:redacted:redacted:task-definition/td:7) does not exist, which is a old task definition.
How to resolve this for scripted pipeline.