anchore / anchore-engine

A service that analyzes docker images and scans for vulnerabilities
Apache License 2.0
1.58k stars 272 forks source link

Jenkins integration failing Connect to 127.0.0.1:8228 [/127.0.0.1] failed: Connection refused (Connection refused) #572

Open mishoops opened 4 years ago

mishoops commented 4 years ago

Is this a request for help?: Yes

Version of Anchore Engine and Anchore CLI if applicable: anchore-cli, version 0.8.0` anchore/anchore-engine:v0.8.0

What happened:

I'm trying to integrate anchore with jenkins, i installed plugin and followed https://www.jenkins.io/blog/2018/06/20/anchore-image-scanning/ instruction. The difference is that i have both docker registar and anchore running on slave's localhost thus in jenkins i set url to 127.0.0.1:8228/v1

The pipeline for job below pipeline { agent { node { label 'jslave02' } } stages { stage('build') { steps { sh''' echo 'FROM debian:latest' > Dockerfile echo 'CMD ["/bin/echo", "HELLO WORLD...."]' >> Dockerfile ''' script { docker.withRegistry('http://localhost:5001/') { def image = docker.build('exampleuser/examplerepo:latest') image.push() } } } } stage('analyze') { steps { sh 'echo "127.0.0.1:5001/exampleuser/examplerepo:latest `pwd`/Dockerfile" > anchore_images' anchore name: 'anchore_images' } } stage('teardown') { steps { sh''' for i in `cat anchore_images | awk '{print $1}'`;do docker rmi $i; done ''' } } } }

Yet i'm getting the following error

`2020-08-13T14:44:21.730 DEBUG AnchoreWorker Initializing build worker 2020-08-13T14:44:21.760 INFO AnchoreWorker Jenkins version: 2.252 2020-08-13T14:44:21.760 INFO AnchoreWorker Anchore Container Image Scanner Plugin version: 1.0.22 2020-08-13T14:44:21.760 INFO AnchoreWorker [global] debug: true 2020-08-13T14:44:21.760 INFO AnchoreWorker [build] engineurl: http://127.0.0.1:8228/v1 2020-08-13T14:44:21.760 INFO AnchoreWorker [build] engineuser: admin 2020-08-13T14:44:21.760 INFO AnchoreWorker [build] enginepass: **** 2020-08-13T14:44:21.760 INFO AnchoreWorker [build] engineverify: false 2020-08-13T14:44:21.760 INFO AnchoreWorker [build] name: anchore_images 2020-08-13T14:44:21.760 INFO AnchoreWorker [build] engineRetries: 300 2020-08-13T14:44:21.760 INFO AnchoreWorker [build] policyBundleId: 2020-08-13T14:44:21.760 INFO AnchoreWorker [build] bailOnFail: true 2020-08-13T14:44:21.761 INFO AnchoreWorker [build] bailOnPluginFail: true 2020-08-13T14:44:21.790 DEBUG AnchoreWorker Initializing Jenkins workspace 2020-08-13T14:44:21.821 DEBUG AnchoreWorker Creating workspace directory AnchoreReport.master_10 2020-08-13T14:44:21.851 DEBUG AnchoreWorker Initializing Anchore workspace (enginemode) 2020-08-13T14:44:21.912 DEBUG AnchoreWorker Dockerfile contents: FROM debian:latest CMD ["/bin/echo", "HELLO WORLD...."]

2020-08-13T14:44:21.912 DEBUG AnchoreWorker Image tag/digest: 127.0.0.1:5001/exampleuser/examplerepo:latest 2020-08-13T14:44:21.912 DEBUG AnchoreWorker Base64 encoded Dockerfile contents: RlJPTSBkZWJpYW46bGF0ZXN0CkNNRCBbIi9iaW4vZWNobyIsICJIRUxMTyBXT1JMRC4uLi4iXQo= 2020-08-13T14:44:21.912 DEBUG AnchoreWorker Build worker initialized 2020-08-13T14:44:21.912 INFO AnchoreWorker Submitting 127.0.0.1:5001/exampleuser/examplerepo:latest for analysis 2020-08-13T14:44:21.916 DEBUG AnchoreWorker anchore-engine add image URL: http://127.0.0.1:8228/v1/images 2020-08-13T14:44:21.916 DEBUG AnchoreWorker anchore-engine add image payload: {"tag":"127.0.0.1:5001/exampleuser/examplerepo:latest","dockerfile":"RlJPTSBkZWJpYW46bGF0ZXN0CkNNRCBbIi9iaW4vZWNobyIsICJIRUxMTyBXT1JMRC4uLi4iXQo="} 2020-08-13T14:44:21.917 ERROR AnchoreWorker Failed to add image(s) to anchore-engine due to an unexpected error org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:8228 [/127.0.0.1] failed: Connection refused (Connection refused) at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359) at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) at com.anchore.jenkins.plugins.anchore.BuildWorker.runAnalyzerEngine(BuildWorker.java:259) at com.anchore.jenkins.plugins.anchore.BuildWorker.runAnalyzer(BuildWorker.java:169) at com.anchore.jenkins.plugins.anchore.AnchoreBuilder.perform(AnchoreBuilder.java:242) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67) at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) 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.net.ConnectException: Connection refused (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75) ` What did you expect to happen:

Any relevant log output from /var/log/anchore:

How to reproduce the issue:

Anything else we need to know:

zhill commented 4 years ago

Hi @mishoops apologies for the delayed response. Looks like the slave isn't able to connect to the anchore engine you're running there. Are you still blocked on this?