Closed dhanushyaselva closed 1 year ago
@dhanushyaselva - you will need to execute apigee-enterprise:configure
before apigee-enterprise:deploy
. The apigee-enterprise:configure
creates the Apigee proxy bundle (zip in your target directory) and then apigee-enterprise:deploy
picks that up and deploys it. In your case, since you are not calling configure, the zip is not in your target directory. Hence the deployment is failing.
Also - the latest version for this plugin with Apigee Edge/OPDK is v1.3.3
Please use that (just to use the latest) - update the version in your pom.xml
Hi @ssvaidyanathan thanks for the response.
Actually, I created a deployment pipeline in jenkins and i wanted to leverage the apigee maven plugin to deploy the artifact only. i have a separate plugin for builds. but, i was able to solve the above issue, after removing
however, providing
I also updated my version to 1.3.3. but the problem i am facing with this version is that the artifact created during build is appending environment name like projectname+version+profile name .zip
@ssvaidyanathan is there a way to remove profile name from artifact name ?
Yes - pls do not include the
Regarding the artifact name - can you confirm what you have in your pom. It uses the name you have configured for artifact
in your pom.xml. Change that it should fix the issue
Thanks for getting back quickly @ssvaidyanathan i tried multiple things cannot find the issue. the artifact gets appended with profile name .can you pls help here : Below are my two 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">
<groupId>com.***.api</groupId>
<artifactId>test-api-v1</artifactId>
<version>1.0.19-SNAPSHOT</version>
<name>test-api-v1</name>
<packaging>pom</packaging>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.***.api</groupId>
<artifactId>parent-pom</artifactId>
<version>1.0.0</version>
<relativePath>../parent-pom/pom.xml</relativePath>
</parent>
<scm>
<connection>scm:git:https://${bitbucket.domain}/bitbucket/scm/apip/${project.artifactId}-v1.git</connection>
<developerConnection>scm:git:https://${bitbucket.domain}/bitbucket/scm/apip/${project.artifactId}.git</developerConnection>
<url>https://${bitbucket.domain}/bitbucket/scm/apip/${project.artifactId}.git</url>
<tag>HEAD</tag>
</scm>
<distributionManagement>
<repository>
<id>releases</id>
<url>http://**/artifactory/libs-release-local/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://***/artifactory/libs-snapshot-local/</url>
</snapshotRepository>
</distributionManagement>
</project>
<?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>com.****.api</groupId>
<artifactId>parent-pom</artifactId>
<packaging>pom</packaging>
<version>1.0.0</version>
<modules>
<module>../apigee-artifact</module>
</modules>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>com.cj.jshintmojo</groupId>
<artifactId>jshint-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>jslint</id>
<phase>package</phase>
<goals>
<goal>lint</goal>
</goals>
</execution>
</executions>
<configuration>
<directories>
<directory>../apigee-artifact/apiproxy/resources/jsc</directory>
<!-- <directory>node</directory> -->
</directories>
<excludes>
<exclude>node/node_modules</exclude>
</excludes>
<reporter>html</reporter>
<reportFile>lintReport.html</reportFile>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${basedir}/target/apiproxy</outputDirectory>
<resources>
<resource>
<directory>apiproxy</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<id>Add Deployment Suffix to Base Path</id>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<basedir>${project.build.directory}/apiproxy/proxies/</basedir>
<includes>
<include>*.xml</include>
</includes>
<replacements>
<replacement>
<token>${basepath}</token>
<value>${basepath}${deploymentpath.delimiter}${deployment.suffix}</value>
</replacement>
</replacements>
</configuration>
</execution>
<execution>
<id>Replace-Description</id>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<basedir>${project.build.directory}/apiproxy</basedir>
<includes>
<include>*.xml</include>
</includes>
<replacements>
<replacement>
<xpath>/APIProxy/Description/text()</xpath>
<token>Release-Version:(\b\d{1,2}\.\d{1,2}\.\d{1,5}\b)</token>
<value>Release-Version:${deployment.version}</value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.apigee.build-tools.enterprise4g</groupId>
<artifactId>apigee-edge-maven-plugin</artifactId>
<version>1.3.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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<checkModificationExcludes>
<checkModificationExclude>src/gateway/apigee-artifact/build.sh</checkModificationExclude>
</checkModificationExcludes>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<deployment.delimiter>-</deployment.delimiter>
<deployment.suffix>${user.name}</deployment.suffix>
<deployment.version>${project.version}</deployment.version>
<main.basedir>${project.basedir}</main.basedir>
<groovy.version>2.5.14</groovy.version>
<sonar.host.url>http://localhost:9000</sonar.host.url>
<systemProp.sonar.host.url>http://localhost:9000</systemProp.sonar.host.url>
<sonar.login>place_holder_sonar_token_value</sonar.login>
<sonar.projectName>test-api-v1</sonar.projectName>
<sonar.projectKey>test-merchant-experience-api-v1</sonar.projectKey>
<sonar.exclusions>**/jenkins/**,**/helm/**"</sonar.exclusions>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.sources>./apiproxy</sonar.sources>
<sonar.sourceEncoding>UTF-8</sonar.sourceEncoding>
<sonar.branch.name>${branchName}</sonar.branch.name>
<sonar.scm.disabled>true</sonar.scm.disabled>
</properties>
<!-- 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.env>dev</apigee.env>
<apigee.hosturl>https://api.enterprise.apigee.com</apigee.hosturl>
<apigee.apiversion>v1</apigee.apiversion>
<apigee.org>**</apigee.org>
<!-- <apigee.revision>1</apigee.revision> -->
<apigee.username>${username}</apigee.username>
<apigee.password>${password}</apigee.password>
<apigee.options>override,update</apigee.options>
</properties>
</profile>
<profile>
<id>sandbox</id>
<properties>
<apigee.profile>sandbox</apigee.profile>
<apigee.env>sandbox</apigee.env>
<apigee.hosturl>https://api.enterprise.apigee.com</apigee.hosturl>
<apigee.apiversion>v1</apigee.apiversion>
<apigee.org>**</apigee.org>
<!-- <apigee.revision>1</apigee.revision> -->
<apigee.username>${username}</apigee.username>
<apigee.password>${password}</apigee.password>
<apigee.options>override,update</apigee.options>
</properties>
</profile>
<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>***</apigee.org>
<!-- <apigee.revision>1</apigee.revision> -->
<apigee.username>${username}</apigee.username>
<apigee.password>${password}</apigee.password>
<apigee.options>override,update</apigee.options>
</properties>
</profile>
</profiles>
</project>
the maven build command used is mvn -f pom.xml package -Pdev -Ddeployment.suffix= -Ddeploymentpath.delimiter=/ -Ddeployment.delimiter=- -Dbasepath=$APIGEE_API_BASE_PATH -Dapigee.host=$APIGEE_MGMT_API_HOST -Dusername=$APIGEE_CREDS_USR -Dpassword=$APIGEE_CREDS_PSW -Dorg=**** sonar:sonar -Dsonar.login=$sonar_login_token -Dsonar.branch.name=$branch_name
the artifactname created is test-api-v1-1.0.19-SNAPSHOT-dev.zip
few observations 1) Please dont include override, update together. Doesnt make sense.
Why is the profile id appended to the zip name an issue?
@ssvaidyanathan Thanks, point noted about the apigee.options. the development team is not satisfied with the naming convention as this will be the artifact deployed to PIT and higher environments. they think this might be deceiving
@ssvaidyanathan also version 1.1.6 did not have this issue.
https://github.com/apigee/apigee-deploy-maven-plugin/pull/86 this change was added to address the above issue right ? can we have this added to latest version ?
Unfortunately its built into the plugin https://github.com/apigee/apigee-deploy-maven-plugin/blob/d19b343e2a1c55fd2b25c11cafbd2ffe115224ea/src/main/java/io/apigee/buildTools/enterprise4g/mavenplugin/GatewayAbstractMojo.java#L454
This is what added as part of another issue that was opened.
Can you have a step added in your Jenkins file to rename that zip after the "package" command?
Thanks @ssvaidyanathan yes, i will try doing that
@ssvaidyanathan thanks for that suggestion. it worked
@ssvaidyanathan can you suggest the apigee.options to use based on my use case below ?
so, I have a separate CD pipeline where I download artifact from artifactory and deploy to apigee env using apigee deploy maven plugin. Basically, I want to deploy these artifacts with newer increemented revisions and if its the same artifact trying to be deployed again I dont want the current revision to be increemented, but to update in the same revision. I tried "update" option,, but it does not seem to satisfy this.
how do you know if its the same artifact being deployed? the "override" and "update" options are meant for that. You use "override" to get a new revision and "update" to update an existing revision. The plugin will just do what you passed.
If the pipeline in some way can find that, then you can use the appropriate option. Now why would you deploy the same revision to the same environment?
@ssvaidyanathan So,our ci pipelines automatically triggers build and deploys to dev and sandbox environments whenever there is a change pushed to master and feature branches (master to dev, feature to sandbox).that causes feature branch to deploy same version artifact to sandbox .
Is there a mgmt api or someother way to find the artifact version deployed to an env?
can you explain the complete process.. Wondering why are you worried about the revision if you have specific branches for each environment
Hi @ssvaidyanathan
To summarize, we have separate CI ,CD pipelines for apigee. CI pipelines are scripted such that, changes to master and feature branches triggers CD pipelines to deploy to dev and sandbox.
developers also have the ability to deploy to envs using these CD pipelines.
so, for instance : ***master branch deploys the proxy "xxx" to dev everytime there is a change pushed.
first run after changes, artifact created xxx-api-1.0.0.zip -> deploy to dev ->revision 1 created-> run acceptance test -> passes->deployment complete second run after changes , artifact created xxx-api-1.0.1.zip -> deploy to dev ->revision 2 created -> run acceptance test -> fails ->revert to previous revision 1
@dhanushyaselva - still dont understand what you are doing with the revisions for each artifacts.
If you are using a snapshot version, use the update
command else override
. Wouldnt that work?
@ssvaidyanathan so, if i have two feature branches, it will update the same revision in sandbox isnt it ?
yes.. but at the same time you can only have one revision deployed to an environment at the same time. So featureB could override featureA right?
What I would recommend doing is - to include a prefix as part of the build script to the proxy name and basepath if the source branch of the repo is a "feature" branch. This prefix could be the name of the feature branch too.. For example lets say the name of the feature branch is "feature/foo" and your proxy is "something-v1.0.0-snapshot.zip". You can deploy it as "something-foo-v1.0.0-snapshot.zip" and the basepath also can be changed to /v1/something-foo
With this you will have separate proxies for your feature branches and you can test it out. And once they are merged to the main branch, you deploy it as a regular proxy without the prefix and test it out end to end. Does that make sense?
Marking this as closed
When i try to deploy artifact by placing it in target folder using the plugin, i get this error.
[INFO] Scanning for projects... [INFO] [INFO] ----------< com.****.api:test-merchant-experience-api-v1 >---------- [INFO] Building test-merchant-experience-api-v1 1.0.7-SNAPSHOT [INFO] from pom.xml [INFO] --------------------------------[ pom ]--------------------------------- [INFO] [INFO] --- apigee-enterprise:1.2.2:deploy (default-cli) @ test-merchant-experience-api-v1 --- [INFO] Request prepared for the server
GET https://api.enterprise.apigee.com/v1/organizations/*******/apis/test-merchant-experience-api-v1/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 test-merchant-experience-api-v1 does not exist in organization ***", "contexts" : [ ] } [INFO] Updating apiproxy/test-merchant-experience-api-v1 revision 1 (current active revision is -1) [INFO] Request prepared for the server
POST https://api.enterprise.apigee.com/v1/organizations/*******/apis/test-merchant-experience-api-v1/revisions/1 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 { "code" : "beans.BeanDoesNotExist", "message" : "ApplicationBean : test-merchant-experience-api-v1 does not exist", "contexts" : [ ] } [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.026 s [INFO] Finished at: 2023-04-03T10:21:27+01:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:1.2.2:deploy (default-cli) on project test-merchant-experience-api-v1: 404 Not Found [ERROR] { [ERROR] "code" : "beans.BeanDoesNotExist", [ERROR] "message" : "ApplicationBean : test-merchant-experience-api-v1 does not exist", [ERROR] "contexts" : [ ] [ERROR] } [ERROR] -> [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
This is the first revision of the proxy.
the maven command i use is: mvn apigee-enterprise:deploy -P dev
my pom has this sections:
* *