Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
2.1k views
by
retagged by

I'm trying to install the Jenkins plugins before I launch it on the server. In my code I have installed java, maven, git etc, then  downloads Jenkins.war which I can launch it in the server using "docker run -p 8080:8080 <image>"

Then I thought of installing plugins before I launch it, and a written script that downloads install the plugin.sh, file and copies plugin.txt file to .sh and make install.

Here is my code,

FROM ubuntu:14.04

# Install Java.

RUN \

  echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \

  apt-get update && \

  apt-get upgrade -y && \

  apt-get install -y  software-properties-common && \

  add-apt-repository ppa:webupd8team/java -y && \

  apt-get update && \

  apt-get install -y oracle-java8-installer && \

  rm -rf /var/lib/apt/lists/* && \

  rm -rf /var/cache/oracle-jdk8-installer

# Define commonly used JAVA_HOME variable

ENV JAVA_HOME /usr/lib/jvm/java-8-oracle

# get maven 3.2.2 and verify its checksum

RUN wget --no-verbose -O /tmp/apache-maven-3.2.2.tar.gz http://archive.apache.org/dist/maven/maven-3/3.2.2/binaries/apache-maven-3.2.2-bin.tar.gz; \

echo "87e5cc81bc4ab9b83986b3e77e6b3095 /tmp/apache-maven-3.2.2.tar.gz" | md5sum -c   

ARG BASE_URL=https://apache.osuosl.org/maven/ven-3/${MAVEN_VERSION}/binaries

# install maven

RUN tar xzf /tmp/apache-maven-3.2.2.tar.gz -C /opt/; \

  ln -s /opt/apache-maven-3.2.2 /opt/maven; \

  ln -s /opt/maven/bin/mvn /usr/local/bin; \

  rm -f /tmp/apache-maven-3.2.2.tar.gz

ENV MAVEN_HOME /opt/maven

# Install dependencies

RUN apt-get -y update  && \

apt-get -yqq --no-install-recommends install bash git bzip2 curl unzip && \

apt-get update

# copy jenkins war file to the container

#ADD http://mirrors.jenkins.io/war-stable/2.107.1/jenkins.war /opt/jenkins.war

COPY jenkins.war /opt/jenkins.war

ENV JENKINS_HOME /jenkins

# configure the container to run jenkins, mapping container port 8080 to that host port

RUN mkdir /jenkins/

COPY proxy.xml /jenkins/proxy.xml

COPY config_updated.xml opt/config_updated.xml

COPY settings.xml /usr/share/maven/conf/settings.xml

ENTRYPOINT ["java","-jar","/opt/jenkins.war"]

ENV JAVA_OPTS="-Djenkins.install.runSetupWizard=false"

#Install plugins

RUN cd /usr/local/bin && curl -L https://raw.githubusercontent.com/hgomez/devops-incubator/master/forge-tricks/batch-install-jenkins-plugins.sh -o batch-install-jenkins-plugins.sh

RUN chmod +x /usr/local/bin/batch-install-jenkins-plugins.sh 

COPY /plugins.txt /usr/share/jenkins/ref/plugins.txt

RUN /usr/local/bin/batch-install-jenkins-plugins.sh --plugins /usr/share/jenkins/ref/plugins.txt --excludedplugins /noplugins.txt --plugindir /var/lib/myjenkins/plugins

RUN echo 2.0 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state

THis is what im getting.(below image)

TO check I changed entry point to bash and checked, this is what I have in the container.

Everything I have in the container, but it's not working.

IN the line RUN /usr/local/bin/batch-install-jenkins-plugins.sh --plugins /usr/share/jenkins/ref/plugins.txt --excludedplugins /noplugins.txt --plugindir /var/lib/myjenkins/plugins

What path should I specify in --plugindir i.e what sholud be there in that plugins??

by Master (1.2k points)
What is the content of your batch-install-jenkins-plugins.sh?
by New User (10 points)
for test sake i have few plugins
    sonar
    ssh-agent
    thucydides
    timestamper
    maven-plugin
    pam-auth
    ssh-credentials
    ssh-slaves

1 Answer

0 like 0 dislike
by Master (1.2k points)

As far as I remember, the 'install-plugin.sh' file does not accept text file. So, you can try something like below.

RUN /usr/local/bin/batch-install-jenkins-plugins.sh --plugins < /usr/share/jenkins/ref/plugins.txt

feed out put of plugins.txt file to the .sh file

by New User (10 points)
Did this before itself, same error. i tried now also, same as first image in my question
by Master (1.2k points)
can you post the error message, instead of the image? the image is not much clear.
by New User (10 points)
Step 21/24 : COPY /plugins.txt /usr/share/jenkins/ref/plugins.txt
 ---> Using cache
 ---> 04430be725b7
Step 22/24 : RUN /usr/local/bin/batch-install-jenkins-plugins.sh --p /usr/share/jenkins/ref/plugins.txt
 ---> Running in 56cf131ce2e0
You must provide plugin directory
  usage: batch-install-jenkins-plugins.sh options

  Install or update Jenkins Plugins.

  OPTIONS:
     -p --plugins  file containing plugins list
     -x --xplugins   file containing excluded plugins list
     -d --plugindir  directory where to deploy plugins (.jpi)

  Examples:

     Run:
     batch-install-jenkins-plugins.sh --plugins okplugins --excludedplugins nokplugins --plugindir /var/lib/myjenkins/plugins
/usr/local/bin/batch-install-jenkins-plugins.sh: illegal option -- -
The command '/bin/sh -c /usr/local/bin/batch-install-jenkins-plugins.sh --p /usr/share/jenkins/ref/plugins.txt' returned a non-zero code: 1
by Master (1.2k points)
I meant, execute this code

RUN /usr/local/bin/batch-install-jenkins-plugins.sh --plugins /usr/share/jenkins/ref/plugins.txt --excludedplugins /noplugins.txt --plugindir /var/lib/myjenkins/plugins

and post the error.

because of the above error, it's clear that it's asking for a plugin directory.
by New User (10 points)
that is what im getting, may be --plugindir  /var/lib/myjenkins/plugins is not allowing to run, as i mentioned in question end what should be there in /var/lib/myjenkins/plugins????????
by New User (10 points)
Can i have more light on the command "batch-install-jenkins-plugins.sh --plugins okplugins --excludedplugins nokplugins --plugindir /var/lib/myjenkins/plugins" ?? for more knowledge for me
by Master (1.2k points)
Hi Hitesh,

We do not know what is the content in the 'batch-install-jenkins-plugins.sh' file. It looks like its customized file.

So, if you can ask a separate question with content of 'batch-install-jenkins-plugins.sh' file. The command you are executing and the error that you are getting, We can answer your question quickly.
...