0

Below code snippet, taken from here creates master jenkins that runs in a container:

# Create Docker Group with GID
# Set default value of 497 if DOCKER_GID set to blank string by Docker Compose
RUN groupadd -g ${DOCKER_GID:-497} docker

# Used to control Docker and Docker Compose versions installed
# NOTE: As of February 2016, AWS Linux ECS only supports Docker 1.9.1
ARG DOCKER_ENGINE=1.10.2
ARG DOCKER_COMPOSE=1.6.2

# ......

# Install Docker Engine
RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D && \
    echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | tee /etc/apt/sources.list.d/docker.list && \
    apt-get update -y && \
    apt-get purge lxc-docker* -y && \
    apt-get install docker-engine=${DOCKER_ENGINE:-1.10.2}-0~trusty -y && \
    usermod -aG docker jenkins && \
    usermod -aG users jenkins

Above container is dind that launches task(each container) on single EC2 host.


To regulate load across multiple EC2 host and launch slave jenkins instance(on each).

We would like to have master jenkins generate build_id for each build that can run on two slave jenkins instances.

To have master & slave jenkins run within each container, across EC2 hosts.

How to approach on making slave container and take build_id from master jenkins?

3
  • Hi there - perhaps it's just me, but I'm having a really hard time understanding what you want to do, reading this this post. The Dockerfile you provided doesn't seem to start anything, just does docker-in-docker. Do you want to have a multi-master jenkins setup? Do you want multi-cluster agents spawns? Help us understand what you're trying to do please :) Commented Nov 4, 2019 at 15:54
  • @BruceBecker a single master Jenkins that has two slave Jenkins. Each jenkins(master and slave) run on their own ECS cluster instance Commented Nov 4, 2019 at 15:55
  • Thanks! that clarifies things a lot. Commented Nov 4, 2019 at 15:59

1 Answer 1

2

You could use the EC2 plugin or the ECS plugin if you want to provision agents dynamically. These would provide some environment variables to use when constructing build_id - e.g. :

  • BUILD_TAG:

    String of "jenkins-${JOB_NAME}-${BUILD_NUMBER}". All forward slashes ("/") in the JOB_NAME are replaced with dashes ("-"). Convenient to put into a resource file, a jar file, etc for easier identification.

  • NODE_NAME:

    Name of the agent if the build is on an agent, or "master" if run on master

You would have to configure the clouds in Jenkins, assign a label to the templates you want to use as agents, and then request those in your pipeline or job configuration.

1
  • Does slave jenkins cluster register with ECS service? because master jenkins cluster register with ECS service Commented Dec 26, 2019 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.