您好我在Docker中使用Jenkins构建了一个图像,它创建了一个Jenkins并使用插件远程创建管道。我的主要问题是插件需要服务器运行才能使用它。为了解决这个问题,我创建了一个启动Jenkins的.sh,睡了2分钟,然后执行管道。它工作正常但是当我使用Docker compose时它会启动.sh文件,但最后Jenkins停止了,我不知道为什么。
我的docker-compose文件:
复制-詹金斯:
image: dockerfile:latest ports:
- "8080:8080" entrypoint: /bin/sh -c "/bin/bash -c \"$${@}\"" command: |
/bin/bash -c "chmod 777 /etc/jenkins_jobs/script-to-execute.sh && ./etc/jenkins_jobs/script-to-execute.sh"
我的.sh文件:
#!/bin/bash
runJenkins(){
echo "Se pone en marcha jenkins"
./usr/local/bin/jenkins.sh &>/dev/null &
bg
}
runPipeline(){
sleep 60
echo "Se ejecuta el pipeline"
jenkins-jobs --conf /etc/jenkins_jobs/jenkins_jobs.ini update /etc/jenkins_jobs/scm_pipeline.yaml
}
clear
runJenkins
runPipeline
#chmod 777 /etc/jenkins_jobs/script.sh
#./etc/jenkins_jobs/script.sh
我的码头文件:
FROM foxylion/jenkins
MAINTAINER Mishel Uchuari <dmuchuari@hotmail.com>
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 pip install jenkins-job-builder==2.0.0.0b2
RUN pip install PyYAML python-jenkins
RUN mkdir /etc/jenkins_jobs/
ADD jenkins_jobs.ini /etc/jenkins_jobs/
ADD scm_pipeline.yaml /etc/jenkins_jobs/
ADD script-to-execute.sh /etc/jenkins_jobs/
你知道这是什么问题吗?谢谢你的关注。
此致
答案 0 :(得分:0)
根据docker日志记录它是好的。
replicate-jenkins_1 | TERM environment variable not set.
replicate-jenkins_1 | Se pone en marcha jenkins
replicate-jenkins_1 | Running from: /usr/share/jenkins/jenkins.war
replicate-jenkins_1 | webroot: EnvVars.masterEnvVars.get("JENKINS_HOME")
replicate-jenkins_1 | Dec 27, 2017 1:57:37 PM Main deleteWinstoneTempContents
replicate-jenkins_1 | WARNING: Failed to delete the temporary Winstone file /tmp/winstone/jenkins.war
replicate-jenkins_1 | Dec 27, 2017 1:57:37 PM org.eclipse.jetty.util.log.Log initialized
replicate-jenkins_1 | INFO: Logging initialized @722ms to org.eclipse.jetty.util.log.JavaUtilLog
replicate-jenkins_1 | Dec 27, 2017 1:57:37 PM winstone.Logger logInternal
replicate-jenkins_1 | INFO: Beginning extraction from war file
replicate-jenkins_1 | Dec 27, 2017 1:57:37 PM org.eclipse.jetty.server.handler.ContextHandler setContextPath
replicate-jenkins_1 | WARNING: Empty contextPath
replicate-jenkins_1 | Dec 27, 2017 1:57:37 PM org.eclipse.jetty.server.Server doStart
replicate-jenkins_1 | INFO: jetty-9.4.z-SNAPSHOT
replicate-jenkins_1 | Dec 27, 2017 1:57:38 PM org.eclipse.jetty.webapp.StandardDescriptorProcessor visitServlet
replicate-jenkins_1 | INFO: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
replicate-jenkins_1 | Dec 27, 2017 1:57:38 PM org.eclipse.jetty.server.session.DefaultSessionIdManager doStart
replicate-jenkins_1 | INFO: DefaultSessionIdManager workerName=node0
replicate-jenkins_1 | Dec 27, 2017 1:57:38 PM org.eclipse.jetty.server.session.DefaultSessionIdManager doStart
replicate-jenkins_1 | INFO: No SessionScavenger set, using defaults
replicate-jenkins_1 | Dec 27, 2017 1:57:38 PM org.eclipse.jetty.server.session.HouseKeeper startScavenging
replicate-jenkins_1 | INFO: Scavenging every 600000ms
replicate-jenkins_1 | Jenkins home directory: /var/jenkins_home found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
replicate-jenkins_1 | Dec 27, 2017 1:57:39 PM org.eclipse.jetty.server.handler.ContextHandler doStart
replicate-jenkins_1 | INFO: Started w.@1c742ed4{/,file:///var/jenkins_home/war/,AVAILABLE}{/var/jenkins_home/war}
replicate-jenkins_1 | Dec 27, 2017 1:57:39 PM org.eclipse.jetty.server.AbstractConnector doStart
replicate-jenkins_1 | INFO: Started ServerConnector@47caedad{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
replicate-jenkins_1 | Dec 27, 2017 1:57:39 PM org.eclipse.jetty.server.Server doStart
replicate-jenkins_1 | INFO: Started @2790ms
replicate-jenkins_1 | Dec 27, 2017 1:57:39 PM winstone.Logger logInternal
replicate-jenkins_1 | INFO: Winstone Servlet Engine v4.0 running: controlPort=disabled
replicate-jenkins_1 | Dec 27, 2017 1:57:40 PM jenkins.InitReactorRunner$1 onAttained
replicate-jenkins_1 | INFO: Started initialization
replicate-jenkins_1 | Dec 27, 2017 1:57:46 PM jenkins.InitReactorRunner$1 onAttained
replicate-jenkins_1 | INFO: Listed all plugins
replicate-jenkins_1 | Dec 27, 2017 1:57:56 PM jenkins.InitReactorRunner$1 onAttained
replicate-jenkins_1 | INFO: Prepared all plugins
replicate-jenkins_1 | Dec 27, 2017 1:57:56 PM jenkins.InitReactorRunner$1 onAttained
replicate-jenkins_1 | INFO: Started all plugins
replicate-jenkins_1 | Dec 27, 2017 1:57:59 PM jenkins.InitReactorRunner$1 onAttained
replicate-jenkins_1 | INFO: Augmented all extensions
replicate-jenkins_1 | Dec 27, 2017 1:58:00 PM jenkins.InitReactorRunner$1 onAttained
replicate-jenkins_1 | INFO: Loaded all jobs
replicate-jenkins_1 | Dec 27, 2017 1:58:00 PM jenkins.util.groovy.GroovyHookScript execute
replicate-jenkins_1 | INFO: Executing /var/jenkins_home/init.groovy.d/default-user.groovy
replicate-jenkins_1 | Dec 27, 2017 1:58:01 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
replicate-jenkins_1 | INFO: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@623c4753: display name [Root WebApplicationContext]; startup date [Wed Dec 27 13:58:01 UTC 2017]; root of context hierarchy
replicate-jenkins_1 | Dec 27, 2017 1:58:01 PM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
replicate-jenkins_1 | INFO: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@623c4753]: org.springframework.beans.factory.support.DefaultListableBeanFactory@2a432dc6
replicate-jenkins_1 | Dec 27, 2017 1:58:01 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
replicate-jenkins_1 | INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2a432dc6: defining beans [authenticationManager]; root of factory hierarchy
replicate-jenkins_1 | Dec 27, 2017 1:58:02 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
replicate-jenkins_1 | INFO: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@3d119c58: display name [Root WebApplicationContext]; startup date [Wed Dec 27 13:58:02 UTC 2017]; root of context hierarchy
replicate-jenkins_1 | Dec 27, 2017 1:58:02 PM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
replicate-jenkins_1 | INFO: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@3d119c58]: org.springframework.beans.factory.support.DefaultListableBeanFactory@428a754e
replicate-jenkins_1 | Dec 27, 2017 1:58:02 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
replicate-jenkins_1 | INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@428a754e: defining beans [authenticationManager]; root of factory hierarchy
replicate-jenkins_1 | Dec 27, 2017 1:58:02 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
replicate-jenkins_1 | INFO: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@fa9f5b3: display name [Root WebApplicationContext]; startup date [Wed Dec 27 13:58:02 UTC 2017]; root of context hierarchy
replicate-jenkins_1 | Dec 27, 2017 1:58:02 PM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
replicate-jenkins_1 | INFO: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@fa9f5b3]: org.springframework.beans.factory.support.DefaultListableBeanFactory@5a459bf4
replicate-jenkins_1 | Dec 27, 2017 1:58:02 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
replicate-jenkins_1 | INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@5a459bf4: defining beans [filter,legacy]; root of factory hierarchy
replicate-jenkins_1 | Dec 27, 2017 1:58:02 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
replicate-jenkins_1 | INFO: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@906ed37: display name [Root WebApplicationContext]; startup date [Wed Dec 27 13:58:02 UTC 2017]; root of context hierarchy
replicate-jenkins_1 | Dec 27, 2017 1:58:02 PM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
replicate-jenkins_1 | INFO: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@906ed37]: org.springframework.beans.factory.support.DefaultListableBeanFactory@79ae4271
replicate-jenkins_1 | Dec 27, 2017 1:58:02 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
replicate-jenkins_1 | INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@79ae4271: defining beans [filter,legacy]; root of factory hierarchy
replicate-jenkins_1 | Dec 27, 2017 1:58:02 PM hudson.model.AsyncPeriodicWork$1 run
replicate-jenkins_1 | INFO: Started Download metadata
replicate-jenkins_1 | Dec 27, 2017 1:58:02 PM hudson.model.AsyncPeriodicWork$1 run
replicate-jenkins_1 | INFO: Finished Download metadata. 53 ms
replicate-jenkins_1 | Dec 27, 2017 1:58:03 PM jenkins.util.groovy.GroovyHookScript execute
replicate-jenkins_1 | INFO: Executing /var/jenkins_home/init.groovy.d/executors.groovy
replicate-jenkins_1 | Dec 27, 2017 1:58:03 PM jenkins.util.groovy.GroovyHookScript execute
replicate-jenkins_1 | INFO: Executing /var/jenkins_home/init.groovy.d/tcp-slave-agent-port.groovy
replicate-jenkins_1 | Dec 27, 2017 1:58:03 PM jenkins.InitReactorRunner$1 onAttained
replicate-jenkins_1 | INFO: Completed initialization
replicate-jenkins_1 | Dec 27, 2017 1:58:07 PM hudson.WebAppMain$3 run
replicate-jenkins_1 | INFO: Jenkins is fully up and running
replicate-jenkins_1 | --> setting agent port for jnlp
replicate-jenkins_1 | --> setting agent port for jnlp... done
replicate-jenkins_1 | Se ejecuta el pipeline
replicate-jenkins_1 | INFO:jenkins_jobs.cli.subcommand.update:Updating jobs in ['/etc/jenkins_jobs/scm_pipeline.yaml'] ([])
replicate-jenkins_1 | INFO:jenkins_jobs.builder:Number of jobs generated: 1
replicate-jenkins_1 | INFO:jenkins_jobs.builder:Reconfiguring jenkins job Replicate-Pipeline
replicate-jenkins_1 | INFO:jenkins_jobs.cli.subcommand.update:Number of jobs updated: 1
replicate-jenkins_1 | INFO:jenkins_jobs.builder:Number of views generated: 0
replicate-jenkins_1 | INFO:jenkins_jobs.cli.subcommand.update:Number of views updated: 0
replicatejenkins_replicate-jenkins_1 exited with code 0
我无法看到Jenkins日志,因为当脚本结束时,容器已停止,我无法访问图像bash。