I am quite new in Jenkins and I am trying to run groovy script 'println "hello world" ' in jenkins. But i am getting below error.
[Test] $ groovy /var/jenkins_home/workspace /Test/hudson481621137087598172.groovy
FATAL: command execution failed
java.io.IOException: Cannot run program "groovy" (in directory "/var/jenkins_home/workspace/Test"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at hudson.Proc$LocalProc.<init>(Proc.java:249)
at hudson.Proc$LocalProc.<init>(Proc.java:218)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:935)
at hudson.Launcher$ProcStarter.start(Launcher.java:454)
at hudson.Launcher$ProcStarter.join(Launcher.java:465)
at hudson.plugins.groovy.Groovy.perform(Groovy.java:106)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
at hudson.model.Build$BuildExecution.build(Build.java:206)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
at hudson.model.Run.execute(Run.java:1815)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 15 more
Build step 'Execute Groovy script' marked build as failure
Finished: FAILURE
I have found some solution Run groovy scripts in Jenkins but I am not sure how can i use that in my case.
You need to add path to your groovy binaries in Jenkins -> Manage Jenkins -> Global Tool Configuration. Once you install groovy on your machine provide path to it's installation folder. For example on my machine it's like shown on the picture below:
Before checking your Global Tool Configuration in Jenkins, you might try installing/updating your Homebrew installation and run "brew install groovy" first. This will enable you to set the groovy home path (http://macappstore.org/groovy/). Otherwise Jenkins may not save you Tool Configuration properly.
You should set GROOVY_HOME:
export GROOVY_HOME=/usr/local/opt/groovy/libexec
Related
I'm trying to deploy a .NET web app as an app service in Azure using Jenkins and Azure app service plugin. Everything is working fine if I use a free style job and 'publish an azure app' as a post-build action, but I need to perform more complex tasks so I need to use pipeline.
The pipeline is:
stage('checkout') {
git branch: 'develop', url: 'https://github.com/test.git', credentialsId: 'cred'
}
stage('build and publish') {
bat "dotnet publish test/test.sln -c Release "
}
stage('deploy') {
azureWebAppPublish ([
appName: "appName",
azureCredentialsId: params.azure_cred_id,
publishType: "file",
resourceGroup: "resName",
sourceDirectory: "test/test/bin/Release/netcoreapp3.1/publish/"
])
Also tried adding
environment {
git: 'C:\\Program Files\\Git\\cmd\\git.exe'
}
The 'checkout' and 'build and publish' stages work fine, but on 'deploy' stage I get this error:
Starting Azure Web App Deployment
java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
Caused: java.io.IOException: Cannot run program "git" (in directory "c:\jenkins\workspace\test\.azure-deploy"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:252)
at hudson.Proc$LocalProc.<init>(Proc.java:221)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:996)
at hudson.Launcher$ProcStarter.start(Launcher.java:508)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2443)
Caused: hudson.plugins.git.GitException: Error performing git command: git init c:\jenkins\workspace\test\.azure-deploy
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2457)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2380)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2376)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1923)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:995)
The main jenkins is running on linux, but this job is executed on windows node. The configuration is:
Jenkins node configuration
C:\Program Files\Git\cmd is also added in the Environment variables on the VM
I guess I'm missing some additional configuration.
I need to run a groovy Post-Build script to do some clean up so I have arranged the following script:
def sout = new StringBuilder(), serr = new StringBuilder()
def proc = '/usr/bin/docker stop mysql'.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(1000)
Although the command '/usr/bin/docker stop mysql' works if I log on the machine, when the groovy script is executed, the following error is raised:
java.io.IOException: Cannot run program "/usr/bin/docker": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at java.lang.Runtime.exec(Runtime.java:450)
at java.lang.Runtime.exec(Runtime.java:347)
at org.codehaus.groovy.runtime.ProcessGroovyMethods.execute(ProcessGroovyMethods.java:533)
at org.codehaus.groovy.runtime.dgm$894.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:157)
at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:104)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:159)
at org.kohsuke.groovy.sandbox.impl.Checker$checkedCall$0.callStatic(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
at Script1.run(Script1.groovy:2)
Do you know why the groovy engine fails to find the 'docker' command?
Thanks!
The Groovy Postbuild plugin actually runs on the master, not on the build node. The documentation states:
This plugin executes a groovy script in the Jenkins JVM
which is presumably meant to convey "and not in an agent JVM". (Fun side note: If you use println in the Groovy script, it prints out to the Jenkins master log, not to the job's console log)
The Post build task plugin does run on the build node (and you don't need to wrap your shell command in a groovy script). The task requires a condition: to "always run" your script just leave the Log text blank.
You might also consider taking a look at the Jenkins Pipeline, which lets you bake in try/catch type logic and maintain your pipeline "as code" using a Jenkinsfile.
All jobs using SVN Checkout are now failing.
Running Jenkins 2.89, SVN 1.92, SUSE 12-SP2
Running Master only
SVN Checkout from a command line window is successful.
Jenkins job receives:
Building in workspace /var/devops/jenkins/jobs/svn test/workspace
Cleaning local Directory CCUMMINGS_TEST_PHASE2
Checking out https://99.999.88.111/MAIN/branches/CCUMMINGS_TEST_PHASE2 at revision '2018-06-12T11:04:05.109 -0700'
FATAL: null
java.nio.channels.NonWritableChannelException
at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1127)
at org.tmatesoft.sqljet.core.internal.fs.SqlJetFileLockManager$1.createLock(SqlJetFileLockManager.java:57)
at org.tmatesoft.sqljet.core.internal.fs.SqlJetFileLockManager.createLock(SqlJetFileLockManager.java:81)
at org.tmatesoft.sqljet.core.internal.fs.SqlJetFileLockManager.tryLock(SqlJetFileLockManager.java:102)
at org.tmatesoft.sqljet.core.internal.fs.SqlJetFile.checkReservedLock(SqlJetFile.java:714)
at org.tmatesoft.sqljet.core.internal.pager.SqlJetPager.hasHotJournal(SqlJetPager.java:2484)
at org.tmatesoft.sqljet.core.internal.pager.SqlJetPager.sharedLock(SqlJetPager.java:1251)
at org.tmatesoft.sqljet.core.internal.pager.SqlJetPager.acquirePage(SqlJetPager.java:1020)
at org.tmatesoft.sqljet.core.internal.btree.SqlJetBtree.getMeta(SqlJetBtree.java:2196)
at org.tmatesoft.sqljet.core.internal.table.SqlJetOptions.readSchemaCookie(SqlJetOptions.java:213)
at org.tmatesoft.sqljet.core.internal.table.SqlJetOptions.readMeta(SqlJetOptions.java:148)
at org.tmatesoft.sqljet.core.internal.table.SqlJetOptions.<init>(SqlJetOptions.java:104)
at org.tmatesoft.sqljet.core.table.engine.SqlJetEngine$2.runSynchronized(SqlJetEngine.java:281)
at org.tmatesoft.sqljet.core.table.engine.SqlJetEngine.runSynchronized(SqlJetEngine.java:217)
at org.tmatesoft.sqljet.core.table.engine.SqlJetEngine.readSchema(SqlJetEngine.java:276)
at org.tmatesoft.sqljet.core.table.engine.SqlJetEngine.getOptions(SqlJetEngine.java:299)
at org.tmatesoft.svn.core.internal.wc17.db.SVNWCDbRoot.<init>(SVNWCDbRoot.java:74)
at org.tmatesoft.svn.core.internal.wc17.db.SVNWCDb.parseDir(SVNWCDb.java:1984)
at org.tmatesoft.svn.core.wc2.SvnOperationFactory.isVersionedDirectory(SvnOperationFactory.java:1502)
at org.tmatesoft.svn.core.wc2.SvnOperationFactory.isVersionedDirectory(SvnOperationFactory.java:1480)
at org.tmatesoft.svn.core.wc.SVNWCUtil.isVersionedDirectory(SVNWCUtil.java:296)
at org.tmatesoft.svn.core.wc2.SvnOperationFactory.getImplementation(SvnOperationFactory.java:1318)
at org.tmatesoft.svn.core.wc2.SvnOperationFactory.run(SvnOperationFactory.java:1227)
at org.tmatesoft.svn.core.wc2.SvnOperation.run(SvnOperation.java:294)
at hudson.scm.subversion.CheckoutUpdater$1.perform(CheckoutUpdater.java:121)
at hudson.scm.subversion.WorkspaceUpdater$UpdateTask.delegateTo(WorkspaceUpdater.java:168)
at hudson.scm.SubversionSCM$CheckOutTask.perform(SubversionSCM.java:1041)
at hudson.scm.SubversionSCM$CheckOutTask.invoke(SubversionSCM.java:1017)
at hudson.scm.SubversionSCM$CheckOutTask.invoke(SubversionSCM.java:990)
at hudson.FilePath.act(FilePath.java:997)
at hudson.FilePath.act(FilePath.java:975)
at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:937)
at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:864)
at hudson.scm.SCM.checkout(SCM.java:495)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1202)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
at hudson.model.Run.execute(Run.java:1724)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:421)
Finished: FAILURE
I suspect a password or a credential may be off, but none of them have changed.
a jenkins pipeline job with a script from SVN can be checked out and run but gets the same error.
Any help in debugging or direction to look in would be helpful
Jenkins .xml files had been placed under SVN control using command line svn. Removed .svn files from Jenkins directory and var/devops/jenkins/jobs directory and ../jenkins/jobs directory to resolve the error
I was running a RobotFramework script using Jenkins and everything was working fine until I accidentally wiped out my current workspace. I don't know how to restore it and now I'm getting the following error:
Robot results publisher started...
-Parsing output xml:
Failed!
hudson.AbortException: No files found in path C:\Users\EEMIZHA\.jenkins\jobs\3PI RF2\workspace with configured filemask: output.xml
at hudson.plugins.robot.RobotParser$RobotParserCallable.invoke(RobotParser.java:77)
at hudson.plugins.robot.RobotParser$RobotParserCallable.invoke(RobotParser.java:54)
at hudson.FilePath.act(FilePath.java:990)
at hudson.FilePath.act(FilePath.java:968)
at hudson.plugins.robot.RobotParser.parse(RobotParser.java:49)
at hudson.plugins.robot.RobotPublisher.parse(RobotPublisher.java:217)
at hudson.plugins.robot.RobotPublisher.perform(RobotPublisher.java:239)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
at hudson.model.Build$BuildExecution.post2(Build.java:185)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
at hudson.model.Run.execute(Run.java:1763)
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 'Publish Robot Framework test results' changed build result to FAILURE
Finished: FAILURE
I have the robot plugin installed, I've enabled a "Publish Robot Framework test results" post build action, and I'm executing a very simple Windows Batch Command as follows:
cd C:\Users\EEMIZHA\Documents\3PIManager\Testing\
pybot jenkinsConnectionTest.robot
Any ideas?
Fixed by using a custom workspace in Jenkins set to my \path\to\test (under Advanced Project Options/Advanced...). Run pybot command with -d \path\to\test\output-folder parameter and set output-folder as "Directory of Robot output" in Robot Framework post build action.
I want deploy in Glassfish a WAR using these batch commands from Jenkins. :
This is how I deploy a WAR with Batch command :
H:\workspace\xxxx>"C:\glassfish3\glassfish\bin\asadmin.bat" "undeploy"
Enter the value for the name operand> xxxx
H:\workspace\xxxx>"C:\glassfish3\glassfish\bin\asadmin.bat" "deploy"
Enter the value for the path operand> H:\xxxx-sources\xxxx.war
Application deployed with name xxxx.
Command deploy executed successfully.
In Jenkins , I add a batch command in my build with that :
cd "C:\glassfish3\glassfish\bin\"
asadmin.bat "undeploy"
XXXX
asadmin.bat "deploy"
H:\XXXX sources\XXXX.war
I have this error :
Démarré par l'utilisateur anonymous Building on master in workspace
C:\Documents and
Settings\XXXX.XXXX.jenkins\jobs\deployerXXXXCore\workspace
[workspace] $ sh -xe
C:\DOCUME~1\XXXX~1.XXXX\LOCALS~1\Temp\hudson2065869118895930371.sh
The system cannot find the file specified FATAL: L'exécution de la
commande a échoué. java.io.IOException: Cannot run program "sh" (in
directory "C:\Documents and
Settings\XXXX.XXXX.jenkins\jobs\deployerXXXX\workspace"):
CreateProcess error=2, The system cannot find the file specified at
java.lang.ProcessBuilder.start(ProcessBuilder.java:460) at
hudson.Proc$LocalProc.(Proc.java:244) at
hudson.Proc$LocalProc.(Proc.java:216) at
hudson.Launcher$LocalLauncher.launch(Launcher.java:802) at
hudson.Launcher$ProcStarter.start(Launcher.java:380) at
hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:97)
at
hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at
hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
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:533)
at hudson.model.Run.execute(Run.java:1759) 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.io.IOException: CreateProcess error=2, The system cannot find the
file specified at java.lang.ProcessImpl.create(Native Method) at
java.lang.ProcessImpl.(ProcessImpl.java:81) at
java.lang.ProcessImpl.start(ProcessImpl.java:30) at
java.lang.ProcessBuilder.start(ProcessBuilder.java:453) ... 15 more
Build step 'Exécuter un script shell' marked build as failure
Finished: FAILURE
It seems that you are trying to execute your scripts in Jenkins using shell script execution,which works only on unix-like systems. Try doing the same with Windows batch execution in the Jenkins job.
You should select 'Execute Windows batch command' according to Jenkins guide.