Luna Paglarelli
Luna Paglarelli

Reputation: 129

Maven doesnt work on jenkins (but it does through eclipse and command line)

I have a few tests for CI, all in maven. The builds are successful when I run them in eclipse in my local (windows 10) and when I run them through command line in ec2 linux server.

Only when I build same project from Jenkins I get the following error:

Waiting for Jenkins to finish collecting data[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project invalidlogin: Error while storing the mojo status: /var/lib/jenkins/workspace/project/invalidlogin/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst (Permission denied) -> [Help 1]

Im using PhantomJS as browser.

How to make it work from jenkins?

this is my pom

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>InvalidLoginV1</groupId>
  <artifactId>invalidlogin</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>invalidcredentials</name>
  <description>invalidcredentials</description>

  <properties>
<suiteXmlFile>src/main/resources/testng.xml</suiteXmlFile>

</properties> 

<dependencies>
<dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>6.8</version>
  <scope>test</scope>
</dependency>

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-server</artifactId>
    <version>2.34.0</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>com.github.detro.ghostdriver</groupId>
    <artifactId>phantomjsdriver</artifactId>
    <version>1.0.4</version>
    <scope>test</scope>
</dependency>

<dependency>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.19.1</version>
  <type>maven-plugin</type>
</dependency>


</dependencies>  

<build>


<plugins>

    <plugin>
          <groupId>com.github.klieber</groupId>
          <artifactId>phantomjs-maven-plugin</artifactId>
          <version>0.7</version>
    </plugin>



<plugin>



<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<compilerVersion>1.8</compilerVersion>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>


</plugins>

</build>

</project>

Upvotes: 3

Views: 7001

Answers (2)

Swami Ganesh Bandaru
Swami Ganesh Bandaru

Reputation: 21

Running chmod command on your project may solve your problem

chmod -R 777 projectfoldername

Upvotes: 2

Luna Paglarelli
Luna Paglarelli

Reputation: 129

The issue was indeed with permissions. I had a few issues setting this up, however I found this guide here: http://blog.manula.org/2013/03/running-jenkins-under-different-user-in.html

basically you need to add a preexisting user on the server as the jenkins user. sudo vim /etc/sysconfig/jenkins

Once that is done, just change the ownership of jenkins home, webroot and logs

chown -R user:user/var/lib/jenkins 
chown -R user:user/var/cache/jenkins
chown -R user:user/var/log/jenkins

Thanks @Reimeus!

Upvotes: 6

Related Questions