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

[Question] Is it possible to reuse ECS container in different pipelines? #275

Closed TreeKat71 closed 1 year ago

TreeKat71 commented 2 years ago

Describe your use-case which is not covered by existing documentation.

I would like to know if it is possible to use the same ECS container in different pipelines.

Here is the example,

pipeline {
    agent { label "ecs" }
    stages {
        stage('Git pull and checkout') {
            steps {
                build job: 'git_checkout',
                ...,
            }
        }
        stage('Build') {
            steps {
                script {
                    sh 'build xxx'
                }
            }
        }
    }
}

The agent is also label:ecs in the job git_checkout. In the pipeline above, Jenkins will launch two separated ecs. Is it any way to keep these jenkins jobs in the same ecs? Or it is issue related to Jenkins?

Reference any relevant documentation, other materials or issues/pull requests that can be used for inspiration.

No response

Stericson commented 1 year ago

TLDR; -- This isn't possible.

Slightly longer version -- when executing another build from a build there's no shared context. The child job can tell how it was triggered but it has no additional context that I know of. This is a limitation of Jenkins and not this plugin.