Docker enhances Jenkins ability to perform various build tasks without having to have the applications or tools installed on the Jenkins server. There are multiple ways Docker agent can be used within Jenkins pipeline. One of the ways are to use Docker images stored in AWS Elastic Container Registry (ECR) in pipeline agent block.
Prereqs
- Jenkins server with Docker installed
- AWS account with Amazon Elastic Container Registry
- Credentials for accessing the registry
Basic Jenkins pipeline structure
Docker agent block
registryUrl: https://<aws-account-no>
.dkr.ecr.us-east-1.amazonaws.com/
image: <ecr-repository-name>
/<image-name>
:<label>
registryCredentialsId: AWS Credentials
Putting it together
References
- What is Amazon Elastic Container Registry?
- Use Containers as Build Agents
- Using Docker with Pipeline