Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declarative pipeline Fargate example does not work (Invalid agent type "ecs" specified.) #84

Closed
JohnLahr opened this issue Mar 5, 2019 · 5 comments

Comments

@JohnLahr
Copy link

JohnLahr commented Mar 5, 2019

When I run a simple declarative pipeline like the one in your PR comments and your readme, I am hit with this error immediately when trying to create a Fargate agent:

Invalid agent type "ecs" specified. Must be one of [any, docker, dockerfile, label, none]

There is no "agent type" called "ecs" as far as Jenkins is able to determine, and we've even tried to restart the instance itself with hopes that maybe the plugin needed another reload before it could be detected and run properly in a pipeline.

The code we are trying is this example provided by this project, modified a bit to strip out any additional complications:

pipeline {
  agent none

  stages {
    stage('Test') {
        agent {
            ecs {
                inheritFrom 'jnlp-slave'
                cpu 2048
                memory 4096
            }
        }
        steps {
            sh 'echo hello'
        }
    }
  }
}

Can this documentation get some clarification? This is the only example we can find regarding using this in a declarative pipeline, so we have absolutely no idea what to change here to get this working.

@pgarbe
Copy link
Contributor

pgarbe commented Mar 11, 2019

Which version are you using? The declarative support comes with 1.20 with is currently in beta (1.20-beta2)

@albac
Copy link

albac commented Mar 20, 2019

On version 1.19, which is the latest officially at this moment, you can still use this:

pipeline {
  agent none
  stages {
    stage('Test') {
        agent { label 'fargate-slave'}
        steps {
            sh 'echo hello from fargate'
        }
    }
  }
}

And works as long as you setup correctly fargate on settings and use that label.

@pgarbe pgarbe closed this as completed Apr 8, 2019
@alineprattiezops
Copy link

Which version are you using? The declarative support comes with 1.20 with is currently in beta (1.20-beta2)

Please, could help us?
We install 1.20-beta2 but we are not having success in the declarative override:

pipeline {
agent any
stages {
stage('Test') {
agent {
ecs {
cloud 'cloud-default'
label 'ecs'
image 'jenkinsci/jnlp-slave'
launchType 'FARGATE'
memory 4096
cpu 2048
subnets 'subnet-xxxxxxxxxxxxx'
securityGroups 'sg-xxxxxxxxxxx'
assignPublicIp true
taskrole 'arn:aws:iam::xxxxxxxxxxxxxxx:role/ecsTaskExecutionRole'
inheritFrom 'fargate-template'
}
}
steps {
sh 'echo hello'
}
}
}
}

Jenkins output:
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Test)
[Pipeline] ecsTaskTemplate
[Pipeline] // ecsTaskTemplate
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: Cloud does not exist: cloud-default
Finished: FAILURE

Jenkins Log:
Apr 11, 2019 9:13:08 PM INFO com.cloudbees.jenkins.plugins.amazonecs.pipeline.ECSDeclarativeAgent getAsArgs
In getAsArgs. label: ecs
Apr 11, 2019 9:13:08 PM INFO com.cloudbees.jenkins.plugins.amazonecs.pipeline.ECSDeclarativeAgent getAsArgs
In getAsArgs. argMap: {assignPublicIp=true, cloud=cloud-default, cpu=2048, image=jenkinsci/jnlp-slave, inheritFrom=fargate-template, label=ecs, launchType=FARGATE, memory=4096, name=ecs, overrides=[assignPublicIp, cloud, cpu, image, inheritFrom, label, launchType, memory, securityGroups, subnets, taskrole], privileged=false, securityGroups=sg-xxxxxxxx, subnets=subnet-xxxxxxxx, taskrole=arn:aws:iam::xxxxxxxx:role/ecsTaskExecutionRole}
Apr 11, 2019 9:13:08 PM INFO org.jenkinsci.plugins.workflow.job.WorkflowRun finish
test_pipeline #36 completed: FAILURE

@pgarbe
Copy link
Contributor

pgarbe commented Apr 12, 2019

In your Jenkins settings (Manage Jenkins -> Configure System), did you set up a "Amazon EC2 Container Services Cloud" with name"default-cloud"? Maybe this is missing?

@pgarbe
Copy link
Contributor

pgarbe commented Apr 15, 2019

closed. further discussion in #92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants