Search code examples
dockerdockerfileamazon-ecs

Jenkins is not runnig jobs on the slave


I'm trying to launch a Jenkins agent through ECS. Below is my Dockerfile. When I start a job on this agent, ECS task shows PENDING and then STOPPED and the Jenkins job is stuck with a message that agent is offline. Am I making a mistake with the Jenkins file?

FROM openjdk:8-jdk
MAINTAINER Munavir Chavody <[email protected]>

ARG VERSION=2.164.1
ARG user=jenkins
ARG group=jenkins
ARG uid=1000
ARG gid=1000

ENV HOME /home/${user}
RUN groupadd -g ${gid} ${group}
RUN useradd -c "Jenkins user" -d $HOME -u ${uid} -g ${gid} -m ${user}

ARG AGENT_WORKDIR=/home/${user}/agent

RUN apt-get update
RUN apt-get install -y jq python-pip
RUN pip install awscli
RUN cd /tmp && curl -O https://packages.chef.io/files/stable/chefdk/1.2.22/debian/8/chefdk_1.2.22-1_amd64.deb && dpkg -i chefdk*.deb
RUN curl --create-dirs -sSLo /usr/share/jenkins/slave.jar http://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/3.9/remoting-3.9.jar \
  && chmod 755 /usr/share/jenkins \
  && chmod 644 /usr/share/jenkins/slave.jar
COPY jenkins-slave.sh /usr/local/bin/jenkins-slave.sh
RUN chmod 744 /usr/local/bin/jenkins-slave.sh

USER ${user}
ENV AGENT_WORKDIR=${AGENT_WORKDIR}
RUN mkdir /home/${user}/.jenkins && mkdir -p ${AGENT_WORKDIR}

VOLUME /home/${user}/.jenkins
VOLUME ${AGENT_WORKDIR}
WORKDIR /home/${user}
ENTRYPOINT ["jenkins-slave.sh"]

Solution

  • There was a permission issue with the entry point.