Jenkins Kuberenet Plugin

33 views
Skip to first unread message

david...@mycit.ie

unread,
Oct 6, 2020, 5:05:04 PM10/6/20
to Jenkins Users
Hi All,

Could do with some help with this one, I'm currently trying to use Kubernetes to build containers for jobs that will run within Jenkins. I'm currently having the issue where my Docker File  has Ansible installed but, for some reason,it's not able to run if the Container is built with Jenkins 

FROM ubuntu:18.04

RUN apt update -y && \
    apt install python3.3 python3-dev gcc libpng-dev g++ build-essential libssl-dev libffi-dev curl wget unzip nano -y

RUN apt install python3-pip libpython2.7-stdlib install python-pip -y && \
    pip3 install wheel && \
    pip3 install --upgrade setuptools

RUN apt update && \
    apt install software-properties-common -y && \
    apt-add-repository --yes --update ppa:ansible/ansible && \
    apt install ansible -y 

RUN apt update && \
    apt install -y software-properties-common && \
    rm -rf /var/lib/apt/lists/*

RUN apt update && \
    apt install git openssh-server -y && \
    sed -i 's|session required     pam_loginuid.so|session    optional     pam_loginuid.so|g' /etc/pam.d/sshd && \
    mkdir -p /var/run/sshd

RUN apt install openjdk-8-jdk maven -y && \
    adduser --quiet <user> && \
    echo "<user>:<pass>" | chpasswd && \
    mkdir /home/jenkins/.m2

RUN pip3 install --upgrade pyvmomi && \
    pip install --upgrade pyvmomi
    
RUN service ssh start
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]

Building remotely on ansible-wwtrw (ansible) in workspace /home/jenkins/agent/workspace/test[Checks API] No suitable checks publisher found. [test] $ /bin/sh -xe /tmp/jenkins813336478250655019.sh + whoami root + ansible --version /tmp/jenkins813336478250655019.sh: 3: /tmp/jenkins813336478250655019.sh: ansible: not found Build step 'Execute shell' marked build as failure  

Arnaud bourree

unread,
Oct 7, 2020, 7:09:38 AM10/7/20
to jenkins...@googlegroups.com
Hi,

Could I suggest you to install at least Python 3.6 and not 3.3?

Arnaud

--
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/1bf82f20-6e80-4863-84b0-df86db9e4419n%40googlegroups.com.

nigel.a...@braincorp.com

unread,
Oct 7, 2020, 2:41:15 PM10/7/20
to Jenkins Users
David,

Looks like your issue isn't with the dockerfile, but with ansible. The failure is listed as `ansible: not found`. Make sure your executor has ansible and its in the path. Note the user and directory jenkins is running the command in.

-Nigel

David Foley

unread,
Oct 7, 2020, 3:20:34 PM10/7/20
to jenkins...@googlegroups.com
When jenkins deploys the pod jnlp container along with my ansible container is created within that Pod,
My docker file is using Ubuntu should I be using the jenkins/jnlp image instead.

If I keep the pod after the jobs fails and execute shell a d run which ansible is shows the path 

Nigel Armstrong

unread,
Oct 7, 2020, 3:42:58 PM10/7/20
to jenkins...@googlegroups.com
David, 

It sounds like you might not be running the step inside the right container. By default steps are runin the jnlp container. You need to specify `container('container-name') {` for which container to run in. See the documentation: https://plugins.jenkins.io/kubernetes/

-Nigel

You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/FwKy_J2Afgo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAJUZ6v4UKN07WDBk19fsCHfGa26Rn90uMWNRwQ8axXTW9ycrvA%40mail.gmail.com.

David Foley

unread,
Oct 7, 2020, 4:24:57 PM10/7/20
to jenkins...@googlegroups.com
Hi Nigel

I'm using FreeStyle Project. 
I have selected restricted to run on Node: Ansible

David Foley

unread,
Oct 7, 2020, 5:05:28 PM10/7/20
to jenkins...@googlegroups.com
Am I correct that pipelines are only supported and not Freestyle? 
I created a Test Pipeline, and am able to see the ansible version when I ran "sh 'ansible --version'" 
so it appears the freestyle is using the JNLP container. 
Reply all
Reply to author
Forward
0 new messages