First import
Some checks failed
perso/jnlp-slave-docker-arm64/master There was a failure building this commit

This commit is contained in:
Julien Cabillot 2020-01-08 16:19:11 -05:00
commit a874654e7e
3 changed files with 164 additions and 0 deletions

43
Dockerfile Normal file
View File

@ -0,0 +1,43 @@
FROM arm64v8/openjdk:11-jre
MAINTAINER Marek Obuchowicz <marek@korekontrol.eu>
# Tini
ADD https://github.com/krallin/tini/releases/download/v0.18.0/tini-arm64 /tini
RUN chmod +x /tini
# Install docker client, kubectl and helm
RUN curl -sSL https://get.docker.com/ | sh
# Debian packages
RUN apt-get update -qy && \
DEBIAN_FRONTEND=noninteractive apt-get install -qy python-pip groff-base git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# AWS CLI, j2cli
RUN pip install awscli && \
pip install j2cli
# Jenkins
ENV HOME /home/jenkins
RUN useradd -c "Jenkins user" -d $HOME -u 10000 -g 999 -m jenkins
LABEL Description="This is a base image, which provides the Jenkins agent executable (slave.jar) and tools: j2cli, awscli, docker client, kubectl and helm" Vendor="KoreKontrol" Version="3.27"
ARG VERSION=3.40
#RUN curl --create-dirs -sSLo /usr/share/jenkins/slave.jar https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/${VERSION}/remoting-${VERSION}.jar
ADD https://jenkins.docker.cabillot.eu/jnlpJars/agent.jar /usr/share/jenkins/agent.jar
RUN chmod 755 /usr/share/jenkins \
&& chmod 644 /usr/share/jenkins/agent.jar
# jnlp slave
COPY jenkins-slave /usr/local/bin/jenkins-slave
RUN chmod +x /usr/local/bin/jenkins-slave
USER jenkins
RUN mkdir /home/jenkins/.jenkins
VOLUME /home/jenkins/.jenkins
WORKDIR /home/jenkins
ENTRYPOINT ["/tini", "--", "jenkins-slave"]

38
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,38 @@
pipeline {
environment {
registry = 'https://registry.hub.docker.com'
registryCredential = 'dockerhub_jcabillot'
dockerImage = 'jcabillot/jnlp-slave-docker-arm64'
}
agent { label 'arm64' }
triggers {
cron('@midnight')
}
stages {
stage('Clone repository') {
steps{
checkout scm
}
}
stage('Build image') {
steps{
sh 'docker build --force-rm=true --no-cache=true --pull -t ${dockerImage} .'
}
}
stage('Deploy Image') {
steps{
script {
withCredentials([usernamePassword(credentialsId: 'dockerhub_jcabillot', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) {
sh 'docker login --username ${DOCKER_USER} --password ${DOCKER_PASS}'
sh 'docker push ${dockerImage}'
}
}
}
}
}
}

83
jenkins-slave Normal file
View File

@ -0,0 +1,83 @@
#!/usr/bin/env bash
# The MIT License
#
# Copyright (c) 2015, 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
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# 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]
# 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
# * JENKINS_SECRET : agent secret, if not set as an argument
# * JENKINS_AGENT_NAME : agent name, if not set as an argument
if [ $# -eq 1 ]; then
# if `docker run` only has one arguments, we assume user is running alternate command like `bash` to inspect the image
exec "$@"
else
# if -tunnel is not provided try env vars
if [[ "$@" != *"-tunnel "* ]]; then
if [ ! -z "$JENKINS_TUNNEL" ]; then
TUNNEL="-tunnel $JENKINS_TUNNEL"
fi
fi
if [ -n "$JENKINS_URL" ]; then
URL="-url $JENKINS_URL"
fi
if [ -n "$JENKINS_JNLP" ]; then
JNLPURL="-jnlpUrl $JENKINS_JNLP"
fi
if [ -n "$JENKINS_NAME" ]; then
JENKINS_AGENT_NAME="$JENKINS_NAME"
fi
if [ -z "$JNLP_PROTOCOL_OPTS" ]; then
echo "Warning: JnlpProtocol3 is disabled by default, use JNLP_PROTOCOL_OPTS to alter the behavior"
JNLP_PROTOCOL_OPTS="-Dorg.jenkinsci.remoting.engine.JnlpProtocol3.disabled=true"
fi
# If both required options are defined, do not pass the parameters
OPT_JENKINS_SECRET=""
if [ -n "$JENKINS_SECRET" ]; then
if [[ "$@" != *"${JENKINS_SECRET}"* ]]; then
OPT_JENKINS_SECRET="${JENKINS_SECRET}"
else
echo "Warning: SECRET is defined twice in command-line arguments and the environment variable"
fi
fi
OPT_JENKINS_AGENT_NAME=""
if [ -n "$JENKINS_AGENT_NAME" ]; then
if [[ "$@" != *"${JENKINS_AGENT_NAME}"* ]]; then
OPT_JENKINS_AGENT_NAME="${JENKINS_AGENT_NAME}"
else
echo "Warning: AGENT_NAME is defined twice in command-line arguments and the environment variable"
fi
fi
exec java $JAVA_OPTS $JNLP_PROTOCOL_OPTS -jar /usr/share/jenkins/agent.jar ${JNLPURL} -secret ${OPT_JENKINS_SECRET} -workDir "/home/jenkins/"
fi