Windows : Not able to execute gradle command from groovy script - windows

I am trying to run gradle command from groovy script.
File : file.groovy
def command = "gradle clean"
command.execute()
Getting following error,
$ groovy file.groovy
Caught: java.io.IOException: Cannot run program "gradle": CreateProcess
error=2, The system cannot find the file specified
java.io.IOException: Cannot run program "gradle": CreateProcess error=2, The
system cannot find the file specified
at file.run(file.groovy:2)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot
find the file specified
... 1 more
Same file is running perfectly fine on MAC.
Using Gradle 3.0 and Groovy 2.4.7
Also if running gradle clean directly, it is working as expected.
Issues comes only when calling from groovy file on windows system.
Tried on windows cmd as well as cygwin. Same issue.

Tried on windows cmd as well as cygwin. Same issue.
I'd say you have a problem with gradle installation. Just follow instructions
https://docs.gradle.org/current/userguide/installation.html
And pay attention to this point:
3.4. Environment variables
For running Gradle, firstly add the environment variable GRADLE_HOME.
This should point to the unpacked files from the Gradle website. Next
add GRADLE_HOME/bin to your PATH environment variable. Usually, this
is sufficient to run Gradle.

Related

Using custom Maven version in Jenkins on OpenShift

I'm trying to run maven-android-sdk-deployer on my OpenShift Jenkins. It needs at least Maven 3.1.1 to run, whereas OpenShift currently uses version 3.0.5 as default. Thus I tried to configure a custom Maven installation.
My Maven system configuration:
name: maven-3.1.1
install automatically: true
one installer with "Unzip archive" (I also tried "Install from Apache" with the same result.)
label: empty
download url: http://mirror.synyx.de/apache/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.zip
subfolder in archive: apache-maven-3.1.1
It seems to install Maven, because there is another error message, if "subfolder in archive" doesn't match. The zip file is valid.
But I cannot use it in the job.
I created a freestyle job and added a Maven step with the configured Maven installation.
There is an error message, when running the job:
[maven-android-sdk-deployer] $ app-root/data/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven-3.1.1/apache-maven-3.1.1/bin/mvn install -P 4.1
FATAL: command execution failed
java.io.IOException: Cannot run program "app-root/data/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven-3.1.1/apache-maven-3.1.1/bin/mvn" (in directory "app-root/data/jenkins/workspace/maven-android-sdk-deployer"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
... 13 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
... 17 more
Workaround for command line
I checked the file system the maven-android-sdk-deployer workspace and app-root/data/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven-3.1.1/apache-maven-3.1.1/bin/mvn both exist on the myappbldr-gear.
When I run the command from commandline I get the same error, whereas appending ~/ to the maven path works as intended:
[maven-android-sdk-deployer] $ ~/app-root/data/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven-3.1.1/apache-maven-3.1.1/bin/mvn install -P 4.1
Looks like this is an administration problem. How can I fix this?

Liferay theme development using JBoss on Mac

I am creating liferay themes using JBoss on my Mac. In the process of creating a theme, when I execute ant deploy on my terminal, I am getting following errors:
Buildfile:
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/themes/g2y-b2b-theme/build.xml
[copy] Copying 1 file to /usr/share/ant/lib
BUILD FAILED
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/themes/g2y-b2b-theme/build.xml:5:
The following error occurred while executing this line:
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/themes/build-common-theme.xml:7:
The following error occurred while executing this line:
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/build-common-plugin.xml:5:
The following error occurred while executing this line:
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/build-common.xml:68:
Failed to copy
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/lib/ecj.jar to
/usr/share/ant/lib/ecj.jar due to java.io.FileNotFoundException
/usr/share/ant/lib/ecj.jar (Permission denied)
Total time: 0 seconds
Please help me to get rid of this and proceed further. What are the steps I should take in order to do this on a Mac? Please also tell me how to set up the environment variable of ANT on a Mac.
When ant builds your theme and requires ecj.jar (the eclipse compiler for java) it typically downloads it from some internet repository and places it in $ANT_HOME/lib. It seems your $ANT_HOME is usr/share/ant and you don't have write access to that directory. Either download it manually and place it there or open up the directory write permissions for one build (then close it again).
You'll only need to do this once: When ecj.jar is on the classpath for ant, it will just be used for eternity.

How do I run phantomjs as a target of js-testrunner from within an intellij maven install?

I have a strange situation on which I cannot get phantom tests to run from intellij.
java.io.IOException: The phantomjs executable cannot be launched from the path or from the value of the org.codehaus.jstestrunner.commandPattern property.See http://js-testrunner.codehaus.org/usage.html for instructions. Original exception: java.io.IOException: Cannot run program "phantomjs": error=2, No such file or directory
Now, I have no idea why this is because:
I can access phantom from the command line, as 'mvn test' works, runs and passes the tests
I have added it as a path variable
I have added it as a path variable that is accessible by a GUI program
I've check the permissions on the phantomjs file and they're as permissive as I can make them - they are permissive than the actual IntelliJ application, and 'owned' by the same owner / group
I have restarted my Mac / IntelliJ numerous times.
I have tried adding it as a 'VM' option for a 'mvn install' task:
mvn test -Dorg.codehaus.jstestrunner.commandPattern="/usr/local/bin/phantomjs '%1$s' %2$s"
Can anyone think why the jstestrunner action that occurs as part of the mvn test target does not seem able to access / see my phantom installation
First thing to check: did you try to hardcode in your pom.xml the full path to the PhantomJS executable?
I know it's not the "final" solution, but it's to make sure it works if you pass it the full-qualified-path.

maven error while running sonar from hudson job

We were trying to implement Static Code Analyzers in our Hudson CI and was trying as mentioned here but, i came across about using SONAR for the same feature. We performed the following steps , but got error when the Hudson Job runs
Installed Sonar & running
Installed Sonar plugin in Hudson and configured hudson with sonar instance details
Configured Sonar details for the already defined job
The hudson job ran successfully until it deployed the WAR file to Tomcat6, but it failed when it started the sonar operations.
We received the following error in the Hudson job console
java.io.IOException: Cannot run program "mvn.bat" (in directory "D:\Users\abcd.hudson\jobs\QA Build Local\workspace\view"): CreateProcess error=2, The system cannot find the file specified
mvn.bat -f "D:\Users\abcd\.hudson\jobs\QA Build Local\workspace\view\msaccess\MyApp\Code\appone\pom.xml" -e -B sonar:sonar -Dsonar.host.url=http://localhost:9000/ -Dsonar.language=java
FATAL: command execution failed
java.io.IOException: Cannot run program "mvn.bat" (in directory "D:\Users\abcd\.hudson\jobs\QA Build Local\workspace\view"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
at hudson.Proc$LocalProc.(Proc.java:192)
at hudson.Proc$LocalProc.(Proc.java:164)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:639)
at hudson.Launcher$ProcStarter.start(Launcher.java:274)
at hudson.Launcher$ProcStarter.join(Launcher.java:281)
at hudson.tasks.Maven.perform(Maven.java:263)
at hudson.plugins.sonar.utils.SonarMaven.executeMaven(SonarMaven.java:138)
at hudson.plugins.sonar.SonarPublisher.executeSonar(SonarPublisher.java:300)
at hudson.plugins.sonar.SonarPublisher.perform(SonarPublisher.java:261)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:630)
at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:608)
at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:584)
at hudson.model.Build$RunnerImpl.post2(Build.java:159)
at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:553)
at hudson.model.Run.run(Run.java:1390)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:145)
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:452)
... 19 more
Sonar analysis completed: FAILURE
We manually ran the maven-sonar command from command prompt and the sonar analysis completed successfully and the results published in the sonar website.
Note: We observed that the M2_HOME environment variable is not set in the server. Would this be an error ?
Update on Fix:
We set maven_home\bin folder in windows PATH environment variable and then sonar was able to recognize mvn.bat and run.
Sonar is being run as a separate Maven program. The command line is being displayed at the top of the log:
mvn.bat -f "D:\Users\abcd.hudson\jobs\QA Build Local\workspace\view\msaccess\MyApp\Code\appone\pom.xml" -e -B sonar:sonar -Dsonar.host.url=http://localhost:9000/ -Dsonar.language=java
This is expected, you attached screen shots specified this Sonar configuration.
Your problem does not appear to be the job configuration, instead Jenkins is unable to find the "mvn.bat" command....
java.io.IOException: Cannot run program "mvn.bat" (in directory "D:\Users\abcd.hudson\jobs\QA Build Local\workspace\view"): CreateProcess error=2, The system cannot find the file specified
You need to investigate how you've configured Maven.
I had the same. In my case I had to change location of maven directory - when it was in "c:\Program Files (x86)\wamp\bin\apache-maven-3.2.1\" it couldn't run, but when I moved it to "c:\maven" (and changed system variable: "Path" including "C:\maven\bin" and created by me "MAVEN_HOME = c:\maven").
I had to reboot computer to work - check in windows console (logo windows -> run "cmd") by typing "mvn -version" and you should have line "Maven home: C:\maven"
Installation
Jenkins installed as war in Tomcat
Tomcat installed as a service in Windows
I've installed Maven and correctly configured environment variables in Windows
Problem
FATAL: command execution failed
java.io.IOException: Cannot run program "mvn.bat" (in directory "C:\.jenkins\workspace\my_project"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:470)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:803)
at hudson.Launcher$ProcStarter.start(Launcher.java:381)
at hudson.Launcher$ProcStarter.join(Launcher.java:388)
at hudson.tasks.Maven.perform(Maven.java:328)
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.<init>(ProcessImpl.java:177)
at java.lang.ProcessImpl.start(ProcessImpl.java:28)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
Solution
I've restarted Tomcat service so it has loaded the last configured Maven's environment variables making them available to Jenkins.

Error when executing "perform tests" in Roo

I'm using Spring Roo in STS and when I run the command "perform tests" I get the following error:
Cannot run program "mvn.bat" (in directory "C:\SS workspace\hello"): CreateProcess error=2, The system cannot find the file specified
Does anyone know what's the problem? I have maven installed properly and the PATH env set to MAVEN_HOME/bin
My Guess is that it chokes on the whitespace character in the current directory (although it shouldn't)
Known bug. Instead use the 'Run As > JUnit Test' command
STS provides via the 'Run As > JUnit Test' a more visual interface
which I prefer, but some may still prefer the "Roo Shell"
If you are on windows 7- 64 bit machine, check if your mavan is on path. Omit MAVAN_HOME and try adding full path.

Resources