jenkinsci / docker

Docker official jenkins repo
https://hub.docker.com/r/jenkins/jenkins
MIT License
6.64k stars 4.51k forks source link

Docker Agent not available #665

Closed daixtrose closed 5 years ago

daixtrose commented 6 years ago

General Description

Following the Blue Ocean tutorial everything goes fine until the creation of an initial pipeline. During the connection to my public GitHub fork of the repository BlueOcean complains that there are no jenkinsfiles in the repo (but they should be there).

My suspicion: the internal Docker system is not set up such that it can call back to the Docker host, since there is no Agent entry in the GUI from which I could choose the agent.

Docker commands that I execute

sudo docker run --rm -u root -p 8080:8080 \
    -v jenkins-data:/var/jenkins_data \
    -v /var/run/docker.sock:/var/run/docker.sock jenkinsci/blueocean

(Note that I use a new directory /var/jenkins_data on the host to ensure no old crap makes trouble)

Actual result

No agent settings visible:

image

Expected outcome

A selection combo box for the Docker agent

image

Have you tried a non-dockerized Jenkins and get the expected outcome?

No.

Output of docker version

Docker running on Ubuntu 16.04.3 VMWare VM host on ESXi

Client:
 Version:   18.03.0-ce
 API version:   1.37
 Go version:    go1.9.4
 Git commit:    0520e24
 Built: Wed Mar 21 23:10:01 2018
 OS/Arch:   linux/amd64
 Experimental:  false
 Orchestrator:  swarm

Server:
 Engine:
  Version:  18.03.0-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.4
  Git commit:   0520e24
  Built:    Wed Mar 21 23:08:31 2018
  OS/Arch:  linux/amd64
  Experimental: false

Other relevant information

A lot of errors on the command line, here an excerpt:

Apr 10, 2018 2:14:40 PM com.squareup.okhttp.internal.Platform$JdkWithJettyBootPlatform getSelectedProtocol
INFO: ALPN callback dropped: SPDY and HTTP/2 are disabled. Is alpn-boot on the boot class path?
Apr 10, 2018 2:14:47 PM org.eclipse.jetty.server.handler.ContextHandler$Context log
WARNING: Error while serving http://0.0.0.0:8080/blue/rest/pipeline-metadata/agentMetadata
java.lang.reflect.InvocationTargetException
    at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:347)
    at org.kohsuke.stapler.ForwardingFunction.invoke(ForwardingFunction.java:63)
    at io.jenkins.blueocean.commons.stapler.TreeResponse$Processor.invoke(TreeResponse.java:43)
    at org.kohsuke.stapler.PreInvokeInterceptedFunction.invoke(PreInvokeInterceptedFunction.java:26)
    at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:184)
    at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:117)
    at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:129)
    at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
    at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:374)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
    at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:374)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:686)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
    at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:374)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649)
    at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650)
    at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
    at org.jenkinsci.plugins.ssegateway.Endpoint$SSEListenChannelFilter.doFilter(Endpoint.java:225)
    at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
    at io.jenkins.blueocean.ResourceCacheControl.doFilter(ResourceCacheControl.java:134)
    at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
    at io.jenkins.blueocean.auth.jwt.impl.JwtAuthenticationFilter.doFilter(JwtAuthenticationFilter.java:61)

        [...]

    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
    at org.eclipse.jetty.server.Server.handle(Server.java:564)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
    at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
    at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
    at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
    at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoSuchMethodError: org.jenkinsci.plugins.pipeline.modeldefinition.agent.DeclarativeAgentDescriptor.all()Lhudson/ExtensionList;
    at io.blueocean.rest.pipeline.editor.PipelineMetadataService.doAgentMetadata(PipelineMetadataService.java:70)
    at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
    at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:343)
    ... 90 more
daixtrose commented 6 years ago

Using the Dockerfile below the system works after installing blue ocean plugin. Do I have to explicitly install Docker in jenkins/blueocean i.e. derive from that Docker image?

FROM jenkins/jenkins:lts

MAINTAINER daixtrose

USER root

# Install the latest Docker CE binaries
RUN apt-get update && \
    apt-get -y install \
    apt-transport-https \
        ca-certificates \
        curl \
        gnupg2 \
        software-properties-common && \
    curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && \
        add-apt-repository \
            "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
            $(lsb_release -cs) \
            stable" && \
    apt-get update && \
    apt-get -y install docker-ce && \
    apt-get autoremove -y && \
    apt-get autoclean -y && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*
carlossg commented 6 years ago

you should ask in the jenkins-user mailing list, no idea what's in jenkinsci/blueocean but obviously you would need the docker binary

batmat commented 6 years ago

@daixtrose Thanks for making your request so detailed. But please follow the explanation, there is a template for issues here for a reason: image

In your case, this looks like a users mailing list issue. Even more because as Carlos said, this repo is not even about BlueOcean Docker image.

Thanks!

hggh commented 5 years ago

The problem with the Jenkins Docker container is, that the container does not contain the "docker" command. If you wish to use Pipelines with docker container you have create a new docker container from the Jenkins one. This is possible with a Dockerfile like the one from @daixtrose but I think the official docker image of jenkins should ship the docker client inside the container. So everyone could start tests inside docker with the offical jenkins image without building a extra image.