Giter Club home page Giter Club logo

apigee-deploy-maven-plugin's Introduction


apigee-deploy-maven-plugin (Apigee X or Apigee hybrid)

apigee-edge-maven-plugin is a build and deploy utility for building and deploying the Apigee ApiProxy's/Application bundles into Apigee Platform. The code is distributed under the Apache License 2.0.

NOTE: Log4J libraries are upgraded to v2.17.1 in v2.2.2


TL;DR

The samples folder provides a Readme with Getting Started steps and commands to hit the ground quickly.


Video

Learn more, check out this video! Ask the Expert


Detailed documentation on the use of plugin


Contents

Prerequisites

You will need the following to run the samples:

Plugin Usage

NOTE

  • If you want to use this plugin for Apigee Edge SaaS/Private Cloud OPDK, please refer to this link. You should be using the version 1.x
<dependency>
  <groupId>io.apigee.build-tools.enterprise4g</groupId>
  <artifactId>apigee-edge-maven-plugin</artifactId>
  <version>1.x</version>
</dependency>
  • For Apigee X or Apigee hybrid, the version of the plugin is 2.x
<dependency>
  <groupId>io.apigee.build-tools.enterprise4g</groupId>
  <artifactId>apigee-edge-maven-plugin</artifactId>
  <version>2.x</version>
</dependency>

Getting Started

Often the most difficult and confusing aspect of application development is figuring out how to build a common framework for creating new applications. Over time, development teams have started using tools like Maven, Ant and Ivy to automate some of these functions. This plugin uses the Maven plugin for deploying bundles to the Apigee platform.

Why this deployment plugin is developed?

  • Helps in offline development.
  • Easy integrations with source control like git.
  • The Maven build strategy is a good strategy if your current enterprise build and deploy strategies already use Maven or Maven compatible tools.
  • Configuration management across organizations/environments. (Realtime Enterprise Apigee architecture consists of multiple organizations/environments and configurations which varies according to these. An example scenario for this use would be the Maven configuration file to replace the number of requests it takes to trip a spike arrest policy. In your non-production environment you may want this policy to take effect when 10 requests a minute is surpassed, in production you may want this policy to trip when 10000 requests a minute is surpassed.)

Building API bundles

What is an Apigee bundle?

Apigee bundles can be described as a zipped file system composed of configuration, scripts and code. The file system when extracted is composed of the following structure.

 |-apiproxy/
   |-proxies
   |-resources
   |-policies
   |-targets

Create a new API Proxy

Instructions for creating a new API proxy can be found at this link

https://cloud.google.com/apigee/docs/api-platform/develop/ui-create-proxy

Export your API

Instructions for exporting your API via an API can be found at this link

https://cloud.google.com/apigee/docs/api-platform/fundamentals/download-api-proxies#download

To export you API via Apigee select the organization that contains the proxy you wish to export. From the navigation bar on the top, under APIs select the API Proxies. Select the proxy, on the far left of the screen, under the drop down menu titled Project, select Download Current Revision.

Steps to set it up

Follow below steps to set up your local development environment

  1. Create the folder structure as described in the section
  2. Create and configure pom files - Parent pom and the child pom for the proxy
  3. Create and configure config.json - if there are environment specific configurations (This is an optional step)

And you are ready for deploy to Apigee using the plugin

Step 1 Create a Maven compatible file structure

Below is the recommended structure for the project. However only the folder structure below the folder gateway is mandatory

  |-name-of-root (typically company name)
    |-archive/
      |-docs
      |-src
    |-binaries/
    |-build-artifacts/
    |-docs/
      |-customer
      |-reference
      |-solution
    |-src/
      |-analytics
      |-gateway/ ***
        |-parent-pom
        |-test-app/
          |-apiproxy/
            |-proxies
            |-resources/
              |-py
            |-policies
            |-targets
      |-java
      |-portal
    |-test

Decompress API Bundle

The API bundle will come zipped, use the unarchiving utility of your choice to unzip the file.

Once unzipped you will have a folder named apiproxy, this folder contains all of the configuration for your proxy and the folder structure needed for re-importing of the configuration.

The composition of the folder can be described as below.

File/Folder Purpose
{ApiName}.xml A file that contains descriptors for the content
policies/ A folder that contains all policy xml files
proxies/ A folder that contains information about your proxy configurations (inbound)
targets/ A folder that contains information about target configurations (outbound)
resources A folder that contains any scripts (java, jsc, py, node)

Note: when creating scripts, place your script/jar files in the proper folders based on the script type (e.g. JavaScript in jsc, node.js in node, java in java).

Step 2 Create and configure pom files

In a standard configuration typically we have parent-pom (pom.xml inside the parent-pom directory) and a child pom (pom file at the peer level as folder apiproxy).

The contents of the parent pom folder will contain a single pom.xml file. This file typically contains most of the configuration of Maven and the plugin, it also contains credentials for the Apigee platform.

In case of manual creation of Maven compatible file structure, "parent-pom" directory should be in peer level with other application folders. Here we configure information that is common across multiple apiproxys. Eg: Profile configurations which has the org/env info etc.

parent-pom-pom-xml Sample

Refer parent-pom template parent-pom

  • groupId element's content should be set to client's company name. Here you see it as apigee.
  • artifactId element's content be left as parent-pom.

Child-pom: Here we configure all the details specific to the particular proxy.

pom-xml Sample

Refer child-pom template child-pom.

  • groupId element's content should match that of the same element in the parent pom.xml.
  • artifactId element's content should be a unique name, typically set to the name of the API.
  • name element's content should match the artifactId above (typically set to the name of the API).
  • side-note groupId and artifactId, combined, define the artifact living quarters within a repository.

Step 3 Create and configure config-json

The config.json contains rules to perform build time configuration update. This JSON file's root object is "configurations" and is an array of proxy configurations scoped to an environment.

Note: it is important that the name of the configurations match the name of the profiles in the parent-pom.

For instance in the example below you have two configurations one for the test profile and one for the production profile. This example also shows how you can use xpath to replace environment specific settings.

Config-json Sample

Refer config.json template config.json

Commands for deploying the proxy using maven

To deploy the proxy

/src/gateway/proxy-dir
(run the command from the directory same as child pom)

mvn apigee-enterprise:deploy -P<profile> -Dfile={file}

The default configuration is "override" and in this option, the plugin polls to check if the deployment is complete across all pods. If you do not want the plugin to poll, please pass -Dapigee.options=async. This is available in v2.0.2 and later

mvn apigee-enterprise:deploy -P<profile> -Dfile={file} -Dapigee.options=async

For example:

mvn apigee-enterprise:deploy -P prod -Dfile={file}

You can also pass the bearer token to deploy (available from v2.0.1 and later)

mvn clean install -P{profile} -Dbearer=${bearer} -Dapigee.options={option}

For example using gcloud

mvn clean install -P{profile} -Dbearer=$(gcloud auth print-access-token) -Dapigee.options={option}

To deploy a proxy that makes requires Apigee to generate the GoogleAccessToken or GoogleIDToken (v2.1.2 or later)

NOTE: This option is available in Apigee X and Apigee hybrid 1.6+

If the API Proxy makes a callout to a Google API, Apigee now supports generating the access token or ID Token by just passing the service account email to the deployment API. For more info on the policy and HTTPTargetConnection config, check out Authentication.

mvn clean install -P{profile} -Dbearer=$(gcloud auth print-access-token) -DgoogleTokenEmail={ACCOUNT_ID}@{PROJECT}.iam.gserviceaccount.com

For more info check out Using Google authentication using Apigee

NOTE: Please make sure that you have the following config in your Maven profile

<apigee.googletoken.email>${googleTokenEmail}</apigee.googletoken.email>

To delete the proxy or sharedflow (v2.0.3 or later)

To delete the entire proxy or sharedflow, pass the options as clean

mvn clean install -P{profile} -Dbearer=$(gcloud auth print-access-token) -Dapigee.options=clean

To just import the proxy or sharedflow without activating (v2.4.1 or later)

To just import the proxy or sharedflow without activating, pass the options as inactive

mvn clean install -P{profile} -Dbearer=$(gcloud auth print-access-token) -Dapigee.options=inactive

To promote the proxy or sharedflow (v2.4.0 or later)

To promote an existing revision deployed to an Apigee org you can use the apigee-enterprise:promote goal

The promote goal allows the following options:

  • To deploy the latest revision to a target environment:
mvn apigee-enterprise:promote -P${profile} -Dbearer=$(gcloud auth print-access-token)

For example let's say the latest revision number of a proxy is 5 (whether deployed or not), the above command will deploy that revision to the environment configured in the Maven profile

  • To deploy a specific revision to Target env:
mvn apigee-enterprise:promote -P${profile} -Dbearer=$(gcloud auth print-access-token) -Dapigee.promote.revision=${REV}

For example, let's say you want a specific revision (Revision 3) to be deployed to an environment, you just need to pass -Dapigee.promote.revision=3. The plugin will deploy that revision to the environment configured in the Maven profile

  • To deploy a revision from a source env to a Target env:
mvn apigee-enterprise:promote -P${PROFILE} -Dbearer=$(gcloud auth print-access-token) -Dapigee.promote.sourceEnv=${SOURCE_ENV}

For example, lets say Revision 6 is deployed to dev environment and you want to promote that revision to qa environment. You can just pass -Dapigee.promote.sourceEnv=dev. The plugin will find the deployed revision from the source environment passed and deploy that revision to the environment configured in the Maven profile

Advanced Configuration Options

Note 1

The following entries in some XML file elements could be changed to match the customer's environment:

  • "groupId"
  • "id" (for each profile sections)
  • "apigee.profile"
  • "apigee.env"
  • "apigee.hosturl"
  • "apigee.org"
  1. The contents of "apigee.profile", "apigee.env", and "id" elements should match the profile the customer wants to use and is matched with environment name.
  2. The value of the "apigee.hosturl" element should match the value in the example if the customer is an enterprise cloud user.
    • If the customer is an private cloud user, this url would be the location of the customer's management server host and port. The port is 8080 by default.
  3. The value of the "apigee.org" element should match the organization provided when Customer environment was initially setup, in most cases this includes the name of the company.
    • For private cloud installations, the org is setup when you run installation scripts. The Maven group id is malleable and is also marked in red for both pom examples, the only thing to note when changing this is that they need to be consistent between applications.

Building Shared Flow bundles

What is a Shared Flow bundle?

Shared Flow bundles can be described as a zipped file system composed of policies, steps and code. The file system when extracted is composed of the following structure.

 |-sharedflowbundle/
   |-policies
   |-sharedflows

The build steps and the options available for building and deploying Shared Flows are the same as API Proxy. The samples has an example of a standard sharedflow with the folder structure and the parent pom file. The only key difference between the API Proxy and the Shared Flow is a new property as part of the profiles.

<apigee.apitype>sharedflow</apigee.apitype>

This is required to differentiate the build and deployment process.

To configure a proxy

Supported from v2.5.0

Please refer to this doc that explains how to setup proxy settings in your settings.xml usually in your $HOME/.m2 directory. Only https protocol is supported


Recommended Convention for Contributions

Refer Guide for Plugin Developers

People Involved

The plugin is initially developed by Santany Dey. With major contributions from Sai Saran Vaidyanathan, Madhan Sadasivam. The plugin is open sourced by Priyanky Thomas.

Support

Issues filed on Github are not subject to service level agreements (SLAs) and responses should be assumed to be on an ad-hoc volunteer basis. The Apigee community board is recommended as for community support and is regularly checked by Apigee experts.

Apigee customers should use formal support channels for Apigee product related concerns.

Disclaimer

This is not an officially supported Google product.

apigee-deploy-maven-plugin's People

Contributors

alanwill avatar annappagk avatar dancer1325 avatar davepickard1234 avatar davidwallen avatar dependabot[bot] avatar dzuluaga avatar ericdahl avatar masterspambot avatar micovery avatar mikeleaver avatar msadasivam avatar owensc avatar priyanky avatar rakeshtl avatar seantdg avatar senthildk avatar shehanp avatar sriki77 avatar ssvaidyanathan avatar sudheesreedhara avatar tschaible avatar wwitman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apigee-deploy-maven-plugin's Issues

Proxy name should be customizable and not tied directly to project.name

We occasionally like to deploy copies of proxies under different names for testing in a dev environment.

Unfortunately, this plugin seems to only allow the proxy name to be the same as the maven project name. There's no way to override the proxy name. Wouldn't it be more consistent to have the proxy name be defined in a property like apigee.env or apigee.org ? Or at least have it be overrideable via a flag?

Installing proxy with java resource file fails to deploy

Related article on Apigee community:
Community article

The proxy gets uploaded but fails to deploy with following error:
POST https://api.enterprise.apigee.com/v1/organizations/ORGNAME/environments/dev/apis/PROXYNAME-v1/revisions/2/deployments accept: application/json accept-encoding: gzip authorization: Basic [Not shown in log] [ERROR] 500 Server Error { "code" : "messaging.runtime.CouldNotExtractJavaResource", "message" : "Could not extract the java resource hmac-edge-callout1.jar", "contexts" : [ ], "cause" : { "message" : "/var/tmp/hmac-edge-callout1.jar_tempResourceDir6768640312569901831.tmp/hmac-edge-callout1.jar (Is a directory)", "contexts" : [ ] } }

Downloading the proxy bundle reveals that the size of the jar file grew from 7K to 11K.

Stack trace:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:1.0.0:deploy (deploy-bundle-step) on project bankcard-v1: at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at org.apache.maven.cli.MavenCli.main(MavenCli.java:199) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.MojoExecutionException: at io.apigee.buildTools.enterprise4g.mavenplugin.DeployMojo.processHelpfulErrorMessage(DeployMojo.java:343) at io.apigee.buildTools.enterprise4g.mavenplugin.DeployMojo.execute(DeployMojo.java:328) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) ... 20 more Caused by: java.io.IOException: com.google.api.client.http.HttpResponseException: 500 Server Error { "code" : "messaging.runtime.CouldNotExtractJavaResource", "message" : "Could not extract the java resource hmac-edge-callout1.jar", "contexts" : [ ], "cause" : { "message" : "/var/tmp/hmac-edge-callout1.jar_tempResourceDir6768640312569901831.tmp/hmac-edge-callout1.jar (Is a directory)", "contexts" : [ ] } } at io.apigee.buildTools.enterprise4g.rest.RestUtil.activateBundleRevision(RestUtil.java:641) at io.apigee.buildTools.enterprise4g.rest.RestUtil.refreshBundle(RestUtil.java:546) at io.apigee.buildTools.enterprise4g.mavenplugin.DeployMojo.doRefreshBundle(DeployMojo.java:210) at io.apigee.buildTools.enterprise4g.mavenplugin.DeployMojo.execute(DeployMojo.java:299) ... 22 more Caused by: com.google.api.client.http.HttpResponseException: 500 Server Error { "code" : "messaging.runtime.CouldNotExtractJavaResource", "message" : "Could not extract the java resource hmac-edge-callout1.jar", "contexts" : [ ], "cause" : { "message" : "/var/tmp/hmac-edge-callout1.jar_tempResourceDir6768640312569901831.tmp/hmac-edge-callout1.jar (Is a directory)", "contexts" : [ ] } }

config.json does not substitute empty nodes

Trying to set the OAuth scope dynamically, I am using the following replacement instructions:

        {
            "name": "verify-oauth-v2-access-token.xml",
            "tokens": [{
                "xpath": "/OAuthV2/Scope",
                "value": "urn:hp:api:ems:send_email urn:hp:api:ems:set_template"
            }]
        }

The source XML to substitute is:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OAuthV2 async="false" continueOnError="false" enabled="true" name="verify-oauth-v2-access-token">
    <DisplayName>Verify OAuth v2.0 Access Token</DisplayName>
    <Operation>VerifyAccessToken</Operation>
    <Scope></Scope>
</OAuthV2>

Substitution works if and only if the original node value is non-empty (eg. <Scope>undefined</Scope>), which it should work with:

  1. No <Scope/> defined in the initial document (DOES NOT WORK)
  2. An empty <Scope/> or <Scope></Scope> defined in the source document (DOES NOT WORK)
    3 A non-empty <Scope>something</Scope> defined in the source document (WORKS)

apigee-edge-maven-plugin:jar not found on mvn install

I am seeing the following error after executing mvn install from directory samples/forecastweatherapi-recommended/src/gateway/forecastweatherapi

[ERROR] Plugin io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:1.1.2-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:jar:1.1.2-SNAPSHOT -> [Help 1]

Also, I see the dependency exists on the central repository [http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22io.apigee.build-tools.enterprise4g%22]

deployment to test environment overrides deployment to production

How to reproduce:

  1. following profile definitions:
<profile>
    <id>test</id>
    <properties>
        <apigee.profile>test</apigee.profile>
        <apigee.env>test</apigee.env>
        <apigee.hosturl>https://api.enterprise.apigee.com</apigee.hosturl>
        <apigee.apiversion>v1</apigee.apiversion>
        <apigee.org>${env.APIGEE_ORG}</apigee.org>
        <apigee.username>${env.APIGEE_USERNAME}</apigee.username>
        <apigee.password>${env.APIGEE_PASSWORD}</apigee.password>
        <apigee.options>update</apigee.options>
    </properties>
</profile>
<profile>
    <id>prod</id>
    <properties>
        <apigee.profile>prod</apigee.profile>
        <apigee.env>prod</apigee.env>
        <apigee.hosturl>https://api.enterprise.apigee.com</apigee.hosturl>
        <apigee.apiversion>v1</apigee.apiversion>
        <apigee.org>${env.APIGEE_ORG}</apigee.org>
        <apigee.username>${env.APIGEE_USERNAME}</apigee.username>
        <apigee.password>${env.APIGEE_PASSWORD}</apigee.password>
        <apigee.options>override</apigee.options>
        <apigee.override.delay>5</apigee.override.delay>
    </properties>
</profile>
  1. deploy to production environment - creates revision 1 in production environment
  2. deploy to test environment - updates revision 1

In step 3, I see the following output from maven:

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


[INFO]


Request prepared for the server
 **************************
GET  https://api.enterprise.apigee.com/v1/organizations/oseymen/apis/currency-v1/
accept: application/json
accept-encoding: gzip
authorization: Basic [Not shown in log]
[INFO]


Response returned by the server
 **************************
200  OK
accept-encoding: gzip
content-length: 233
content-type: application/json
date: Sun, 12 Jun 2016 19:35:47 GMT
access-control-allow-headers: [origin, x-requested-with, accept]
access-control-allow-origin: [*]
access-control-max-age: [3628800]
access-control-allow-methods: [GET, PUT, POST, DELETE]
connection: [keep-alive]
server: [Apigee Router]
{
  "name": "currency-v1",
  "revision": [
    "1"
  ]
}
[INFO] Latest Revision: 1
[INFO] Updating Latest Revision: 1
[INFO]

=============Updating App================


[INFO]


Request prepared for the server
 **************************
POST  https://api.enterprise.apigee.com/v1/organizations/oseymen/apis/currency-v1/revisions/1?validate=true
accept: application/json
accept-encoding: gzip
authorization: Basic [Not shown in log]
content-type: application/octet-stream
 [Request body contains data, not shown]

[INFO]


Response returned by the server
 **************************
200  OK
accept-encoding: gzip
content-length: 827
content-type: application/json
date: Sun, 12 Jun 2016 19:35:51 GMT
access-control-allow-headers: [origin, x-requested-with, accept]
access-control-allow-origin: [*]
access-control-max-age: [3628800]
access-control-allow-methods: [GET, PUT, POST, DELETE]
connection: [keep-alive]
server: [Apigee Router]
{
  "configurationVersion": {
    "majorVersion": 4,
    "minorVersion": 0
  },
  "contextInfo": "Revision 1 of application currency-v1, in organization oseymen",
  "createdAt": 1465759479195,
  "createdBy": "[email protected]",
  "lastModifiedAt": 1465760149767,
  "lastModifiedBy": "[email protected]",
  "policies": [
    "AssignMessage.SetTargetResource",
    "JavaScript.ConfigureTargetRequest"
  ],
  "proxyEndpoints": [
    "default"
  ],
  "resources": [
    "jsc://ConfigureTargetRequest.js"
  ],
  "revision": "1",
  "targetEndpoints": [
    "default"
  ],
  "targetServers": [],
  "type": "Application"
}

Note the following lines:

[INFO] Latest Revision: 1
[INFO] Updating Latest Revision: 1

when deploying to test, I'd expect plugin to look for the latest revision of the proxy in "test" environment.
Version 1.0.0 does not have this problem.

Error while configuring CI and deployment to Apigee

ERROR] BUILD ERROR

[INFO] ------------------------------------------------------------------------

[INFO] Failed to configure plugin parameters for: io.apigee.build-tools.enterpri se4g:apigee-edge-maven-plugin:1.0.3 Cause: Cannot assign value '' to field: io.apigee.buildTools.enterprise4g.maven plugin.DeployMojo.buildOption; type: java.lang.String

For detail error description and my pom files:
https://community.apigee.com/questions/27421/error-while-configuring-ci-and-deployment-to-apige.html

Issue deploying with bamboo using maven plugin

Issue deploying with bamboo using maven plugin.

build 19-Apr-2016 18:46:09 Request prepared for the server
build 19-Apr-2016 18:46:09 **************************
build 19-Apr-2016 18:46:09 POST https://:443/v1/organizations/internal/apis?action=import&name=forecastweatherapi
build 19-Apr-2016 18:46:09 accept: application/json
build 19-Apr-2016 18:46:09 accept-encoding: gzip
build 19-Apr-2016 18:46:09 authorization: Basic [Not shown in log]
build 19-Apr-2016 18:46:09 content-type: application/octet-stream
build 19-Apr-2016 18:46:09 [Request body contains data, not shown]
build 19-Apr-2016 18:46:09
build 19-Apr-2016 18:46:09 18:46:09,223 ERROR RestUtil:397 - 400 Bad Request
build 19-Apr-2016 18:46:09 {
build 19-Apr-2016 18:46:09 "code" : "messaging.config.beans.InvalidBundle",
build 19-Apr-2016 18:46:09 "message" : "Bundle is invalid. Unable to read/find APIProxy contents",
build 19-Apr-2016 18:46:09 "contexts" : [ ]
build 19-Apr-2016 18:46:09 }
build 19-Apr-2016 18:46:09 18:46:09,223 ERROR DeployMojo:367 -
build 19-Apr-2016 18:46:09
build 19-Apr-2016 18:46:09
build 19-Apr-2016 18:46:09 * * * * * * * * * * *
build 19-Apr-2016 18:46:09
build 19-Apr-2016 18:46:09 This deployment could have failed for a variety of reasons.
build 19-Apr-2016 18:46:09
build 19-Apr-2016 18:46:09
build 19-Apr-2016 18:46:09
build 19-Apr-2016 18:46:09 * * * * * * * * * * *

Proxy display name and the description

Reported by customer:

While deploying the proxy, I can update information in /proxies and /targets directories using config.json file.

Is there any way to update the information in the proxy xml file, such as Proxy name and Description?

It does not seem to be using my proxy xml file.
Here is the file:

1400771316457 [email protected] 1234 mb139h_core_image 1400771316458 [email protected] default default false

And here is what it creates:

And the more time I re-deploy the code, the longer description becomes. Each time I get a new “::mb139h git revision unknown NJCDTL02MB139H” appended.

I’d like to be able to control the proxy display name and the description.
image001

Profile should not be part of the artifact name or optional

Currently, the artifact name contains the profile name (in this example "test"):

forecastweatherapi1.0-test.zip

But in the case of Release Automation, you will generate a generic artifact which will then be parameterized at deployment time. Artifacts will not be deployed from within maven. If one generated the package without a profile, the name whould be:

forecastweatherapi1.0-null.zip

I propose to not include the profile name if empty or null. This whould enable both options:

a) Deploy into the local dev environment with maven (artifact contains -dev.zip)
b) Create an artifact and store it in the repository for release automation (artifact without profile name)

MFA on org level

Hi guys

I got feedback from one customer saying that the plugin doesn't work if mfa is enabled for the whole org.

Do you have any test cases for that? Support can enable MFA for an entire org for you.

Override Delay is Hardcoded for 5 seconds

There is an option in the shared pom for apigee.override.delay, but the following code seems to ignore this and always use 5 seconds:

line 577 apigee-deploy-maven-plugin/src/main/java/io/apigee/buildTools/enterprise4g/rest/RestUtil.java

if (Options.override) {
    GenericData data = new GenericData();
    data.set("override", "true");
    data.set("delay", "5");
    urlEncodedContent = new UrlEncodedContent(data);
 }

Add XML elements through config.json file

Hi,

I want to add and remove some xml elements during the deployment to api using maven plugin. As each value is parsed as text, tags are converted into characters. Is there way to pass XML elements in value field of config.json configuration.

Regards,
Kalmesh.

Archetype missing from the plugin

Hi everybody,

Thanks for opening this to the community!

Few observations I found while testing it, which have been documented Google docs (internally) shared and authored by Steve Richardson.

I tried removing any references to http://repo.apigee.com:8081/artifactory/repo from settings.xml to use the open sourced version, but creating the project using the following command command didn't work:

mvn archetype:generate -DarchetypeGroupId=apigee -DarchetypeArtifactId=Customer-Root-archetype -DarchetypeVersion=3.0 -DarchetypeCatalog=local -DinteractiveMode=false -Dversion=1.0 -DgroupId=apigee -DartifactId=name-of-root(typically company name) -DorgName=Your_Customer_ORG_Name -DorgUserId=your-user-id -DorgPassword=changeit

Based on the command above, I discovered the archetype resides in a different jar than the maven deployment plugin.

http://repo.apigee.com:8081/artifactory/repo/apigee/Customer-Root-archetype/3.0/

Do you happen to know if there's any plan open source or even to integrate that one into the same maven-deploy plugin?

As a workaround, users with access to Apigee Artifactory can still generate the project structure and edit a few files such as parent pom.xml. However, for users without access to artifactory, I'd suggest creating manually the directory structure along with any other files. Do you have any other suggestions?

Regards,
Diego

Missing dash between the artifact name and the version

Normally, there is a dash in between the artifact name and the version. Normally means, that you will not found any artifacts wihtout this naming pattern. Currently, the artifacts will be created like this:

forecastweatherapi1.0-test.zip

But it should be:

forecastweatherapi-1.0-test.zip

Delpoying Proxies Behind a Proxy

I was having issues using the maven deploy plugin when behind an NTLM proxy, doesn't seem to be a maven issue as adding proxy username and password to settings.xml didn't resolve the issue. The deployment was hanging when trying to get the revisions.

Looking through the code in RestUtil doesn't take into account any proxy information in the HttpTransport.

MASSL support

Ability to use client certificate authentication.

Change the update implementation of the plugin to use alternate set of API calls for deployment of proxy

The current API call used to update a given version of the proxy is the following.

POST https://api.enterprise.apigee.com/v1/organizations/<org name>/apis?action=import&name=<apiproxy name>&validate=true

This API is a heavy weight call that results in timeout on Edge. We need to change the implementation to use alternate set of API calls (split the single call) to achieve the same result. These API calls should undeploy,update and deploy the new version of the code.

OAuth2 API calls

I see that Apigee are looking to remove basic authentication to the management API's and replace it with OAuth2; is there a plan to update the Maven plug in to use OAuth2?

Description should be set even if there's no config.json

My proxy doesn't have any variables so I don't use a config.json. This seems to work fine. But, the deployed proxy Description is empty and lacking the useful git commit information which would otherwise be present if I had an empty config.json

It would be nice to not require a config.json to get this git commit info the the proxy description

Multibundle project - Usage of <skip> option for parent pom

I have created a multi api bundle project in order to automate the deployment of my APIs. In doing so, I took as example the Apigee Grass project.

The difference lies in that I have tried to eliminate any redundancies between the parent pom and the children pom files. Ideally the children pom files would be empty unless they had to override something in particular, while the parent pom would have all the build configuration (plugins, goals, executions) as this build process is going to be the same for all the modules (unless tailored for rare cases within the children poms).

Now, I tried to do this by putting all the build configuration in the parent pom with a particular detail that the apigee-edge-maven-plugin for this module (the parent one) would have to be skipped as this is not a deployable bundle but just the aggregation specification and build configuration for all the children.
That said, the children poms would have to override this tiny piece so that it was not skipped.

Hence my pom files looked like this:

Parent pom

<?xml version="1.0"?>
<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>my.company.com</groupId>
  <artifactId>parent-pom</artifactId>
  <packaging>pom</packaging>
  <version>1.0</version>
  <pluginRepositories>

  </pluginRepositories>
  <modules>
    <module>../child_1</module>
   <!--...-->
    <module>../child_n</module>
  </modules>

  <build>
    <plugins>

      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <execution>
            <id>auto-clean</id>
            <phase>initialize</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.0.1</version>
        <executions>
          <execution>
            <id>copy-resources-step</id>
            <phase>package</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <!-- this is important -->
              <overwrite>true</overwrite>
              <!-- target -->
              <outputDirectory>${basedir}/target/apiproxy</outputDirectory>
              <resources>
                <resource>
                  <!-- source -->
                  <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>
        <configuration>
          <skip>true</skip> <!-- Use this module level config to skip module build. Make it true -->
        </configuration>
        <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>

</project>

Any child 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">
  <parent>
    <groupId>my.company.com</groupId>
    <artifactId>parent-pom</artifactId>
    <version>1.0</version>
    <relativePath>../parent-pom/pom.xml</relativePath>
  </parent>

  <modelVersion>4.0.0</modelVersion>
  <groupId>my.company.com</groupId>
  <artifactId>child_1</artifactId>
  <version>1.0</version>
  <name>child_1</name>
  <packaging>pom</packaging>

  <build>
    <plugins>

      <plugin>
        <groupId>io.apigee.build-tools.enterprise4g</groupId>
        <artifactId>apigee-edge-maven-plugin</artifactId>
        <configuration>
          <skip>false</skip> <!-- Use this module level config to skip module build. Make it true -->
        </configuration>
      </plugin>

    </plugins>
  </build>

</project>

This approach does not work as it seems that the apigee-edge-maven-plugin is not skipped for the parent project/pom: so it tries to import/deploy something that it is not an API bundle causing the build to fail:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.261 s
[INFO] Finished at: 2016-08-16T10:24:29+12:00
[INFO] Final Memory: 13M/276M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:1.0.3:deploy (deploy-bundle) on project parent-pom: MojoExecutionException: 400 Bad Request
[ERROR] {
[ERROR] "code" : "messaging.config.beans.InvalidBundle",
[ERROR] "message" : "Bundle is invalid. Unable to read/find APIProxy contents",
[ERROR] "contexts" : [ ]
[ERROR] }
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:1.0.3:deploy (deploy-bundle) on project parent-pom:
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException:
        at io.apigee.buildTools.enterprise4g.mavenplugin.DeployMojo.processHelpfulErrorMessage(DeployMojo.java:373)
        at io.apigee.buildTools.enterprise4g.mavenplugin.DeployMojo.execute(DeployMojo.java:358)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
        ... 20 more
Caused by: java.io.IOException: 400 Bad Request
{
  "code" : "messaging.config.beans.InvalidBundle",
  "message" : "Bundle is invalid. Unable to read/find APIProxy contents",
  "contexts" : [ ]
}
        at io.apigee.buildTools.enterprise4g.rest.RestUtil.uploadBundle(RestUtil.java:398)
        at io.apigee.buildTools.enterprise4g.mavenplugin.DeployMojo.doImport(DeployMojo.java:159)
        at io.apigee.buildTools.enterprise4g.mavenplugin.DeployMojo.execute(DeployMojo.java:283)
        ... 22 more
[ERROR]
[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

I worked around this problem by removing from the parent pom only the apigee-edge-maven-plugin entire section and putting it in all the children poms. Even though that there is not as much redundancy it still feels strange/not good having to do this.

Is there something I am not doing properly when using this configuration property?

Thanks in advance.

Configure happens twice with recommended pom configuration.

When you configure the execution in the pom file like the following:

<plugin>
   <groupId>io.apigee.build-tools.enterprise4g</groupId>
   <artifactId>apigee-edge-maven-plugin</artifactId>
   <version>1.0.0</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>

packaging occurs twice and you'll see duplicate log statements zipping the app bundle. The deploy goal executes the package phase again and is also configured for package phase.

Node support

Does this plugin support Node.js deployments to Apigee Edge.
If yes where can we find relevant documentation

allow plugin to accept a bearer token as a parameter

I would like to allow plugin to accept a bearer token as a parameter. This way, clients that have special MFA requirements (e.g. the tokens are expiring as in Issue 59) can generate the bearer token in a different plugin as the first step, and provide it as a parameter.

Assertion fails when management API call returns 2 deployed revisions

There is a valid scenario where 2 or more revisions could be deployed in the same env for a proxy given that their basepaths are different. In such a setup, seamless deployment using the plugin would fail as it asserts only against the first revision returned by the management server . The fix would need the plugin to loop through all the returned revisions and validate against the same.

CODE Archetype to create project and bundle

Based on a conversation with @sriki77, @Priyanky, @rakeshtl it'd be nice to have an artifact utility for:

  • Initializing the project for instance mvn initialize project-name creates the basic structure for the project following standards
  • Initializing api proxy bundles mvn initproxy proxy-name creates the basic api bundle structure

Deploy does not deploy all javascript resources

I am trying to deploy a proxy that has 12 jsc resources. All of the resources are accounted for in the proxy.xml.

this is what I am seeing
[ERROR] 400 Bad Request
{
"code" : "messaging.config.beans.InvalidResourceURLRef",
"message" : "Invalid resource url ref jsc://js_memberInfoHash.js in policy js_hashMemberInfo in cambiahealth-nonprod",
"contexts" : [ ],
"cause" : {
"code" : "messaging.config.beans.ResourceDoesNotExist",
"message" : "Resource with name js_memberInfoHash.js and type jsc does not exist",
"contexts" : [ ]
}
}
I have check numerous times and the file is there. it will deploy via the gui.

This is the proxy giving me trouble

js_hashMemberInfo jsc://js_memberInfoHash.js jsc://js_MD5.js

i notice that this policy has an includeURL, not sure if that is throwing off the count.

Hoping this is a know issue with an easy work around, I don't want to had deploy these.

JavaScript Policy if not referred fails deployment

JavaScript policy is added in policies and corresponding resource is created and kept in proxy bundle but not referred in any flow , then the deployment fails stating the resource reference is invalid.

Deployment through jenkins failed after the config.json is executed

Hi All,

when i am doing the build through jenkins, the job is failing with FileNotFoundException after the config.json is executed (if i dont use the config.json, build and deployment has no issues).

@ssvaidyanathan - i was refering to https://community.apigee.com/questions/28281/maven-deployment-plugin-deployment-error.html but didn't find the answer. i am facing the same issue. can you please help me in this?

below are the logs:
error.txt

Maven deploy failing due to resource not found

When I am trying to deploy using maven plugin, my deploy is failing with following error.

accept: application/json
accept-encoding: gzip
authorization: Basic [Not shown in log]
[ERROR] 404 Not Found
{
"code" : "messaging.config.beans.ResourceDoesNotExist",
"message" : "Resource with name processHL7-add-namespace.xslt and type xsl does not exist",
"contexts" : [ ]
}

is there any workaround?

We have this in our pom.xml

maven-resources-plugin 2.6 copy-resources package copy-resources true ${target.root.dir}/apiproxy ${project.root.dir}/apiproxy

Support for Refresh Tokens

Along with support for Bearer Token, needs enhancement to pass refresh token as well, so that if the bearer token is invalid, the refresh token can be used to generate a new access token and continue with the build process

apigee-edge-maven-plugin:1.0.3 restarts maven lifecycle

Here is an excerpt from maven output where all lifecycle stages before maven execution is repeated once apigee-edge-maven-plugin is initiated:

Note before/after of this line:

[INFO] >>> apigee-edge-maven-plugin:1.0.3:deploy (deploy-bundle-step) > package @ currency-v1 >>>
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building currency-oseymenv1 -
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- jshint-maven-plugin:1.6.0:lint (jslint) @ currency-v1 ---
[INFO] using jshint version 2.5.6
[INFO]   /Users/oseymen/projects/prof/apigee/accelerator-ci-maven/currency-v1/apiproxy/resources/jsc/ConfigureTargetRequest.js
[INFO]   /Users/oseymen/projects/prof/apigee/accelerator-ci-maven/currency-v1/apiproxy/resources/jsc/LogToLoggly.js
[INFO]
[INFO] --- exec-maven-plugin:1.3.2:exec (unit) @ currency-v1 ---


  feature: loggly integration
    ✓ should push target error response data to loggly


  1 passing (32ms)

[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (auto-clean-init) @ currency-v1 ---
[INFO] Deleting /Users/oseymen/projects/prof/apigee/accelerator-ci-maven/currency-v1/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:copy-resources (copy-resources) @ currency-v1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 32 resources
[INFO]
[INFO] --- replacer:1.5.2:replace (default) @ currency-v1 ---
[INFO] Replacement run on 3 files.
[INFO]
[INFO] --- exec-maven-plugin:1.3.2:exec (npm-install) @ currency-v1 ---
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No license field.
[INFO]
[INFO] --- apigee-edge-maven-plugin:1.0.3:configure (configure-bundle-step) @ currency-v1 ---
[INFO] No config.json found. Skipping package configuration.
[INFO]

=============Checking for node.js app================


[INFO]

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


[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ currency-v1 ---
[INFO] Installing /Users/oseymen/projects/prof/apigee/accelerator-ci-maven/currency-v1/pom.xml to /Users/oseymen/.m2/repository/apigee/currency-v1/-/currency-v1--.pom
[INFO]
[INFO] >>> apigee-edge-maven-plugin:1.0.3:deploy (deploy-bundle-step) > package @ currency-v1 >>>
[INFO]
[INFO] --- jshint-maven-plugin:1.6.0:lint (jslint) @ currency-v1 ---
[INFO] using jshint version 2.5.6
[INFO]   /Users/oseymen/projects/prof/apigee/accelerator-ci-maven/currency-v1/apiproxy/resources/jsc/ConfigureTargetRequest.js
[INFO]   /Users/oseymen/projects/prof/apigee/accelerator-ci-maven/currency-v1/apiproxy/resources/jsc/LogToLoggly.js
[INFO]
[INFO] --- exec-maven-plugin:1.3.2:exec (unit) @ currency-v1 ---


  feature: loggly integration
    ✓ should push target error response data to loggly


  1 passing (33ms)

[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (auto-clean-init) @ currency-v1 ---
[INFO] Deleting /Users/oseymen/projects/prof/apigee/accelerator-ci-maven/currency-v1/target

Suspect logic with string == "" in configurePackage

In configurePackage, is this block of code:

if (super.getProfile().getProfileId() != null && super.getProfile().getProfileId() != "") {
    PackageConfigurer.configurePackage(super.getProfile().getProfileId(), configFile);
} else {
    PackageConfigurer.configurePackage(super.getProfile().getEnvironment(), configFile);
}

The literal string compare to "" means that the else won't be executed.

That said, I'm not sure what the difference is between apigee.profile and apigee.environment

support for optimized node deployment

API bundles with multiple node modules cause timeouts during deployment. Can we upload them separately or use management API to do a post-upload install.

Improper Deployment Status

During deployment of the API Proxy using the apigee deploy maven plugin, we realised that one of the MPs in the env was down. The api proxy activation response shows the state as error, but still the build response is "Build Success".
From a layman point of view this is not correct, as the response of deployment is success, but when the APIX Proxy is retrieved on Edge UI, it shows Error Marks in it.
Therefore, would it be possible to read the State Parameter at the body of the activation response and based on that decide the final status of deployment. May be we can add something like "Partial Success".
Due to proprietary commitments, I can't attach the logs here, but here is the snap with masked values.

build 23-Jun-2016 22:11:27 POST https://api.enterprise.apigee.com/v1/organizations/XXX/environments/prod/apis/XXX/revisions/35/deployments
build 23-Jun-2016 22:11:27 accept: application/json
build 23-Jun-2016 22:11:27 accept-encoding: gzip
build 23-Jun-2016 22:11:27 authorization: Basic [Not shown in log]
build 23-Jun-2016 22:11:53 [INFO]
build 23-Jun-2016 22:11:53
build 23-Jun-2016 22:11:53
build 23-Jun-2016 22:11:53 Response returned by the server
build 23-Jun-2016 22:11:53 **************************
build 23-Jun-2016 22:11:53 200 OK
build 23-Jun-2016 22:11:53 accept-encoding: gzip
build 23-Jun-2016 22:11:53 content-encoding: gzip
build 23-Jun-2016 22:11:53 content-length: 457
build 23-Jun-2016 22:11:53 content-type: application/json
build 23-Jun-2016 22:11:53 date: Fri, 24 Jun 2016 02:11:53 GMT
build 23-Jun-2016 22:11:53 server: [Apigee Router]
build 23-Jun-2016 22:11:53 access-control-allow-origin: [*]
build 23-Jun-2016 22:11:53 access-control-allow-methods: [GET, PUT, POST, DELETE]
build 23-Jun-2016 22:11:53 connection: [keep-alive]
build 23-Jun-2016 22:11:53 access-control-max-age: [3628800]
build 23-Jun-2016 22:11:53 access-control-allow-headers: [origin, x-requested-with, accept]
build 23-Jun-2016 22:11:53 {
build 23-Jun-2016 22:11:53 "aPIProxy": "XXX",
build 23-Jun-2016 22:11:53 "configuration": {
build 23-Jun-2016 22:11:53 "basePath": "/",
build 23-Jun-2016 22:11:53 "steps": []
build 23-Jun-2016 22:11:53 },
build 23-Jun-2016 22:11:53 "environment": "prod",
build 23-Jun-2016 22:11:53 "name": "35",
build 23-Jun-2016 22:11:53 "organization": "XXX",
build 23-Jun-2016 22:11:53 "revision": "35",
build 23-Jun-2016 22:11:53 "state": "error",
build 23-Jun-2016 22:11:53 "server": [
build 23-Jun-2016 22:11:53 {
build 23-Jun-2016 22:11:53 "status": "error",
build 23-Jun-2016 22:11:53 "type": [
build 23-Jun-2016 22:11:53 "message-processor"
build 23-Jun-2016 22:11:53 ],
build 23-Jun-2016 22:11:53 "uUID": "XXX"
build 23-Jun-2016 22:11:53 },
build 23-Jun-2016 22:11:53 {
build 23-Jun-2016 22:11:53 "status": "deployed",
build 23-Jun-2016 22:11:53 "type": [
build 23-Jun-2016 22:11:53 "message-processor"
build 23-Jun-2016 22:11:53 ],
build 23-Jun-2016 22:11:53 "uUID": "6XXX"
build 23-Jun-2016 22:11:53 },
build 23-Jun-2016 22:11:53 {
build 23-Jun-2016 22:11:53 "status": "deployed",
build 23-Jun-2016 22:11:53 "type": [
build 23-Jun-2016 22:11:53 "router"
build 23-Jun-2016 22:11:53 ],
build 23-Jun-2016 22:11:53 "uUID": "XXX"
build 23-Jun-2016 22:11:53 },
build 23-Jun-2016 22:11:53 {
build 23-Jun-2016 22:11:53 "status": "deployed",
build 23-Jun-2016 22:11:53 "type": [
build 23-Jun-2016 22:11:53 "router"
build 23-Jun-2016 22:11:53 ],
build 23-Jun-2016 22:11:53 "uUID": "XXX"
build 23-Jun-2016 22:11:53 },
build 23-Jun-2016 22:11:53 {
build 23-Jun-2016 22:11:53 "status": "deployed",
build 23-Jun-2016 22:11:53 "type": [
build 23-Jun-2016 22:11:53 "router"
build 23-Jun-2016 22:11:53 ],
build 23-Jun-2016 22:11:53 "uUID": "XXX"
build 23-Jun-2016 22:11:53 },
build 23-Jun-2016 22:11:53 {
build 23-Jun-2016 22:11:53 "status": "deployed",
build 23-Jun-2016 22:11:53 "type": [
build 23-Jun-2016 22:11:53 "router"
build 23-Jun-2016 22:11:53 ],
build 23-Jun-2016 22:11:53 "uUID": “XXX”
build 23-Jun-2016 22:11:53 },
build 23-Jun-2016 22:11:53 {
build 23-Jun-2016 22:11:53 "status": "deployed",
build 23-Jun-2016 22:11:53 "type": [
build 23-Jun-2016 22:11:53 "router"
build 23-Jun-2016 22:11:53 ],
build 23-Jun-2016 22:11:53 "uUID": "XXX"
build 23-Jun-2016 22:11:53 }
build 23-Jun-2016 22:11:53 ]
build 23-Jun-2016 22:11:53 }
build 23-Jun-2016 22:11:53 [INFO]
build 23-Jun-2016 22:11:53 Deployed revision is: 35
build 23-Jun-2016 22:11:53 [INFO] ------------------------------------------------------------------------
build 23-Jun-2016 22:11:53 [INFO] BUILD SUCCESS
build 23-Jun-2016 22:11:53 [INFO] ------------------------------------------------------------------------
build 23-Jun-2016 22:11:53 [INFO] Total time: 55.753 s
build 23-Jun-2016 22:11:53 [INFO] Finished at: 2016-06-23T22:11:53-04:00
build 23-Jun-2016 22:11:53 [INFO] Final Memory: 14M/170M
build 23-Jun-2016 22:11:53 [INFO] ------------------------------------------------------------------------
simple 23-Jun-2016 22:11:53 Finished task 'deploy apigee enterprise service' with result: Success
simple 23-Jun-2016 22:11:53 Starting task 'mvn clean' of type 'XXX'
simple 23-Jun-2016 22:11:53 Cleaning working directory ‘XXX’
simple 23-Jun-2016 22:11:53 Finished task 'mvn clean' with result: Success
simple 23-Jun-2016 22:11:53 Finalising the build...
simple 23-Jun-2016 22:11:53 Stopping timer.
simple 23-Jun-2016 22:11:53 Build XXX completed.
simple 23-Jun-2016 22:11:53 Finished processing deployment result Deployment of XXX on 'Prod'

Issue while deploying bundle using maven plugin

Hi,

I have created a maven application for building and deploying api bundle. Followed steps given in document. I am facing below issues. Can someone help please...?

  1. Deploying new proxy: If I am deploying proxy for the first time (that means there is no existing proxy available Apigee Edge). Apigee api web link returns error message as below:

GET https://api.enterprise.apigee.com/v1/organizations/bdhanashetti/apis/json-formatter/deployments
accept: application/json
accept-encoding: gzip
authorization: Basic [Not shown in log]
[ERROR] 404 Not Found
{
"code" : "messaging.config.beans.ApplicationDoesNotExist",
"message" : "APIProxy named json-formatter does not exist in organization bdhanashetti",
"contexts" : [ ]

}

  1. Since I am facing above error, I have imported the ZIP file using UI application (this works wonderfully !!!). Then I have gone for re-deployment using maven deploy command. This command corrupts the proxy link. Error on proxy link says there is no revision attached to it (as shown in below image).

image

Here is link for the test project (https://github.com/basavarajdhanashetti/mands) for review.

Thanks,
Basavaraj

Proxy without Description causes NullPointerException

If a proxy xml file is missing its <Description>, then the plugin will fail with a NullPointerException despite the fact that the Description is supposed to be optional according to the documentation

This bug seems to be caused by this piece of code in PackageConfigurer:

javax.xml.xpath.XPathExpression expression = xpath.compile("/APIProxy/Description");

NodeList nodes = (NodeList) expression.evaluate(xmlDoc,
        XPathConstants.NODESET);

if (nodes.item(0).hasChildNodes()) {
    // sets the description to whatever is in the <proxyname>.xml file
    nodes.item(0).setTextContent(expression.evaluate(xmlDoc));
} else {

The stack trace (once I updated the code to include the exception cause):

$ mvn -X install ...
[ERROR] Failed to execute goal io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:1.0.2-SNAPSHOT:configure (configure-bundle) on project httpbin: null: MojoExecutionException: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:1.0.2-SNAPSHOT:configure (configure-bundle) on project httpbin: null
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException
        at io.apigee.buildTools.enterprise4g.mavenplugin.ConfigureMojo.configurePackage(ConfigureMojo.java:125)
        at io.apigee.buildTools.enterprise4g.mavenplugin.ConfigureMojo.execute(ConfigureMojo.java:51)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 19 more
Caused by: java.lang.NullPointerException
        at io.apigee.buildTools.enterprise4g.utils.PackageConfigurer.configurePackage(PackageConfigurer.java:161)
        at io.apigee.buildTools.enterprise4g.mavenplugin.ConfigureMojo.configurePackage(ConfigureMojo.java:119)
        ... 22 more

By the way, is there a reason why the plugin doesn't include a nested Exception cause when throwing MojoExecutionExceptions ? If it were included it would be easier to debug with maven's -X flag.

Another approach for implementing SAML support

Here is what I had in mind - I am not 100% if this is the best way to handle full automation so let's discuss:

get_token retrieves access and refresh tokens using passcode and stores them in a file called access_token.dat

So in maven pom:

  • run get_token with a passcode if access_token.dat is not found. This will persist access/refresh tokens in that file.

In maven plugin:

  • check access_token.dat to see if it contains access/refresh tokens. Use the access token, if it fails, use refresh token to get the new access token.
  • if file is empty or refresh token expired, return error asking an admin to run get_token with a passcode
  • use access token for all management api calls.

I am aware of relying on get_token command line is kinda shit but this seems to be the only way I can find to do this in fully automated fashion. Maven plugin itself could also run get_token executable but I guess it would be cleaner to run it outside the plugin in pom using exec plugin.

If refresh token expires in ~30 days, this should be enough for most people running deployment at least once a day.

MFA Code may have expired by the time the deploy plugin is trigger

Not sure how this could be resolved/documented, but we have the following issue:

If a project has a number of steps prior to deployment e.g. unit tests, js lint, proxy dependency plugin, node js zipping etc. then it is likely that the totp will have expired by the time the deployment happens.

At the minimum, we should document this so people understand why they are observing 403's for large projects.

http.nonProxyHosts is getting overridden by default with blank

In plugin apigee-deploy-maven-plugin, system property http.nonProxyHosts is getting overridden by default with blank, which need to be fixed. We need this property to be functioning as expected according to java proxy standards here (https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html)]

have done some debugging, and can see the GatewayAbstractMojo.fixOSXNonProxyHosts() method is getting called from every Mojo execute method, fixOSXNonProxyHosts method is overriding always the system variable http.nonProxyHosts. If this method should behave as mentioned in the code comment, it should at least check the OS type to override this value.


protected void fixOSXNonProxyHosts() {

    // This is required to work around a Mac OS X bug.  Probably would be better to be more selective about this.  Only override if we're
    // actually on OS X.  Or look at the value and only unset if it contains the problematic wildcard value.
    try {
           System.setProperty("http.nonProxyHosts", "");
    }
    catch (RuntimeException e) {
           // just try to continue
           getLog().error(e);
    }

}

[INFO] --- apigee-config-maven-plugin:1.1-SNAPSHOT:caches (create-config-cache) @ Dummy ---
[INFO] ************************************************************************
[INFO] Apigee Cache
[INFO] ************************************************************************
[DEBUG] Build option update
[DEBUG] Base dir xxxx
[DEBUG] Retrieving config from edge.json
[INFO] Retrieving existing environment caches - xxx
[DEBUG] Request
GET xxxxx
accept: application/json
accept-encoding: gzip
authorization: Basic [Not shown in log]
[ERROR] 503 Service Unavailable

<TITLE>Network Error</TITLE>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.