Not able do deploy proxy with Maven Plugin to Hybrid

Hey, Guys. We use Maven Plugin a lot for deploying proxies and SF to Cloud solution. Recently we had to deploy proxies to Apigee Hybrid and faced some issue. We have service account and generated Token. I use next command adding correct token as param:

mvn clean install -Pdemo -Dusername=*****@********.com -Dpassword=******* -Dorg=platforms-apigee -Dversion=v1 -Dbearer=$TOKEN -Doptions=validate
My shared-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/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>apigee</groupId>
 <artifactId>parent-pom</artifactId>
 <packaging>pom</packaging>
 <version>1.0</version>
 <pluginRepositories>
 <pluginRepository>
 <id>central</id>
 <name>Maven Plugin Repository</name>
 <url>https://repo1.maven.org/maven2</url>
   <layout>default</layout>
 <snapshots>
 <enabled>false</enabled>
 </snapshots>
 <releases>
 <updatePolicy>never</updatePolicy>
 </releases>
 </pluginRepository>
 </pluginRepositories>
 <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.6</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>2.0.4</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>

 <profiles>
 	<profile>
 	<id>demo</id>
 	<properties>
 		<org>${org}</org> 
 		<apigee.profile>demo</apigee.profile>
 		<apigee.env>demo</apigee.env>
 		<apigee.hosturl>https://apigee.googleapis.com</apigee.hosturl>
 		<apigee.apiversion>${version}</apigee.apiversion>
 		<apigee.org>${org}</apigee.org>
 		<apigee.username>${username}</apigee.username>
 		<apigee.password>${password}</apigee.password>
 		<apigee.options>${options}</apigee.options>
 		<apigee.tokenurl>${tokenurl}</apigee.tokenurl> <!-- optional: oauth -->
 		<apigee.mfatoken>${mfatoken}</apigee.mfatoken> <!-- optional: mfa -->
 		<apigee.authtype>${authtype}</apigee.authtype> 
 		<apigee.bearer>${bearer}</apigee.bearer> <!-- optional: Bearer token override -->
 		<apigee.refresh>${refresh}</apigee.refresh> <!-- optional: Refresh token override -->
 		<apigee.clientid>${clientId}</apigee.clientid> <!-- optional: Oauth Client Id - Default is edgecli-->
 		<apigee.clientsecret>${clientSecret}</apigee.clientsecret> <!-- optional: Oauth Client Secret Default is edgeclisecret-->
 		<!--apigee.override.delay>10</apigee.override.delay-->
 		<!--apigee.delay>1000</apigee.delay-->
 	</properties>
	 </profile>
 </profiles>
</project>

When command is launched I get next output which I get every 10 seconds:

Request prepared for the server
 **************************
POST  https://apigee.googleapis.com/v1/organizations/platforms-apigee/environments/demo/apis/video-v1/revi...
accept: [application/json]
authorization: [Bearer [Not shown in log]
content-type: application/x-www-form-urlencoded; charset=UTF-8
 [Request body]
override=true
[INFO] Getting Deployment Info for Revision: 23
[INFO] Using the bearer token
[INFO]
Request prepared for the server
 **************************
GET  https://apigee.googleapis.com/v1/organizations/platforms-apigee/environments/demo/apis/video-v1/revi...
accept: [application/json]
accept-encoding: [gzip]
authorization: [Bearer [Not shown in log] 

Could you help me to understand what I am doing wrong. Previously we had no issues with Maven Plugin. I would be grateful for your advices. Able to provide all info, you need. Thanks!

Solved Solved
1 2 331
1 ACCEPTED SOLUTION

@Oleksandr Chalyi

Welcome to the community !

Looks right to me. In hybrid, the deployment is asynchronous. When you make the POST call to perform the deployment, you get a confirmation response back. You will need to poll the deployments API to see if the deployment is complete. The plugin is doing that and thats why you seeing the multiple GET calls. The deployment could take a few seconds (30-40 seconds) and in that period, the plugin keeps polling to check the status. Once it's complete, it should complete the build process.

TIP: While this is running, you can refresh the Apigee UI and see if the deployment of that API is complete. The UI behind the scenes uses the same API to poll the deployment status.

Please let us know if the deployment was complete but the plugin still did not complete

View solution in original post

2 REPLIES 2

@Oleksandr Chalyi

Welcome to the community !

Looks right to me. In hybrid, the deployment is asynchronous. When you make the POST call to perform the deployment, you get a confirmation response back. You will need to poll the deployments API to see if the deployment is complete. The plugin is doing that and thats why you seeing the multiple GET calls. The deployment could take a few seconds (30-40 seconds) and in that period, the plugin keeps polling to check the status. Once it's complete, it should complete the build process.

TIP: While this is running, you can refresh the Apigee UI and see if the deployment of that API is complete. The UI behind the scenes uses the same API to poll the deployment status.

Please let us know if the deployment was complete but the plugin still did not complete

Hey! Thanks a a lot! You are totally right about the reason of my issue. From the very beginning I had imported proxy but it was not deployed and GET request was infinite. Later it has changed and after 4 - 7 GET request I got message about successful deployment. Not sure why from very beginning it worked in a bit other way, but everything is fine. Thank you for explanation!