Apigee deploy maven plugin - Separate build and deploy process

agupta267
Participant III

I am using apigee deploy maven plugin for the deployments (which is working fine) but now trying to separate build and deploy phase but facing issues.

I am able to successfully create the package using below command (parameter buildNumber is added to create unique package name for every build)

mvn package -DbuildNumber={buildNumber}

Eg. Package Name created is "abc1.0-1-test.zip" wherein 1 is buildNumber

Now I want to deploy the already created package. I am using below command and getting below error :

Command : mvn deploy -Ptest -Dusername={username} -Dpassword={pwd} -Dorg=xyz

Error :

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




[INFO]




Request prepared for the server
 **************************
POST  https://api.enterprise.apigee.com/v1/organizations/xyz/apis?action=imp
ort&name=abc
accept: application/json
accept-encoding: gzip
authorization: Basic [Not shown in log]
content-type: application/octet-stream
 [Request body contains data, not shown]


[ERROR] 400 Bad Request
{
  "code" : "repository.cassandra.UnableToReadApiProxy",
  "message" : "Unable to read/find APIProxy contents",
  "contexts" : [ ]
}
[ERROR]

Please help.

0 8 1,056
8 REPLIES 8

agupta267
Participant III

I am unable to edit question. Attaching the parent pom for reference.parent-apiproxy-pom.zip

agupta267
Participant III

@Sai Saran Vaidyanathan, please help.

@Apoorva

Why do you need this build number ? You cant deploy two different proxies to the same environment with the same basepath. So if you deploy abc1.0-1-test and abc1.0-2-test with the same basepath, the deployment will fail.

Can you explain why you are doing this ?

agupta267
Participant III

@Sai Saran Vaidyanathan, By adding build number, I am trying to keep all the packages created for an apiproxy instead of overwriting the package and deploy the one which I want.

eg. In dev, let's say I want build#10 package to be deployed of api proxy abc whereas in qa build#8 package to be deployed and in prod build#5 package to be deployed.

So, I would want to keep all the packages.

Also, if I am don't add build number in the package name and deploy the package using below command I get below error :

Command : mvn deploy -Ptest -Dusername={username} -Dpassword={pwd}

Error : repository element was not specified in the POM inside distributionManagement element in maven deploy

Hi @Apoorva

I dont think its a good idea to do what you mentioned (have build number and use that across environments). The reasons being -

  1. Maintaining so many build and using that across environments seems a cumbersome process
  2. The more environments you have, these process get really complicated
  3. If you want to push certain hotfixes and also push certain fixes to your test and prod environment, your overall SDLC gets complicated

I think you should be using SCM and CI/CD to control the overall code promotion. Check this link, it talks about having branches for each environment. With this everything is controlled via your SCM and then audited.

Accordingly your CI/CD can just build the package from the appropriate environment branch and then push that to the appropriate Apigee environment.

Going back to your question, to create the package, you can run

mvn package -P<profile>

and to deploy, you can run

mvn apigee-enterprise:deploy -P<profile>

Make sure the package is in the target folder as the maven plugin expects the zip file to be in the target folder.

@Sai Saran Vaidyanathan

for deployment of Sharedflows: is there also a target folder with the zipped version needed or how is the folder structure expected in this case? Thx!!

Hi @maria thanner - I am happy to help if you can please open a new question regarding this? Don't want to mix two topics in the same post