Using custom Maven version in Jenkins on OpenShift - maven

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?

Related

Jenkins Pathignore Plugin installation failing

I have Jenkins installed on a Windows Server.
I am trying to add the plugin Pathignore Plugin which has a dependency on Ruby-runtime.
When I tried to add Ruby-runtime plugin, I've got the following error:
Caused by: java.nio.file.FileSystemException: C:\Program Files (x86)\Jenkins\plugins\ruby-runtime\WEB-INF\lib\classes.jar: The process cannot access the file because it is being used by another process.
It appears to be caused by a long file name bug, I had to relocate our Jenkins install to the root of the drive, it then "just works"
Stop the Jenkins Service
Move the Jenkins folder to the drive root (i.e. C:\Program Files (x86)\Jenkins to C:\Jenkins
Edit the location of the service in the system registry
Restart Jenkins
see bug report here for more information

Windows : Not able to execute gradle command from groovy script

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.

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.

Jenkins executing maven from incorrect path

This happens for both: maven projects, and freestyle projects, when maven target is envoked, it tries to execute mvn using absolute path.
[MY-Job] $ tools/Maven/Jenkins_Private_Maven/bin/mvn -f cc/pom.xml -Ddeploy_env=xxx.dev.prv -Dbranch=dev -D-Dsmdist.target=/opt/builds -U clean test -DtestGroups=unit,delegate -Do verride:server=xxx.dev.prv
FATAL: command execution failed
java.io.IOException: Cannot run program "tools/Maven/Jenkins_Private_Maven/bin/mvn" (in directory "workspace/MY-Job"): java.io.IOException: error=2, No such file or directory
I can see that mvn is installed at user's home :
/home/jenkins/tools/Maven/Jenkins_Private_Maven/bin/mvn
but it's trying to run it from the workspace:
/home/jenkins/workspace/MY-Job/tools/Maven/Jenkins_Private_Maven/bin/mvn
Add the default maven installation under (Jenkins -> configuration)
Goto the failing job and make sure you choose the default maven installation from dropdown
Run the job. Success!
Are you sure you have set up Maven in Jenkins -> configuration like this
I have hunch you have a accidental **"."** current directory reference somewhere in your maven set up.
This looks like an auto installed Maven by Jenkins. In which case the previous answers are not correct.
It would seem in this occasion that you have not specified a "remote fs root" for your slave in the salve setup - later versions of Jenkins flag not setting this up correctly as an error.
in Jenkins 2.43:
Manage Jenkins -> Global Tool Configuration -> Maven

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.

Resources