From f3ad6df2c0d09f75625fc71f5fdcd9ccb6816e1e Mon Sep 17 00:00:00 2001 From: Oleg Nenashev Date: Fri, 20 Sep 2019 13:50:55 +0200 Subject: [PATCH 1/3] [JENKINS-42846] - Rename the jenkins-slave script to jenkins-agent --- Dockerfile | 9 +++++++-- jenkins-slave => jenkins-agent | 7 ++++--- jenkins-agent.ps1 | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) rename jenkins-slave => jenkins-agent (94%) mode change 100755 => 100644 diff --git a/Dockerfile b/Dockerfile index 6fad8d50..0a178417 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,6 +24,11 @@ FROM jenkins/slave:3.35-1 MAINTAINER Oleg Nenashev LABEL Description="This is a base image, which allows connecting Jenkins agents via JNLP protocols" Vendor="Jenkins project" Version="3.35-1" -COPY jenkins-slave /usr/local/bin/jenkins-slave +ARG user=jenkins -ENTRYPOINT ["jenkins-slave"] +USER root +COPY jenkins-agent /usr/local/bin/jenkins-agent +RUN ln -s /usr/local/bin/jenkins-agent /usr/local/bin/jenkins-slave +USER ${user} + +ENTRYPOINT ["jenkins-agent"] diff --git a/jenkins-slave b/jenkins-agent old mode 100755 new mode 100644 similarity index 94% rename from jenkins-slave rename to jenkins-agent index 4d893071..0a556ea3 --- a/jenkins-slave +++ b/jenkins-agent @@ -2,7 +2,7 @@ # The MIT License # -# Copyright (c) 2015, CloudBees, Inc. +# Copyright (c) 2015-2019, CloudBees, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -# Usage jenkins-slave.sh [options] -url http://jenkins [SECRET] [AGENT_NAME] +# Usage jenkins-agent.sh [options] -url http://jenkins [SECRET] [AGENT_NAME] # Optional environment variables : # * JENKINS_TUNNEL : HOST:PORT for a tunnel to route TCP traffic to jenkins host, when jenkins can't be directly accessed over network # * JENKINS_URL : alternate jenkins URL @@ -96,5 +96,6 @@ else #TODO: Handle the case when the command-line and Environment variable contain different values. #It is fine it blows up for now since it should lead to an error anyway. - exec $JAVA_BIN $JAVA_OPTS $JNLP_PROTOCOL_OPTS -cp /usr/share/jenkins/slave.jar hudson.remoting.jnlp.Main -headless $TUNNEL $URL $WORKDIR $OPT_JENKINS_SECRET $OPT_JENKINS_AGENT_NAME "$@" + ls -la /usr/share/jenkins/ + exec $JAVA_BIN $JAVA_OPTS $JNLP_PROTOCOL_OPTS -cp /usr/share/jenkins/agent.jar hudson.remoting.jnlp.Main -headless $TUNNEL $URL $WORKDIR $OPT_JENKINS_SECRET $OPT_JENKINS_AGENT_NAME "$@" fi diff --git a/jenkins-agent.ps1 b/jenkins-agent.ps1 index 43d43833..05c883be 100644 --- a/jenkins-agent.ps1 +++ b/jenkins-agent.ps1 @@ -31,7 +31,7 @@ Param( $JavaHome = $env:JAVA_HOME ) -# Usage jenkins-slave.ps1 [options] -Url http://jenkins -Secret [SECRET] -Name [AGENT_NAME] +# Usage jenkins-agent.ps1 [options] -Url http://jenkins -Secret [SECRET] -Name [AGENT_NAME] # Optional environment variables : # * JENKINS_TUNNEL : HOST:PORT for a tunnel to route TCP traffic to jenkins host, when jenkins can't be directly accessed over network # * JENKINS_URL : alternate jenkins URL From efe18a9921dffbfefd59b7fac2890fc9f0d3b3b5 Mon Sep 17 00:00:00 2001 From: Oleg Nenashev Date: Fri, 20 Sep 2019 15:17:53 +0200 Subject: [PATCH 2/3] [JENKINS-42846] - Apply renaming to Alpine and JDK11 images --- Dockerfile-alpine | 7 ++++++- Dockerfile-jdk11 | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Dockerfile-alpine b/Dockerfile-alpine index b406a19f..fa3b5c62 100644 --- a/Dockerfile-alpine +++ b/Dockerfile-alpine @@ -24,6 +24,11 @@ FROM jenkins/slave:3.35-2-alpine MAINTAINER Oleg Nenashev LABEL Description="This is a base image, which allows connecting Jenkins agents via JNLP protocols" Vendor="Jenkins project" Version="3.35-2" -COPY jenkins-slave /usr/local/bin/jenkins-slave +ARG user=jenkins + +USER root +COPY jenkins-agent /usr/local/bin/jenkins-agent +RUN ln -s /usr/local/bin/jenkins-agent /usr/local/bin/jenkins-slave +USER ${user} ENTRYPOINT ["jenkins-slave"] diff --git a/Dockerfile-jdk11 b/Dockerfile-jdk11 index e04d9196..e19cde23 100644 --- a/Dockerfile-jdk11 +++ b/Dockerfile-jdk11 @@ -24,6 +24,11 @@ FROM jenkins/slave:3.35-2-jdk11 MAINTAINER Oleg Nenashev LABEL Description="This is a base image, which allows connecting Jenkins agents via JNLP protocols" Vendor="Jenkins project" Version="3.35-2" -COPY jenkins-slave /usr/local/bin/jenkins-slave +ARG user=jenkins + +USER root +COPY jenkins-agent /usr/local/bin/jenkins-agent +RUN ln -s /usr/local/bin/jenkins-agent /usr/local/bin/jenkins-slave +USER ${user} ENTRYPOINT ["jenkins-slave"] From b839a9740d4500956f35f1e4d134fb38b5d281e9 Mon Sep 17 00:00:00 2001 From: Oleg Nenashev Date: Fri, 20 Sep 2019 15:22:05 +0200 Subject: [PATCH 3/3] [JENKINS-42846] - Remove the debug code --- jenkins-agent | 1 - 1 file changed, 1 deletion(-) diff --git a/jenkins-agent b/jenkins-agent index 0a556ea3..ec0b57bc 100644 --- a/jenkins-agent +++ b/jenkins-agent @@ -96,6 +96,5 @@ else #TODO: Handle the case when the command-line and Environment variable contain different values. #It is fine it blows up for now since it should lead to an error anyway. - ls -la /usr/share/jenkins/ exec $JAVA_BIN $JAVA_OPTS $JNLP_PROTOCOL_OPTS -cp /usr/share/jenkins/agent.jar hudson.remoting.jnlp.Main -headless $TUNNEL $URL $WORKDIR $OPT_JENKINS_SECRET $OPT_JENKINS_AGENT_NAME "$@" fi