Jenkins build over ssh times out on first attempt - jenkins

I have successfully set up a build with Jenkins (version 2.375.1) that is triggered by a GitHub web-hook. Dockerized Jenkins is running on an Ubuntu VM locally.
If I push from my local machine to GitHub, then this will initiate a build using build step: "Execute shell script on remote host using ssh" on the target AWS and run some steps to install the application. However, if I leave it too long the job times out. If I make a change and push again, or if I just hit build now, then the build is successful.
It seems like the connection from Jenkins to AWS is going to sleep and it requires the first attempt to "wake it up". I can't find any reference to this behaviour anywhere.
At the end of the console output....
[SSH] executing...
[SSH] Exception:Session.connect: java.net.SocketTimeoutException: Read timed out
com.jcraft.jsch.JSchException: Session.connect: java.net.SocketTimeoutException: Read timed out
at com.jcraft.jsch.Session.connect(Session.java:565)
at org.jvnet.hudson.plugins.CredentialsSSHSite.createSession(CredentialsSSHSite.java:132)
at org.jvnet.hudson.plugins.CredentialsSSHSite.executeCommand(CredentialsSSHSite.java:208)
at org.jvnet.hudson.plugins.SSHBuilder.perform(SSHBuilder.java:104)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:818)
at hudson.model.Build$BuildExecution.build(Build.java:199)
at hudson.model.Build$BuildExecution.doRun(Build.java:164)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:526)
at hudson.model.Run.execute(Run.java:1900)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
at hudson.model.ResourceController.execute(ResourceController.java:107)
at hudson.model.Executor.run(Executor.java:449)
Build step 'Execute shell script on remote host using ssh' marked build as failure
Finished: FAILURE

Related

H: Disconnecting configuration [api_server] after Build step 'Send build artifacts over SSH' changed build result to UNSTABLEFinishe UNSTABLE

Getting this error while running Docker build command on remote server via publish over ssh
[0mSSH: Disconnecting configuration [api_server] ...ERROR: Exception when publishing, exception message [Exec timed out or was interrupted after 120,001 ms]Build step 'Send build artifacts over SSH' changed build result to UNSTABLEFinished: UNSTABLE
Need to run docker build command on remote server

Unable to run command to remote machine via Jenkins

While trying to execute some shell command to a remote server from Jenkins, I am getting "Host key verification failed." error.
I have installed Jenkins in a docker on my MAC. Now from the Jenkins browser, I want to run some shell command to a remote server (which is accessible).
To do that I already added the server (10.206.y.z) in the configure page of jenkins (by providing hostname i.e. 10.206.y.z, username & the key generated in 10.206.y.z server in the SSH Servers section) & tested the connection. The connection test passed & then I saved the configuration.
For executing shell command on 10.206.y.z, I created a FreeStyle project & in the Execute Shell section I am passing ssh root1#10.206.y.z 'hostname'.
If I run the project by clicking 'Build Now', I am getting the below error & the build fails.
Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/TestProject
[TestProject] $ /bin/sh -xe /tmp/jenkins4234161871485451783.sh
+ ssh root1#10.206.y.z hostname
Host key verification failed.
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Any help please?
I think that the problem is the key. You are using the key generated in the destination machine (10.206.y.z)
You should use the key generated on the jenkins server and pass it to the destination server. For that you could use ssh-copy-id

Jenkins not able to connect sonarqube server

I'm running Ubuntu on Oracle VM from my Windows 10 machine.
On Ubuntu, I'm running Jenkins in a docker container.
In this I've created a job which in which a I've added a SonarScanner build step.
In sonar configurations, I've mentioned a remote URL of my sonar server. Same URL can be opened in web browser without any problem.
I've also mentioned sonar project properties in the build step.
But when I execute the build, I get error, that jenkins is not able to connect sonar server.
But it's fishy since, I'm able to open same URL from my browser.
The jenkins setup & sonar configurations also seems to correct as same I've used in my native window's jenkins setup & it worked.
So I think it is something to do with VM, but not sure exactly what.
Any suggestions.
Also, on Ubuntu I'm working as a default user with admin access. (Not as root user)
Thank you
Error Trace:
10:34:27.358 ERROR: Error during SonarQube Scanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:85)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:74)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:70)
at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:167)
at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:113)
at org.sonarsource.scanner.cli.Main.execute(Main.java:73)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:42)
at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(JarDownloader.java:58)
at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:53)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:76)
... 7 more
Caused by: java.net.UnknownHostException: sonarqube.intranet.myhost.com: Name or service not known
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
at java.net.InetAddress.getAllByName0(InetAddress.java:1276)
at java.net.InetAddress.getAllByName(InetAddress.java:1192)
at java.net.InetAddress.getAllByName(InetAddress.java:1126)
at org.sonarsource.scanner.api.internal.shaded.okhttp.Dns$1.lookup(Dns.java:39)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:171)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RouteSelector.nextProxy(RouteSelector.java:137)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RouteSelector.next(RouteSelector.java:82)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:171)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:121)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.newStream(StreamAllocation.java:100)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.execute(RealCall.java:69)
at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:113)
at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:98)
at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:39)
... 10 more
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succedeed?
ERROR: SonarQube scanner exited with non-zero code: 1
Finished: FAILURE

Jenkins job status failing despite running correctly

I have a jenkins jobs that executes with 'Publish over SSH'. The job connects to the remote server, transfers files and runs and ansible playbook.
The playbook runs as intended, confirmed by the logs. However at the end of the job an error is returned, failing the job. It's causing problems as it's preventing the pipeline from working correctly.
SSH: EXEC: completed after 402,593 ms
SSH: Disconnecting configuration [server] ...
ERROR: Exception when publishing, exception message [Exec exit status not zero. Status [2]]
Build step 'Send files or execute commands over SSH' changed build result to UNSTABLE
[Run Playbook] $ /bin/sh -xe /tmp/jenkins1528195779014969962.sh
+ echo Finished
Finished
Finished: UNSTABLE
Is there a setting missing to allow this to pass?
never used the 'Publish over SSH' you are referingto, but I can recommend Jenkins Ansible Plugin. I am running several playbooks in pipeline stages here successfully from labeled build slaves (have one dedicated slave that has Ansible installed) targeting Linux hosts on cloud infrastructure via SSH.
Especially in combination with the ANSI color plugin the output very readable.
If you cannot try that plugin, check whats the return code of the playbook run shell call.

Jenkins CI build timeout for long processes

We're using Jenkins CI (version 1.454) as execution engine for automated tests (triggered via Ant). One of my tests runs for at least 1-2 days. I couldn't exactly find out, since Jenkins always terminates my test before it finishes. Last time after ~20,5h.
We got the "Build timeout" plugin installed, but the test project in question doesn't have a timeout configured, so it shouldn't interrupt. The tests are running on a slave node. The global Jenkins configuration does not contain any timeout settings.
I've seen two other people having a similar problem, but no answers so far
Stacktrace:
INFO: Test-Linux-lts-mc #31 aborted
java.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at hudson.remoting.Request.call(Request.java:127)
at hudson.remoting.Channel.call(Channel.java:681)
at hudson.remoting.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:158)
at $Proxy37.join(Unknown Source)
at hudson.Launcher$RemoteLauncher$ProcImpl.join(Launcher.java:859)
at hudson.Launcher$ProcStarter.join(Launcher.java:345)
at hudson.tasks.Ant.perform(Ant.java:217)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:703)
at hudson.model.Build$RunnerImpl.build(Build.java:178)
at hudson.model.Build$RunnerImpl.doRun(Build.java:139)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:473)
at hudson.model.Run.run(Run.java:1408)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:238)
The console log doesn't show any indication to an error or timeout. It just says Build aborted and cleans up the nodes workspace.
Jenkins itself does not have a timeout. I have 24 hour performance tests and Jenkins does not abort them.
The java.lang.InterruptedException makes me think there is a signal from your build process which escapes and hits Jenkins. Are you running ant target using the Invoke Ant build step? If you are, you could try to execute a shell build step and in the shell run ant yourtarget.

Resources