I am in a situation, it's been more than two weeks but I could not solve the problem. Sorry for the long description of the question. What I am trying to do is:
I have two different projects, say A
and B
and I have to build them using Jenkins. Though they are independent they work together. So I created to different repositories and called them Repo-A
and Repo-B
and I was able to build them.
Here is a real problem: Now I want to build them together from single repository. So I created a repository called Demo
in Bitbucket and now I have both projects A
and B
in Demo
repository.
Now I created a pom.xml
file in the Demo
repository so that I can use it as parent POM and each of the projects A
and B
have their own pom.xml
.
Project Demo's pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo.parent</groupId>
<artifactId>Parent</artifactId>
<packaging>pom</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Maven Webapp</name>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
<!--<url>http://maven.apache.org</url> -->
<modules>
<module>A</module>
<module>B</module>
</modules>
<distributionManagement>
<snapshotRepository>
<id>my-snapshots</id>
<name>Internal Repository</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>my-releases</id>
<name>Internal Repository</name>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
</repository>
</distributionManagement>
</project>
Project A's pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.a.batch</groupId>
<parent>
<groupId>com.demo.parent</groupId>
<artifactId>Parent</artifactId>
<version>0.01-SNAPSHOT</version>
</parent>
<artifactId>A</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>A Maven Webapp</name>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
<dependencies>
<!-- Spring ORM support -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>3.2.13.RELEASE</version>
</dependency>
<!-- Spring Batch -->
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core</artifactId>
<version>3.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-infrastructure</artifactId>
<version>3.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.1</version>
</dependency>
</project>
Project B
's pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.B</groupId>
<parent>
<groupId>com.demo.parent</groupId>
<artifactId>Parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>B</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>B Maven Webapp</name>
<!--url>http://maven.apache.org</url-->
<url>http://localhost:8081/nexus/content/repositories/releases</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.2.13.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.2.13.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.13.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>3.2.13.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.2.13.RELEASE</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</project>
Now when I am building using Jenkins the build is successful but Jenkins is not generating any war
file. It is generating three different pom
projects instead.
[INFO] A Maven Webapp ........................... SUCCESS [ 0.351 s]
[INFO] Demo Maven Webapp ............................ SUCCESS [ 0.056 s]
[INFO] B Maven Webapp ....................... SUCCESS [ 0.075 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.453 s
[INFO] Finished at: 2016-04-30T02:59:14+05:30
[INFO] Final Memory: 7M/176M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /var/lib/jenkins/jobs/Jenkins_Projects/workspace/A/pom.xml to com.A/A/1.0-SNAPSHOT/A-1.0-SNAPSHOT.pom
[JENKINS] Archiving /var/lib/jenkins/jobs/Jenkins_Projects/workspace/B/pom.xml to com.B/B/1.0-SNAPSHOT/B-1.0-SNAPSHOT.pom
[JENKINS] Archiving /var/lib/jenkins/jobs/Jenkins_Projects/workspace/Demo/pom.xml to Demo.Demo/Parent/1.0-SNAPSHOT/Parent-1.0-SNAPSHOT.pom
channel stopped
Finished: SUCCESS
If I build the projects standalone, the builds are successful and I am getting .war
files as well.
But when I am building from same repository Demo
and using parent pom.xml
I do not see any .war
files though the build is successful.
How do I solve this problem?
What is the way to build two projects together?
Why am I getting pom
instead of .war
?
Why am I getting Parent-1.0-SNAPSHOT.pom
though this is not a project. it is just a pom
inside repository.
Please guide me.
Demo
? Can you add the relevant parts of the Jenkins build log regarding the SCM handling? – Saccularmvn deploy
and some artifact repository (like Nexus). This should make this project independent from jenkins problems. – DocumentMaven Webapp
should be builded first, and this not happens in your log, so please attach correct projects poms and logs. – Document