CICD using git, jenkin and apigee.

Hello All,

As I m trying to deploy API proxy using git and Jenkins. Below is my successful configuration.

1. I m able to connect to git (clone, pull, commit, push ) through a local computer.

2. In Jenkins job built it able to configured and take a path from git lab repository.

3. While building the job I m getting below error "Failed to getClass for io.apigee.buildTools.enterprise4g.mavenplugin.DeployMojo"

=============Now zipping the App Bundle================


[WARNING] Failed to getClass for io.apigee.buildTools.enterprise4g.mavenplugin.DeployMojo
[INFO] 
[INFO] <<< apigee-edge-maven-plugin:1.0.3:deploy (deploy-bundle) < package @ CICDDemo <<<
[INFO] 
[INFO] 
[INFO] --- apigee-edge-maven-plugin:1.0.3:deploy (deploy-bundle) @ CICDDemo ---
[INFO] 

=============Initializing Maven Deployment================


[INFO] 

=============Importing App================


[ERROR] 


* * * * * * * * * * *

This deployment could have failed for a variety of reasons.



* * * * * * * * * * *



[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenArtifactArchiver$2; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenFingerprinter$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.548 s
[INFO] Finished at: 2018-11-19T14:58:15+05:30
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "test" could not be activated because it does not exist.
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:1.0.3:deploy (deploy-bundle) on project CICDDemo: MojoExecutionException: NullPointerException -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Below is the maven pom file,
pom.txt



If you need any more infomation please let me know.

Any pointer/lead would help me here would be really appreciated. @Dino @Sai Saran Vaidyanathan @Anil Sagar @ Google @Siddharth Barahalikar

Solved Solved
2 9 4,658
1 ACCEPTED SOLUTION

@Mohsin Khan

Not sure what is the mvn command you are running. From the WARNING, looks like you are calling the maven command with the test profile "-P test" but your pom only has a "dev" profile in it. So either include a test profile in your pom or else change the mvn command you are running to use the dev profile

mvn clean install -P dev -Dorg=<org> -Dusername=<user> -Dpassword=<password>

In the pom you shared the env used is hardcoded to "dev", so make sure you have that in your Apigee organization, if not change that from

<apigee.env>dev</apigee.env>

to

<apigee.env>${env}</apigee.env>

and include that in your maven command

mvn clean install -P dev -Dorg=<org> -Dusername=<user> -Dpassword=<password> -Denv=<env>

Hope this helps

View solution in original post

9 REPLIES 9

For reference, I have used below links, but no luck,
https://community.apigee.com/questions/18908/error-during-deployment-in-travis-apigee-edge-mave.html
https://github.com/AnuManasa05/cal-build-deploy/blob/master/Calculator-master/shared-pom.xml
https://github.com/apigee/apigee-deploy-maven-plugin/tree/master/samples

Below is the shared-pom.xml file

<!-- Copyright (C) 2014 Apigee Corporation Licensed under the Apache License, 
	Version 2.0 (the "License"); you may not use this file except in compliance 
	with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
	Unless required by applicable law or agreed to in writing, software distributed 
	under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 
	OR CONDITIONS OF ANY KIND, either express or implied. See the License for 
	the specific language governing permissions and limitations under the License. -->


<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">


	<!--  <parent>
		<groupId>com.myorg.maven.adp</groupId>
		<artifactId>adp-base-pom</artifactId>
		<version>1.0.16</version>
	</parent> -->
	
   <parent>
 	    <groupId>org.sonatype.oss</groupId>
    	<artifactId>oss-parent</artifactId>
    	<version>7</version>
  </parent>


	<modelVersion>4.0.0</modelVersion>
	<groupId>apigee</groupId>
	<artifactId>shared-pom</artifactId>
	<packaging>pom</packaging>
	<version>1.0</version>


	<name>shared-pom</name>
	<description>Plugin to manage configuration in Apigee</description>
	<url>http://maven.apache.org</url>


	<properties>
		<main.basedir>${project.basedir}</main.basedir>
	</properties>


	<build>
		<plugins>			
			<plugin>
				<artifactId>maven-clean-plugin</artifactId>
				<version>2.5</version>
			</plugin>
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<version>2.5</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<overwrite>true</overwrite>
							<encoding>UTF-8</encoding>
							<echo message="basedir parent : ${basedir}" />
							<outputDirectory>${basedir}/target/apiproxy</outputDirectory>
							<resources>
								<resource>
									<directory>apiproxy</directory>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>io.apigee.build-tools.enterprise4g</groupId>
				<artifactId>apigee-edge-maven-plugin</artifactId>
				<version>1.0.3</version>
				<executions>
					<execution>
						<id>configure-bundle</id>
						<phase>package</phase>
						<goals>
							<goal>configure</goal>
						</goals>
					</execution>
					<execution>
						<id>deploy-bundle</id>
						<phase>install</phase>
						<goals>
							<goal>deploy</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
	<!-- This is where you add the environment specific properties under various 
		profile names -->
	<profiles>
		<profile>
			<id>dev</id>
			<properties>
				<org>enterprisemobility</org>  <!-- default org, replace with dafault org to avoid passing parameter e.g. 
					-Dorg testmyapi -->
				<options>validate</options> 	<!-- default options, replace with dafault option to avoid passing parameter 
					e.g. -Doptions=validate,update -->
				<apigee.profile>dev</apigee.profile>
				<apigee.env>dev</apigee.env>
				<apigee.hosturl>https://apigeems.persistent.com:9443</apigee.hosturl>
				<apigee.apiversion>v1</apigee.apiversion>
				<apigee.org>${org}</apigee.org>
				<apigee.username>${username}</apigee.username>
				<apigee.password>${password}</apigee.password>
				<apigee.options>${options}</apigee.options>
			</properties>
		</profile>
	</profiles>			
</project>

@Mohsin Khan

Not sure what is the mvn command you are running. From the WARNING, looks like you are calling the maven command with the test profile "-P test" but your pom only has a "dev" profile in it. So either include a test profile in your pom or else change the mvn command you are running to use the dev profile

mvn clean install -P dev -Dorg=<org> -Dusername=<user> -Dpassword=<password>

In the pom you shared the env used is hardcoded to "dev", so make sure you have that in your Apigee organization, if not change that from

<apigee.env>dev</apigee.env>

to

<apigee.env>${env}</apigee.env>

and include that in your maven command

mvn clean install -P dev -Dorg=<org> -Dusername=<user> -Dpassword=<password> -Denv=<env>

Hope this helps

Thanks, @Sai Saran Vaidyanathan for your response.

In my organization, we have 4 different environments like prod, dev, qe, uat. I'm using dev env for this demo.

I have updated my shared-pom.xml as you mention and also mention maven command used in Jenkins as follow,

install -P dev -Dusername=$apg_username -Dpassword=$apg_password -Dorg=$apg_org -Denv=$apg_env
<!-- This is where you add the environment specific properties under various profile names -->		
 <profiles>
        <profile>
          <id>dev</id>
           <properties>
                <apigee.profile>dev</apigee.profile>
                <apigee.hosturl>https://apigeems.persistent.com:9443</apigee.hosturl>
                <apigee.apiversion>v1</apigee.apiversion>
                <apigee.org>${org}</apigee.org>
                <apigee.env>${env}</apigee.env>
                <apigee.username>${username}</apigee.username>
                <apigee.password>${password}</apigee.password>
               
            </properties>
        </profile>       
		 
 </profiles>

But after building the project through Jenkins

[INFO] 

=============Now zipping the App Bundle================


[WARNING] Failed to getClass for io.apigee.buildTools.enterprise4g.mavenplugin.DeployMojo
[INFO] 
[INFO] <<< apigee-edge-maven-plugin:1.0.3:deploy (deploy-bundle) < package @ CICDDemo <<<
[INFO] 
[INFO] 
[INFO] --- apigee-edge-maven-plugin:1.0.3:deploy (deploy-bundle) @ CICDDemo ---
[INFO] 

=============Initializing Maven Deployment================


[INFO] 

=============Importing App================


[INFO] 


Request prepared for the server 
 **************************
POST  https://apigeems.persistent.com:9443/v1/organizations/enterprisemobility/apis?action=import&name=CIC...
accept: application/json
accept-encoding: gzip
authorization: Basic [Not shown in log]
content-type: application/octet-stream
 [Request body contains data, not shown] 

[ERROR] 404 Not Found


[ERROR] 


* * * * * * * * * * *

This deployment could have failed for a variety of reasons.



* * * * * * * * * * *



[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenArtifactArchiver$2; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenFingerprinter$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.100 s
[INFO] Finished at: 2018-11-20T14:10:58+05:30
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:1.0.3:deploy (deploy-bundle) on project CICDDemo: MojoExecutionException: 404 Not Found

By looking at above result is there any configuration required on Apigee server we are getting 404 Not found error. I m using Apigee OPDK v.4.17.09.00

Thanks for that info @Mohsin Khan

Few things for you to check:

  1. Can you confirm that the Mgmt API URL is correct ? Can you make a call to https://apigeems.persistent.com:9443/v1/organizations/enterprisemobility/apis and see if you are getting a response ? Probably the URL is not correct ?
  2. Can you make sure the Jenkins server has access to that Mgmt server host ?
  3. Can you run the maven command with a "-X" for debug logs, it can provide you more details?
  4. Can you run the command with "-Dhttps.protocols=TLSv1.2" (just in case if the https protocols is the issue)

Thanks a lot, @Sai Saran Vaidyanathan

There was an issue with the port number here I changed it, now I'm able to build Jenkins job successfully and a proxy is deployed in Edge.


Now the question arises here is how can we deploy multiple proxies in one build.

For this, I came across your one post in the community,
https://community.apigee.com/questions/43522/deploying-apis-using-jenkins-and-apigee-maven-plug.html

As you mention that update you shared-pom.xml as mention below and point Jenkins build root to this shared-pom.xml.file and reset other two proxy as CICDdemo1 and CICDdemo2 which need to be deployed are having their individual pom.xml

<modules>
        <module>CICDdemo1</module>
        <module>CICDdemo2</module>
</modules>

After build execution, I'm getting below error you can find here build-error.txt, I have run the maven command with a "-X" to get the debug logs.

build-error.txt

Here am I on right track or do I need to make some changes. please suggest me because in local machine Jenkins workspace I have pointed to take this shared-pom.xml which it's not taking as I feel

Thanks a lot for all your help @Sai Saran Vaidyanathan now I'm able to build successfully multiple proxies in one jenkins build.

Thats awesome ! Glad you were able to get it through

Former Community Member
Not applicable

@Mohsin Khan, are you using 1 repo for each proxy or 1 repo for all proxies?

aswinsegu
Participant IV

@Mohsin Khan

Please refer to the Readme.md and Samples for the actual folder structure in the below repository

https://github.com/apigee/apigee-deploy-maven-plugin

Alternatively, the directory structure can be seen when you download the API Proxy from Apigee Edge Dashboard