Hello developers,

i don't know if i use the kubernetes-plugin correct:
My jenkinsfile looks like:

podTemplate(label: 'mypod', containers: [
        containerTemplate(name: 'maven', image: 'myOwnMavenImage:latest'', 
ttyEnabled: true, command: 'cat')
      ]) {

        node ('mypod') {
            stage 'Get a Maven project'
            git 'https://github.com/jenkinsci/kubernetes-plugin.git'
            container('maven') {
                stage 'Build a Maven project'
                sh 'mvn clean install'
            }
        }
    }


My Dockerfile uses a script-file as entrypoint:


*run-script:*


export JENKINS_HOME=/var/lib/jenkins

# Setup nss_wrapper so the random user OpenShift will run this container
# has an entry in /etc/passwd.
# This is needed for 'git' and other tools to work properly.
#
export USER_ID=$(id -u)
export GROUP_ID=$(id -g)
envsubst < ${JENKINS_HOME}/passwd.template > ${JENKINS_HOME}/passwd
export LD_PRELOAD=libnss_wrapper.so
export NSS_WRAPPER_PASSWD=${JENKINS_HOME}/passwd
export NSS_WRAPPER_GROUP=/etc/group

exec "$@"


*dockerfile:*


FROM openjdk8:stable

ENV MAVEN_HOME /usr/share/maven
ENV M2_HOME /usr/share/maven
ENV JENKINS_HOME=/var/lib/jenkins

COPY ./contrib/.m2 $JENKINS_HOME/.m2/
COPY ./contrib/maven $M2_HOME
COPY ./contrib/fix-permissions /usr/local/bin/fix-permissions
COPY ./contrib/passwd.template $JENKINS_HOME/passwd.template
COPY ./contrib/run /var/lib/jenkins/run

USER root

RUN yum-config-manager --disable epel >/dev/null || : && \
    yum-config-manager --enable rhel-7-server-ose-3.3-rpms || : && \
    INSTALL_PKGS="nss_wrapper gettext git lsof rsync tar unzip which zip" && 
\
    yum install -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
    rpm -V $INSTALL_PKGS && \
    yum clean all
    
RUN    localedef -f UTF-8 -i en_US en_US.UTF-8
RUN    ln -s $M2_HOME/bin/mvn /usr/bin/mvn
RUN    chmod a+x /usr/local/bin/fix-permissions
RUN    chown -R 1001:0 $M2_HOME
RUN    chmod 775 $M2_HOME/bin/*
RUN    /usr/local/bin/fix-permissions $M2_HOME/bin
    
RUN chown -R 1001:0 $JENKINS_HOME && \
    chmod -R g+rw $JENKINS_HOME

USER 1001

ENTRYPOINT ["/var/lib/jenkins/run"]

If i start the jenkins-job the pod is started with the jnlp- and the 
maven-container, but my shellscript in the maven-container is not used. I 
think thats because i use a cmd in the containertemplate of the 
maven-container.


If i delete the cmd an set tty to 'false' the shellskript is used but the 
container stops after executing the shell-skript in the maven-container.


Is there a posibility to have a long-running process in a container with 
executing a shell-script in the entrypoint of a container ?


Thank you for your help.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/7f2d3e30-0409-4ddc-a8a5-159987246b16%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to