Run "From .." docker image inside Dockerfile

360 Views Asked by At

I'm building a image that builds a Jenkins and I try to use a plugin over the Jenkins when it is running, so, I need get run Jenkins before my plugin execution.

I execute it like docker build -t dockerfile and the error which I am obtaining:

jenkins.JenkinsException: Error in request: [Errno 99]
Cannot assign requested address

I think the problem is when the plugin is executed it guess Jenkins is running and not.

FROM foxylion/jenkins
MAINTAINER Mishel Uchuari <[email protected]>

RUN /usr/local/bin/install-plugins.sh workflow-remote-loader workflow-aggregator build-pipeline-plugin

ENV JENKINS_USER replicate
ENV JENKINS_PASS replicate


USER root
RUN apt-get -y update && apt-get -y upgrade
RUN apt-get install -y apt-utils
RUN apt-get install -y python-pip
RUN apt install -y linuxbrew-wrapper
RUN useradd someuser -m -s /bin/bash
USER someuser
RUN chmod -R 777 /home/someuser
RUN brew install libyaml
USER root
RUN apt-get install build-essential
RUN apt-get -y update && apt-get -y upgrade

RUN pip install jenkins-job-builder==2.0.0.0b2
RUN pip install PyYAML python-jenkins

RUN mkdir /etc/jenkins_jobs/
COPY jenkins_jobs.ini /etc/jenkins_jobs/
COPY scm_pipeline.yaml /etc/jenkins_jobs/
RUN jenkins-jobs --conf /etc/jenkins_jobs/jenkins_jobs.ini update /etc/jenkins_jobs/scm_pipeline.yaml
1

There are 1 best solutions below

1
On

I had the same issue myself when using it under Docker:

File "/src/.tox/py27/local/lib/python2.7/site-packages/jenkins_jobs/builder.py", line 124, in get_plugins_info raise e JenkinsException: Error in request: [Errno 99] Cannot assign requested address

That was caused when it tries to retrieve the list of plugins, I went overriding plugins_info to short circuit the code path:

jjb = JenkinsJobs(args=['test', config_dir, '-o', output_dir])
jjb.builder['plugins_info'] = []  # prevents 99 cannot assign requested address
jjb.execute()

I had the issue with python 2.7.9 on Debian Jessie. If I remember correctly that is no more an issue with a later python version eg 2.7.13 from Debian Stretch.

(the patch on which I encountered the issue): https://gerrit.wikimedia.org/r/#/c/380929/8/tests/test_integration.py

RUN brew install libyaml

brew is a package manager for Mac OS X. Also PyYAML gracefully skip compilation when the lib is not availble. So you probably do not need that one. And I guess it would work without installing build-essential.

RUN pip install jenkins-job-builder==2.0.0.0b2 RUN pip install PyYAML python-jenkins

I am surprised you have install PyYAML and python-jenkins explicitly. Supposedly installing jenkins-job-builder should install all the dependencies (eg PyYAML and python-jenkins).