Openshift Jenkins build fails to remove temp shell script on builder - jenkins

I had a working Django setup on OpenShift with Jenkins building so this has worked before. Now, for couple of weeks I have had problems with Jenkins. Here is one symptom:
FATAL: Unable to delete script file /tmp/hudson2562951972265911713.sh
hudson.util.IOException2: remote file operation failed: /tmp/hudson2562951972265911713.sh at hudson.remoting.Channel#1826d31:stablesbldr
at hudson.FilePath.act(FilePath.java:900)
at hudson.FilePath.act(FilePath.java:877)
at hudson.FilePath.delete(FilePath.java:1262)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:101)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:60)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:802)
at hudson.model.Build$BuildExecution.build(Build.java:199)
at hudson.model.Build$BuildExecution.doRun(Build.java:160)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:584)
at hudson.model.Run.execute(Run.java:1575)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:237)
Caused by: hudson.remoting.ChannelClosedException: channel is already closed
at hudson.remoting.Channel.send(Channel.java:494)
at hudson.remoting.Request.call(Request.java:129)
at hudson.remoting.Channel.call(Channel.java:672)
at hudson.FilePath.act(FilePath.java:893)
... 13 more
Caused by: java.io.IOException: Unexpected termination of the channel
at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:50)
.......
So Jenkins cannot remove the remote script on the builder machine. I even re-installed the jenkins gear and re-added the Jenkins cartridge to my application.

Apparently it had something to do with the connection dropping to the slave.
The second comment on this answer: https://stackoverflow.com/a/9998520/216846 did the trick for me.
When I contsantly refreshed the node status it showed me that the response time rose as high as 400ms when Django was post processing static files. Maybe that dropped the slave to offline mode.

Related

Jenkins System configuration error when saving

An instance of Jenkins started not saving changes made under 'Manage Jenkins > System Configuration'.
In an attempt to solve it, I have recently upgraded to Jenkins 2.346.3 (including all the plugins).
Unfortunately, this behavior still persists and the System Log only shows:
Error while serving http://<jenkins_url>/configSubmit
java.lang.ClassCastException: java.lang.Integer cannot be cast to hudson.model.Describable
at hudson.util.DescribableList.get(DescribableList.java:128)
at hudson.util.DescribableList.rebuild(DescribableList.java:170)
at jenkins.model.GlobalNodePropertiesConfiguration.configure(GlobalNodePropertiesConfiguration.java:24)
at jenkins.model.Jenkins.configureDescriptor(Jenkins.java:4017)
at jenkins.model.Jenkins.doConfigSubmit(Jenkins.java:3981)
at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:397)
Caused: java.lang.reflect.InvocationTargetException
at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:401)
at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:409)
at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:207)
<snippet>
Any idea on the possible cause?
UPDATE
After 2 attempts on restarting Jenkins without the config.xml, I succeeded in having Jenkins 'Manage Jenkins > System Configuration' behaving as expected.
After the first attempt, I reverted to the old configuration file as all the security related configurations were missing and I ended up raising the ticket https://issues.jenkins.io/browse/JENKINS-69548
On the 2nd attempt, I did what I described in the ticket comment https://issues.jenkins.io/browse/JENKINS-69548?focusedCommentId=430091&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-430091 (i.e. re-introducing the security-related configurations)
You probably have a corrupted config.xml from your old installation. Try deleting the config.xml(Back it up) located at $JENKINS_HOME(if you have not changed the default JENKINS_HOME in most cases it will be at USER_HOME/.jenkins(~/.jenkins)) and restarting Jenkins. If it's successful you can start reconfiguring or moving the configs from there.

Issue with C# sonarqube plugin

I have a SonarQube 5.6 installed since a year now, It's integrated with TFS. Installed with few additional plugins, C#, dependency-check, fxcop, java, Checkmarx, scm-cvs, scm-git, scm-svn and scm-tfvc.
everything was working fine. Today it's started failing build with error
2017-06-26T17:54:22.7387533Z Downloading SonarQube.MSBuild.Runner.Implementation.zip from http://xxxxxxx:9000/static/csharp/SonarQube.MSBuild.Runner.Implementation.zip to E:\agnt\_work\41\.sonarqube\bin\SonarQube.MSBuild.Runner.Implementation.zip
2017-06-26T17:54:22.7397520Z ##[error]Could not find a file on the SonarQube server. Url: http://xxxxxxxxxx:9000/static/csharp/SonarQube.MSBuild.Runner.Implementation.zip
2017-06-26T17:54:22.7407523Z ##[error]Failed to update the SonarQube Scanner for MSBuild binaries. Check the server url, verify that the C# plugin is correctly installed on the SonarQube server and that the SonarQube server has been restarted.
2017-06-26T17:54:22.7417526Z ##[error]Pre-processing failed. Exit code: 1
2017-06-26T17:54:22.8678238Z ##[error]System.Exception: Unexpected exit code received from batch file: 1
2017-06-26T17:54:22.8698250Z ##[error] at Microsoft.TeamFoundation.DistributedTask.Task.Internal.PowerShell.InvokeBatchScriptCmdlet.ProcessRecord()
2017-06-26T17:54:22.8708248Z ##[error] at System.Management.Automation.CommandProcessor.ProcessRecord()
From the error, I can it's something related to C# plugin. I checked that plugin under /extensions/plugins and it's there. I thought it can be something compatibility issue, I tried to upgrade it to latest one 6.0
After installing 6.0 tried again and got the same error.
I also tried with old version of same plugins. tried 5.3, 5.0. After manually copied jar file under /plugins. Tried to restart the sonar server and it didn't started successfully. I got the error as below,
2017.06.26 18:31:11 ERROR web[o.s.s.p.Platform] Fail to stop server - ignored
java.lang.IllegalStateException: Cannot stop. Current container state was: CONSTRUCTED at org.picocontainer.lifecycle.DefaultLifecycleState.stopping(DefaultLifecycleState.java:72) ~[picocontainer-2.15.jar:na] at org.picocontainer.DefaultPicoContainer.stop(DefaultPicoContainer.java:794) ~[picocontainer-2.15.jar:na]
2017.06.26 18:31:11 ERROR web[o.a.c.c.C.[.[.[/]] Exception sending context initialized event to listener instance of class org.sonar.server.platform.PlatformServletContextListener
java.lang.IllegalStateException: Fail to load plugin FxCop [fxcop] at org.sonar.server.plugins.ServerExtensionInstaller.installExtensions(ServerExtensionInstaller.java:74) ~[sonar-server-5.6.jar:na] at org.sonar.server.platform.platformlevel.PlatformLevel4.start(PlatformLevel4.java:691) ~[sonar-server-5.6.jar:na] at org.sonar.server.platform.Platform.start(Platform.java:216) ~[sonar-server-5.6.jar:na]
Caused by: java.lang.IllegalStateException: Unable to register extension org.sonar.api.config.PropertyDefinition at org.sonar.core.platform.ComponentContainer.addExtension(ComponentContainer.java:248) ~[sonar-core-5.6.jar:na] at org.sonar.server.plugins.ServerExtensionInstaller.installExtension(ServerExtensionInstaller.java:111) ~[sonar-server-5.6.jar:na] at org.sonar.server.plugins.ServerExtensionInstaller.installExtensions(ServerExtensionInstaller.java:66) ~[sonar-server-5.6.jar:na]
Caused by: org.picocontainer.PicoCompositionException: Duplicate Keys not allowed. Duplicate for 'org.sonar.api.config.PropertyDefinition-sonar.cs.fxcop.timeoutMinutes'at org.picocontainer.DefaultPicoContainer.addAdapterInternal(DefaultPicoContainer.java:438) ~[picocontainer-2.15.jar:na]
2017.06.26 18:31:11 ERROR web[o.a.c.c.StandardContext] One or more listeners failed to start. Full details will be found in the appropriate container log file 2017.06.26 18:31:11 ERROR web[o.a.c.c.StandardContext] Context [] startup failed due to previous errors
2017.06.26 18:31:11 WARN web[o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread
2017.06.26 18:31:11 WARN web[o.s.p.ProcessEntryPoint] Fail to start web
java.lang.IllegalStateException: Webapp did not start at org.sonar.server.app.EmbeddedTomcat.isUp(EmbeddedTomcat.java:84) ~[sonar-server-5.6.jar:na]at org.sonar.server.app.WebServer.isUp(WebServer.java:47) [sonar-server-5.6.jar:na]at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:105) ~[sonar-process-5.6.jar:na]at org.sonar.server.app.WebServer.main(WebServer.java:68) [sonar-server5.6.jar:na]
can someone please help to fix this issue?
You need to update the Scanner for MsBuild as well. The old versions are not compatible with SonarC# 6+.
I fixed this issue by removing FxCop plugin. Somehow that plugin stopped working. can be the version what i was using that was not compatible with C# plugin. I installed C# plugin version 5.0 (latest is 6.0)
as mentioned above, if i want to use C# latest version, i need to update sonar scanner for MSBuild.

Jenkins Plugins Update & Delete at same time

During my Jenkins maintenance time, I tried to "Update" some Plugins & "Uninstall" \"Unpin" some plugins at the same attempt, from "Jenkins -> Plugin Manager -> Updates \ Installed" Tabs and restarted my Jenkins Instance.
Jenkins failed to Load\parse my Config.xml saying below Errors in diff Attempts.
WARNING jenkins.diagnosis.HsErrPidList
Failed to list up hs_err_pid files
java.lang.UnsatisfiedLinkError: com.sun.jna.Native.open(Ljava/lang/String;)J
at com.sun.jna.Native.open(Native Method)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:236)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
Unable to read c:\jenkins\config.xml
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:246)
at hudson.model.Hudson.executeReactor(Hudson.java:753)
at hudson.model.Hudson.<init>(Hudson.java:667)
at hudson.model.Hudson.<init>(Hudson.java:607)
at hudson.WebAppMain$2.run(WebAppMain.java:215)
Caused by: hudson.util.IOException2: Unable to read c:\jenkins\config.xml
at hudson.XmlFile.unmarshal(XmlFile.java:152)
at hudson.model.Hudson$12.run(Hudson.java:2340)
at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:146)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:259)
at hudson.model.Hudson$4.runTask(Hudson.java:735)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:187)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:94)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
My Jenkins Instance is Back Online :-)
Solution that worked for me:
I deleted the "DISABLED" files in my "C:\Jenkins->Plugins" (sort by TYPE, look for DISABLED) and Restarted my Jenkins Instance.
It loaded like a Charm. However, Configuration page Didnt load Correctly due to Some Plugins didnt get Updated good. So Identified each Job and re-loaded the Required Plugins.
Finally, used "Jenkins -> Manage Jenkins -> Reload Configuration from Disk" to get back all my Jobs back Online functioning normal.

How to install Jacoco plugin in Jenkins

I'm running Jenkins 1.627, and I'm having problems to install JaCoCo plugin into it the usual way from management UI.
I was able to install number of other plugins without issues, but for JaCoCo plugin the installation fails with exception below, which indicates something wrong with the archive. Indeed, when I download from the link below using browser it downloads only ~7kb hpi file, even though the expected size is >5MB. I tried several older versions as well and same result.
Why is this? Was anyone successful in installing the plugin?
hudson.util.IOException2: Failed to download from http://updates.jenkins-ci.org/download/plugins/jacoco/1.0.19/jacoco.hpi (redirected to: http://jenkins.mirror.isppower.de/plugins/jacoco/1.0.19/jacoco.hpi)
at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:797)
at hudson.model.UpdateCenter$DownloadJob._run(UpdateCenter.java:1148)
at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:1309)
at hudson.model.UpdateCenter$DownloadJob.run(UpdateCenter.java:1126)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:110)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Inconsistent file length: expected 5196617 but only got 6808
at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:784)
... 7 more
Look at your exception message
Failed to download from
http://updates.jenkins-ci.org/download/plugins/jacoco/1.0.19/jacoco.hpi
(redirected to:
http://jenkins.mirror.isppower.de/plugins/jacoco/1.0.19/jacoco.hpi)
Caused by: java.io.IOException: Inconsistent file length: expected
5196617 but only got 6808
Looks like the file is(was) missing on the specific mirror. Try again, because the url http://jenkins.mirror.isppower.de/plugins/jacoco/1.0.19/jacoco.hpi returned 404 when I started to write my answer and returned 200 at the end
Solution 1
Step 1: Download http://updates.jenkins-ci.org/latest/jacoco.hpi and put it into your $JENKINS_HOME/plugins folder.
Step 2: Restart Jenkins. Done.
Solution 2
Step 1: Download http://updates.jenkins-ci.org/latest/jacoco.hpi
Step 2: Goto http://your_jenkins_url/pluginManager/advanced, from the Upload Plugin section, upload your jacoco.hpi and restart Jenkins. Done.

Unable to login jenkins, and can't disable login option either

I deployed jenkins.war to tomcat webapps. and changed security setting to "allow only login user..." without creating any users yet.
So now I am not able to login jenkins, and can not disable the login option either.
After googling around, seems it can be solved by editing config.xml file under jenkins root directory; however, there's not such xml existing in my jenkins root dir.
How do I recover from here?
Many Thanks!
Update:
Actually jenkins is running on the Windows 7 OS.
After specifically set the environment variable as JENKINS_HOME="F:\Tools\apache-tomcat-7.0.50\webapps\jenkins"
then navigate to http://localhost:8080/jenkins/
I see below Error -
*hudson.util.HudsonFailedToLoad: org.jvnet.hudson.reactor.ReactorException: java.io.IOException: Unable to read F:\Tools\apache-tomcat-7.0.50\webapps\jenkins\config.xml
at hudson.WebAppMain$3.run(WebAppMain.java:234)
Caused by: org.jvnet.hudson.reactor.ReactorException: java.io.IOException: Unable to read F:\Tools\apache-tomcat-7.0.50\webapps\jenkins\config.xml
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:269)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:44)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:910)
at jenkins.model.Jenkins.<init>(Jenkins.java:809)
at hudson.model.Hudson.<init>(Hudson.java:82)
at hudson.model.Hudson.<init>(Hudson.java:78)
at hudson.WebAppMain$3.run(WebAppMain.java:222)
Caused by: java.io.IOException: Unable to read F:\Tools\apache-tomcat-7.0.50\webapps\jenkins\config.xml
at hudson.XmlFile.unmarshal(XmlFile.java:167)
at jenkins.model.Jenkins$17.run(Jenkins.java:2562)
at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:282)
at jenkins.model.Jenkins$7.runTask(Jenkins.java:899)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:210)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.InstantiationError: hudson.security.AuthorizationStrategy
at sun.reflect.GeneratedSerializationConstructorAccessor5.newInstance(Unknown Source)*
(Answered in a question edit. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )
The OP wrote:
Issue was solved now :-)
I first changed the port of server.xml file for Tomcat
--> Connector port="new-port" protocol="HTTP/1.1"
I then removed the JENKINS_HOME environment variable from System
variables definition.
then removed deployed 'jenkins' directory under 'tomcat/webapps'
directory
and removed everything under 'tomcat/work/Catalina/localhost'
directory
then restart Tomcat server
Now I'm in Jenkins page without requiring a login - "Welcome to Jenkins! Please create new jobs to get started. "
Hopefully, this could help others who having the same issue.
In the Jenkins installation, I edited the config.xml to have <useSecurity> set to false. This enabled me to go back into Jenkins and redo my security settings.
You might need to restart the Jenkins service for this to take effect.

Resources