running build on jenkins fails ssh-agent error - jenkins

When I run a build using a master/slave system and Jenkins, Jenkins running on a slave gives me the error:
Caused by: java.lang.UnsatisfiedLinkError:
/tmp/jffi5344372940870867938.tmp: /tmp/jffi5344372940870867938.tmp:
failed to map segment from shared object: Operation not permitted
FATAL: Could not find a suitable ssh-agent provider
On master it works perfectly.
Is there a configuration issue I am missing?

I solved my problem by adding the following to JVM Options (click Advanced... button when adding a slave):
-Djava.io.tmpdir=/home/jenkins/data

Related

Jenkins build over ssh times out on first attempt

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

Failed to setup GlobalToolConfiguration In Jenkins - Http Status 403-Forbidden

My Jenkins is running in an azure app service as a java web application. as soon the app service started jenkins started & running successfully.
Im accessing Jenkins UI using the url https://app-service-url/jenkins
I logged into jenkins with initial admin password The next step is to choose install suggested plugin & select plugins to install
upon clicking any of this options im getting "Error ocurred during installation".
However After few retries plugins are installed but for all further operation I do it is giving Http 403- Forbidden.
I tried to add Jdk in Global Tool Configuration before adding values it is throwing error and even I save it ends with 403-forbidden result.
I could not able to do anything in jenkins I failed to install new plugins,setup basic configuration,run commands in jenkins script console etc.
In all the cases periodically receiving Http 403-Forbidden.
In jenkins system log I found the messages.
Solutions Tried:
Tried to enable "Enable proxy compatibility" in GlobalSecurity - but 403-Forbidden
Added hudson.security.csrf.GlobalCrumbIssuerConfiguration.DISABLE_CSRF_PROTECTION = true in my app service Configuration(Similar to setting the Env Variable)
Created init.groovy script in JENKINS_HOME and added below commands
def instance = Jenkins.instance
instance.setCrumbIssuer(null)
Tried to install strict-crumb-issuer jenkins plugin but failed to install
Note: I tried latest jenkins version 2.375 as well as the downgraded version(2.361.2,2.332 etc).
looking for a solution to fix this no valid crumb Http 403- forbidden.

Why ist Jenkins job-dsl plugin failing with ERROR: java.io.IOException: Failed to persist config.xml

I have a Jenkins Job DSL job that worked well until about january (it is not used that often). Last week, the job failed with the error message ERROR: java.io.IOException: Failed to persist config.xml (no Stack trace, just that message). There were no changes to the job since the last successful execution in january.
[...]
13:06:22 Processing provided DSL script
13:06:22 New run name is '#15 (Branch_B20_2_x)'
13:06:22 ERROR: java.io.IOException: Failed to persist config.xml
13:06:22 [WS-CLEANUP] Deleting project workspace...
13:06:22 [WS-CLEANUP] Deferred wipeout is used...
13:06:22 [WS-CLEANUP] done
13:06:22 Finished: FAILURE
I thougt that between january and noew, maybe some plugin was updated and the DSL script is now wrong, so I changed my DSL script to the most easy one I could imagine (example from job-dsl plugin page):
job('example') {
steps {
shell('echo Hello World!')
}
}
But the job still fails with the exact same error.
I checked the jenkins logs but nothing to see.
I am running jenkins in a docker swarm container and each job is executed in an own build agent conatiner using docker-swarm-plugin (no changes to that either, worked in january).
The docker deamon logs also show no errors.
The filesystem for the workspace of jenkins also is not full and the user in the build agent container has write access to taht file system.
It even does not work, when I mount an empty tmpfs to the workspace.
Does anyone have an idea what goes wrong or at least a hint where to continue searching for that error?
Jenkins version: 2.281
job-dsl plugin version: 1.77
Docker version: 20.10.4
Problem was solved by updating jenkins to 2.289
Seems like there war some problem with the combination of the versions before. I will keep you updated if some of the next updates chnages anything.

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

Build step 'Execute shell' marked build as failure

I have a build step in my jenkins project. This is an Execute Shell step.
The following is the command is what I am running.
sudo gcloud --project=xxxx preview app deploy app.yaml ==version=1
During the deployment the above step breaks the build, with the following error.
sudo gcloud --project=cfc-melbourne-website preview app deploy app.yaml ==version=1
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
sudo: no tty present and no askpass program specified
Build step 'Execute shell' marked build as failure
No JDK named ‘null’ found
ERROR: Build step failed with exception
com.google.jenkins.plugins.credentials.oauth.GoogleRobotPrivateKeyCredentials$AccountIdNotSetException
at com.google.jenkins.plugins.credentials.oauth.GoogleRobotPrivateKeyCredentials.getUsername(GoogleRobotPrivateKeyCredentials.java:152)
at com.google.jenkins.plugins.credentials.oauth.RemotableGoogleCredentials.<init>(RemotableGoogleCredentials.java:54)
at com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials.forRemote(GoogleRobotCredentials.java:204)
at com.google.jenkins.plugins.storage.AbstractUpload.initiateUploadsAtWorkspace(AbstractUpload.java:342)
at com.google.jenkins.plugins.storage.AbstractUpload.perform(AbstractUpload.java:173)
at com.google.jenkins.plugins.storage.GoogleCloudStorageUploader.perform(GoogleCloudStorageUploader.java:109)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:785)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)
at hudson.model.Build$BuildExecution.post2(Build.java:185)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
at hudson.model.Run.execute(Run.java:1766)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Build step 'Google Cloud Storage Uploader' marked build as failure
Finished: FAILURE
How do I resolve this ?
The no tty present error indicates that you have the requiretty setting in your sudoers file. This will require a tty. To solve this you can add your user to that file and turn .
change your sudoers-file:
vi /etc/sudoers
and add (assuming it's your jenkins-user):
Defaults:jenkins !authenticate
Normally your jenkins user can use sudo-commands without authentication.

Resources