How to load a file from current workspace into your Jenkinsfile - jenkins

I am trying to load a groovy file into my Jenkinsfile by using -
stage('Load')
code = load 'versioning.groovy'
I have this file in the current workspace as well but I keep getting error saying -
hudson.remoting.ProxyException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during canonicalization: java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Am I doing something wrong ?

Related

NoClassDefFoundError - Problems running project inside Jenkins build

The project build by "jenkins" is ok, but when "WildFly" is started from the "jenkins" build, the error below occurs:
Caused by: java.lang.NoClassDefFoundError: org/hibernate/Query
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:72)
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66)
... 10 more
Is there any maven setting in Jenkins that might be out of whack with the local project?

Jenkins error Unable to produce a script file

I am getting the following error while trying to build an application.
It worked properly from long time, recently it stopped the build process and throws the error. The configuration of the build uses slave node, In google many suggested that the issue may related to the Java version issues in slave node and the selected version in jenkings configuration section.
FATAL: Unable to produce a script file
hudson.util.IOException2: Failed to create a temp file on
/scratch/jenkins/workspace/
at hudson.FilePath.createTextTempFile(FilePath.java:1223)
at hudson.tasks.CommandInterpreter.createScriptFile(CommandInterpreter.java:115)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:75)
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:804)
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:586)
at hudson.model.Run.execute(Run.java:1593)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:247)
Caused by: hudson.util.IOException2: remote file operation failed:
/scratch/jenkins/workspace/ERT_PC_CF7 at
hudson.remoting.Channel#1f9efe8:build- linux-1
at hudson.FilePath.act(FilePath.java:901)
at hudson.FilePath.act(FilePath.java:878)
at hudson.FilePath.createTextTempFile(FilePath.java:1200)
... 12 more
Caused by: hudson.util.IOException2: Failed to create a temporary directory in /tmp
at hudson.FilePath$14.invoke(FilePath.java:1212)
at hudson.FilePath$14.invoke(FilePath.java:1200)
at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2393)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:326)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:679)
Caused by: java.io.IOException: Read-only file system
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.checkAndCreate(File.java:1717)
at java.io.File.createTempFile0(File.java:1738)
at java.io.File.createTempFile(File.java:1815)
at hudson.FilePath$14.invoke(FilePath.java:1210)
This is not a permission issue. The issue has been resolved by rebooting the slave nodes as the whole file system in slave node went into read mode, even the root user gets exception with touch command on the directory /scratch/jenkins/workspace/ .

Grails 2.5.3 NPE on production deployment (assets-pipeline)

I got the following stacktrace when I try to access login page of my application:
21.03.2016 19:01:52,746: (HVK3) GrailsExceptionResolver: NullPointerException occurred when processing request: [GET] /wmp-hvk3-development/login/auth
Stacktrace follows:
org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: null
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53)
at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:62)
at grails.plugin.springsecurity.web.SecurityRequestHolderFilter.doFilter(SecurityRequestHolderFilter.java:59)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
Caused by: java.lang.NullPointerException
at java.util.Hashtable.hash(Hashtable.java:262)
at java.util.Hashtable.get(Hashtable.java:459)
at java.util.Properties.getProperty(Properties.java:951)
at asset.pipeline.grails.AssetProcessorService.getResolvedAssetPath(AssetProcessorService.groovy:57)
at asset.pipeline.grails.AssetProcessorService.asset(AssetProcessorService.groovy:72)
at asset.pipeline.grails.CachingLinkGenerator.asset(CachingLinkGenerator.groovy:32)
at asset.pipeline.grails.CachingLinkGenerator.resource(CachingLinkGenerator.groovy:24)
at gsp_wmpHvk3Development_loginauth_gsp$_run_closure2.doCall(gsp_wmpHvk3Development_loginauth_gsp.groovy:67)
Application works perfectly in test environment on local workstation but this stacktrace occurs when I deploy to production.
Im not sure what to make out of it, I guess there is a problem with the assets-pipeline assets path since AssetProcessorService.groovy:57 states:
I'm on RedHat linux running tomcat 7 with java 1.7 with assets pipeline 2.7.2 plugin as compile dependency and spring security core plugin 2.0.0 compile time dependency.
This was caused by missing configuration in BuildConfig. I added the following to the end of the file and it fixed this:
// This closure is passed the command line arguments used to start the war process.
grails.war.copyToWebApp = { args ->
fileset(dir: "web-app") {
include(name: "js/**")
include(name: "css/**")
include(name: "WEB-INF/**")
}
}

Trying to jslint files using jenkins .. java.io.FileNotFoundException: /var/lib/jenkins/jobs/test/workspace (Is a directory)

Error seen in jenkins job console output ..
[JSLint] Ready
[JSLint] calling jslint with args[-DxmlOutput=/var/lib/jenkins/jobs/test/workspace/, /var/lib/jenkins/jobs/test/workspace/src/main/resources/levels/level1.json, /var/lib/jenkins/jobs/test/workspace/src/main/resources/levels/level2.json, /var/lib/jenkins/jobs/test/workspace/src/main/resources/levels/level3.json]
[JSLint] JSLint path is jar:file:/var/lib/jenkins/plugins/jslint/WEB-INF/lib/classes.jar!/com/boxuk/jenkins/jslint/JSLintBuilder/jslint.js
ERROR: Build step failed with exception
org.mozilla.javascript.WrappedException: Wrapped java.io.FileNotFoundException: /var/lib/jenkins/jobs/test/workspace (Is a directory) (jslint.js#5732)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1773)
at org.mozilla.javascript.MemberBox.newInstance(MemberBox.java:202)
at org.mozilla.javascript.NativeJavaClass.constructSpecific(NativeJavaClass.java:281)
at org.mozilla.javascript.NativeJavaClass.construct(NativeJavaClass.java:200)
at org.mozilla.javascript.ScriptRuntime.newObject(ScriptRuntime.java:2327)
at org.mozilla.javascript.gen.c3._c149(jslint.js:5732)
at org.mozilla.javascript.gen.c3.call(jslint.js)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
at org.mozilla.javascript.gen.c3._c0(jslint.js:5591)
at org.mozilla.javascript.gen.c3.call(jslint.js)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
at org.mozilla.javascript.gen.c3.call(jslint.js)
at org.mozilla.javascript.gen.c3.exec(jslint.js)
at org.mozilla.javascript.Context.evaluateReader(Context.java:1135)
at com.boxuk.jenkins.jslint.LintRunner.call(LintRunner.java:126)
at com.boxuk.jenkins.jslint.LintRunner.call(LintRunner.java:28)
at hudson.remoting.LocalChannel.call(LocalChannel.java:45)
at com.boxuk.jenkins.jslint.JSLintBuilder.perform(JSLintBuilder.java:116)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
at hudson.model.Run.execute(Run.java:1744)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:374)
Caused by: java.io.FileNotFoundException: /var/lib/jenkins/jobs/test/workspace (Is a directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
at java.io.FileOutputStream.<init>(FileOutputStream.java:110)
at java.io.FileWriter.<init>(FileWriter.java:63)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.mozilla.javascript.MemberBox.newInstance(MemberBox.java:194)
... 26 more
Build step 'JSLint' marked build as failure
jenkins job configuration ..
Here is how file system looks on jenkins server ..
jenkins#work:~/jobs/test/workspace$ pwd
/var/lib/jenkins/jobs/test/workspace
jenkins#work:~$ ls src/main/resources/levels/
level1.json level2.json level3.json
Anyway, as a workaround, try providing a full path to your json files should work.
You can try this:
Files to Scan: /full_path/src/main/resources/levels/*.json
Updated answer (2015-05-29)
I tried below configurations and it works for me
Screenshot 1
Screenshot 2
Screenshot 3
Console Output log

Jenkins slave job fails after successful job

I have 2 jenkins servers because my 2 builds have some incompatible system requirements.
I setup a new node for one of the servers and migrated the jobs from the other server and set them up to run on the node.
The node runs the job just fine and even archives the artifacts (they are linked from the job) but the job throws and exception and gets marked as a failure.
** Below is the output from the jobs **
Completed build, now archiving <-- I print this out at the end of my last build step
FATAL: Remote call on ops-1-jenkins-android-10-186.fam.io failed
java.io.IOException: Remote call on ops-1-jenkins-android-10-186.fam.io failed
at hudson.remoting.Channel.call(Channel.java:748)
at hudson.Launcher$RemoteLauncher.kill(Launcher.java:940)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:556)
at hudson.model.Run.execute(Run.java:1745)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class hudson.slaves.SlaveComputer
at hudson.util.ProcessTree.getKillers(ProcessTree.java:151)
at hudson.util.ProcessTree$OSProcess.killByKiller(ProcessTree.java:212)
at hudson.util.ProcessTree$UnixProcess.kill(ProcessTree.java:557)
at hudson.util.ProcessTree$UnixProcess.killRecursively(ProcessTree.java:564)
at hudson.util.ProcessTree$Unix.killAll(ProcessTree.java:488)
at hudson.Launcher$RemoteLauncher$KillTask.call(Launcher.java:952)
at hudson.Launcher$RemoteLauncher$KillTask.call(Launcher.java:943)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:328)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at hudson.remoting.Engine$1$1.run(Engine.java:63)
at java.lang.Thread.run(Thread.java:701)
Thanks Lovato!
After I updated all the plugins and jenkins things worked just fine.
We got this error: FATAL: java.io.IOException: Remote call on pm_jenprodslave_1 failed. We found the slave server was unresponsive and had to reboot it. Once it came back the build works again.

Resources