Jenkins Build and ECR Push

Docker build with Jenkins and push to Amazon ECR!

Before getting started

Docker Build & Push with Jenkins

1. Include a Dockerfile in the service's source code

2. Configure the jenkins server to be able to access ECR

3. Create a deployment Job for the service in jenkins, and set the Job to build a new image using the pre-included Dockerfile when executed

4. Build a new docker image on the jenkins server and then push the image to ECR

5. Finally, on the test server, pull the new image from ECR, delete the existing container, and create a new container

Configure Jenkins job example

ex1) Discard old builds

  • Discard old builds

    • With the settings shown in the example above, Build History is stored for 10 days and a maximum of 20 build histories are kept

      ex)

ex2) Invoke Gradle script

  • For Java projects built with Gradle, you can specify Tasks as shown above

ex3) Execute shell

  • You can write shell scripts to be executed during the Jenkins job build as shown above

ex4) Post-build Actions

  • To save artifacts after the build, you can configure settings as shown above

Last updated