This Jenkins plugin do use Amazon Elastic Container Service to host jobs execution inside docker containers.
- see Jenkins wiki for detailed feature descriptions
- use GitHub Issues to report issues / feature requests
Please find the documentation on the Jenkins Wiki page Amazon EC2 Container Service Plugin.
Declarative Pipeline support requires Jenkins 2.66+
Declarative agents can be defined like shown below. You can also reuse pre-configured templates and override certain settings using inheritFrom
to reference the Label field of the template that you want to use as preconfigured. Only one label is expected to be specified.
Note: You have to configure list of settings to be allowed in the declarative pipeline first (see the Allowed Overrides setting). They are disabled by default for security reasons, to avoid non-privileged users to suddenly be able to change certain settings.
pipeline {
agent none
stages {
stage('Test') {
agent {
ecs {
inheritFrom 'my-preconfigured-template'
cpu 2048
memory 4096
logDriver 'fluentd'
logDriverOptions([[name: 'foo', value:'bar'], [name: 'bar', value: 'foo']])
}
}
steps {
sh 'echo hello'
}
}
}
}
Actually, there can be multiple reasons:
-
The plugin creates a new agent only when the stage contains an
agent
definition. If this is missing, the stage inherits the agent definition from the level above and also re-uses the instance. -
Also, parallel stages sometimes don't really start at the same time. Especially, when the provided label of the
agent
definition is the same. The reason is that Jenkins tries to guess how many instances are really needed and tells the plugin to start n instances of the agent with label x. This number is likely smaller than the number of parallel stages that you've declared in your Jenkinsfile. Jenkins calls the ECS plugin multiple times to get the total number of agents running. -
If launching of the agents takes long, and Jenkins calls the plugin in the meantime again to start n instances, the ECS plugin doesn't know if this instances are really needed or just requested because of the slow start. That's why the ECS plugin subtracts the number of launching agents from the number of requested agents (for a specific label). This can mean for parallel stages that some of the agents are launched after the previous bunch of agents becomes online.
Andreas Sieferlinger (GitHub Twitter)
Philipp Garbe (GitHub, Twitter)
Marky Jackson (GitHub, Twitter)
Building the Plugin
$ java -version # Need Java 1.8, earlier versions are unsupported for build
$ mvn -version # Need a modern maven version; maven 3.2.5 and 3.5.0 are known to work
$ mvn clean install
To run locally, execute the following command and open the browser http://localhost:8080/jenkins/
$ mvn -e hpi:run
Releasing the Plugin
$ mvn release:prepare release:perform