How to Execute Build command in jenkins(Ubuntu) - java

I need to integrate a simple selenium script with Jenkins.
Can someone please help me to get a shell script code to update in the build section.
Currently, I am tried with run.bat file which returns the following error.
Building in workspace /home/mythos/loremine/Automation_Workspace/JenkinsDemo
[JenkinsDemo] $ cmd /c call /tmp/jenkins2455301809650179322.bat
FATAL: command execution failed
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)
Caused: java.io.IOException: Cannot run program "cmd" (in directory "/home/mythos/loremine/Automation_Workspace/JenkinsDemo"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at hudson.Proc$LocalProc.<init>(Proc.java:250)
at hudson.Proc$LocalProc.<init>(Proc.java:219)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:937)
at hudson.Launcher$ProcStarter.start(Launcher.java:455)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:109)
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:741)
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:1853)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:427)
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE

In Ubuntu, you need to use Execute Shell not Execute Windows Batch Command

remove / in your command as given below. It may solve your problems.
cmd /c call tmp/jenkins2455301809650179322.bat

Related

Permission denied error while running maven install

I have an IntelliJ IDEA Ultimate 2022.1.2 installed from Ubuntu Software app.
It is configured to use Maven wrapper. When I execute "install" on my java project (from lifecycle menu) I get two errors:
Cannot run program "/usr/bin/git" (in directory "/usr/bin"): error=13, Permission denied
--- protobuf-maven-plugin:0.6.1:compile
Compiling 1 proto file(s) to /.../target/generated-sources/protobuf/java
org.codehaus.plexus.util.cli.CommandLineException: Error while executing process.
...
at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
Caused by: java.io.IOException: Cannot run program "/.../target/protoc-plugins/protoc-3.11.1-linux-x86_64.exe": error=13, Permission denied
at java.lang.ProcessBuilder.start (ProcessBuilder.java:1143)
...
git test:
...:~$ /usr/bin/git --version
git version 2.25.1
protoc test:
...:~/Dev/.../target/protoc-plugins$ ls -l
total 4952
-rwxrwxr-x 1 user user 5068728 jun 6 14:24 protoc-3.11.1-linux-x86_64.exe
...:~/Dev/.../target/protoc-plugins$ ./protoc-3.11.1-linux-x86_64.exe --version
libprotoc 3.11.1
maven-wrapper.properties:
distributionUrl=https://.../repository/maven-central/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip
wrapperUrl=https://.../repository/maven-central/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
Same project on a different machine works well. Can't figure out a problem.
the problem was: missing execute permission on a /jvm/jdk-.../lib/jexec file.

I want to use JDK8 on macOS slave of Jenkins macOS but node is failing builds when removing earlier JDK

Sorry this question might be similar to any other but those questions did not solve my issue.
I had JDK 11 [primary] and JDK 8 [secondary] installed for Jenkins slave agent due to requirement.
Then JDK 11 started giving JNLP connection error after builds are successful but build status is FAILED.
Now I want to use JDK8 [as primary JDK] on my macOS slave to avoid JNLP connection error as my Master Jenkins is having JDK8.
But as soon I remove JDK11 , all my projects on that particular MacOS node fails before starting with error :-
check out build error logs when I removed JDK11 :-
FATAL: Command execution failed.
java.io.IOException: error=2, No such file or directory
at java.lang.ProcessImpl.forkAndExec(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
at java.lang.ProcessImpl.start(ProcessImpl.java:271)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from 192.xx.xx.50/192.xx.xx.50:49xxx
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1737)
at hudson.remoting.UserResponse.retrieve(UserRequest.java:313)
at hudson.remoting.Channel.call(Channel.java:952)
at hudson.Launcher$RemoteLauncher.launch(Launcher.java:1052)
at hudson.Launcher$ProcStarter.start(Launcher.java:449)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:109)
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: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:1727)
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: java.io.IOException: Cannot run program "/bin/sh" (in directory "Jenkins_home/workspace/java11-failure-on-mac-test"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
at hudson.Proc$LocalProc.<init>(Proc.java:249)
at hudson.Proc$LocalProc.<init>(Proc.java:218)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:929)
at hudson.Launcher$ProcStarter.start(Launcher.java:449)
at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1299)
at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1259)
at hudson.remoting.UserRequest.perform(UserRequest.java:153)
at hudson.remoting.UserRequest.perform(UserRequest.java:50)
at hudson.remoting.Request$2.run(Request.java:336)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at hudson.remoting.Engine$1$1.run(Engine.java:94)
at java.lang.Thread.run(Thread.java:834)
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Help would be appreciated..!

Jenkins 2.60.2 returns "CreateProcess error=267, The directory name is invalid" when running Gradle Task

I just installed Jenkins 2.60.2 using Windows Installer and then configure it to run my Gradle Task.
My build.gradle is located in C:\Workspace\SSD\build.gradle , so I put the path in Jenkins's configuration page, field "Root Build script :" C:\Workspace\SSD\build.gradle
When I click "Build Now" , Jenkins returns
Building in workspace C:\Program Files (x86)\Jenkins\workspace\Testing
[Gradle] - Launching build.
[build.gradle] $ cmd.exe /C "gradle.bat gradle clean test -PSSD && exit %%ERRORLEVEL%%"
The directory name is invalid
FATAL: command execution failed
java.io.IOException: Cannot run program "cmd.exe" (in directory "C:\Workspace\SSD\build.gradle"): CreateProcess error=267, The directory name is invalid
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:245)
at hudson.Proc$LocalProc.<init>(Proc.java:214)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:850)
at hudson.Launcher$ProcStarter.start(Launcher.java:384)
at hudson.Launcher$ProcStarter.join(Launcher.java:395)
at hudson.plugins.gradle.Gradle.performTask(Gradle.java:330)
at hudson.plugins.gradle.Gradle.perform(Gradle.java:221)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:735)
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:490)
at hudson.model.Run.execute(Run.java:1735)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:405)
Caused by: java.io.IOException: CreateProcess error=267, The directory name is invalid
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 17 more
Build step 'Invoke Gradle script' changed build result to FAILURE
Build step 'Invoke Gradle script' marked build as failure
Finished: FAILURE
I changed the field "Root Build script" to C:\\Workspace\\SSD\\build.gradle , still doesn't work.
When I build my codes using gradle (without Jenkins), it works fine.
Any clue maybe?
Thank you.
From the documentation at https://wiki.jenkins.io/display/JENKINS/Gradle+Plugin, and from the error it gives you, it expects the folder of the build script in that configuration option, not the full path to the script itself. Change it to C:\Workspace\SSD and I expect it will work.

issue with running git commands from java program

I am trying to run a git command through java program using
Runtime.getRuntime().exec(commandToBeExecuted);
and commandToBeExecuted ="git log" ;
i have set env variables but still getting the error like:
java.io.IOException: Cannot run program "git": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
at java.lang.Runtime.exec(Runtime.java:615)
at java.lang.Runtime.exec(Runtime.java:448)
at java.lang.Runtime.exec(Runtime.java:345)
at GITCodeCoverage.createLog(GITCodeCoverage.java:40)
at GITCodeCoverage.main(GITCodeCoverage.java:17)
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.<init>(ProcessImpl.java:188)
at java.lang.ProcessImpl.start(ProcessImpl.java:132)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1021)
... 5 more
Any can please help me in this run this command succesfully on Windows system.
Thanks in advance!
Try using this overloaded Runtime.exec(String command, String[] envp, File dir) like:-
File gitPath = new File("path where git is located in your system");
Runtime.exec('git logs', null, gitPath);

Word Topology deployment error

I am getting the following error when I try to deploy the Word Topology in windows.
I have followed the below link to deploy the word Topology in windows.
http://ptgoetz.github.io/blog/2013/12/18/running-apache-storm-on-windows/
When i deploy and see I am getting the floowing error.
java.lang.RuntimeException: Error when launching multilang subprocess
at backtype.storm.task.ShellBolt.prepare(ShellBolt.java:105)
at backtype.storm.daemon.executor$fn__3493$fn__3505.invoke(executor.clj:689)
at backtype.storm.util$async_loop$fn__457.invoke(util.clj:431)
at clojure.lang.AFn.run(AFn.java:24)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.IOException: Cannot run program "python" (in directory "storm- local\supervisor\stormdist\WordCount-1-1407303402\resources"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
at backtype.storm.utils.ShellProcess.launch(ShellProcess.java:50)
at backtype.storm.task.ShellBolt.prepare(ShellBolt.java:102)
... 4 more
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:189)
at java.lang.ProcessImpl.start(ProcessImpl.java:133)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1021)
Can anyone help me.
I had the same error.
Look at the compiled source. In the target folder you need all the scripts of the mutlilang available to execute all of them.
Look at target/classes/resources/ if there are any files. If not and if even you do not have the folder in target/classes copy the the resource folder from multilang/resources into the target path.

Categories

Resources