Maven Config Plugin Tool Error on Jenkins

Former Community Member
Not applicable

Hi,

I am using the following command.

install -Ptest -Dusername=orguser1@email.com -Dauthtype=oauth -Dbearer=$T -Dapigee.config.options=create -Denv=dev -Dorg=org1

I am seeing this error on jenkins:

[ERROR] Failed to execute goal io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:1.1.7:deploy (deploy-bundle) on project HelloWorld: : MojoExecutionException: The token was expected to have 3 parts, but got 1. -> [Help 1]
Solved Solved
0 6 506
1 ACCEPTED SOLUTION

Former Community Member
Not applicable

It worked for me with this:

install -Ptest -Dusername=$un -Dpassword=$pw -Dauthtype=oauth -Dapigee.config.options=create -Denv=explore -Dorgname=org

As we have SAML enabled, I had to update the tokenURL (in the shared-pom.xml) from the default

https://login.apigee.com/oauth/token" to https://zonename.login.apigee.com/oauth/token"

View solution in original post

6 REPLIES 6

sidd-harth
Participant V

You need to provide more info.

Which doc/example are you following? What is your goal? What steps have you done?

Seeing the error I can take a wild guess, you may be sending an opaque oauth token and the service is expecting a JWT token.

The token was expected to have 3 parts, but got 1. -> [Help 1]

Former Community Member
Not applicable

I am following the documentation on this link:

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

Doing all these steps on Jenkins. I am using a machine user to get the token using curl (Execute Shell step).

curl -H "Content-Type: application/x-www-form-urlencoded;charset=utf-8" -H "accept: application/json;charset=utf-8" -H "Authorization: Basic ZWRnZWNsaTplZGdlY2xpc2VjcmV0" -X POST https://orgname.login.apigee.com/oauth/token -d 'grant_type=password&username=$un&password=$pw' -o ./output.json

export T=`grep -o '"access_token": *"[^"]*' output.json | grep -o '[^"]*`

I am taking the "access_token" out of the json returned and passing to the maven command.

Next step is maven config tool command:

install -Ptest -Dusername=username -Dauthtype=oauth -Dbearer=$T -Dapigee.config.options=create -Denv=dev -Dorg=org1

This is where I am seeing the error.

Looks like the org you are using is SAML enabled

In stead of running the curl, extracting the token and passing it to the mvn command. You can use all of that in the Maven plugin itself. Just configure the login url in your profile and then in the Maven command, just pass the username and password along with the apigee.config.options, org and env. The plugin will automatically use the login url, generate the token and use that for the Management API calls

Former Community Member
Not applicable

Yes, this org has SAML enabled and I am using machine user.

Like suggested, I tried this and seeing the following error:

install -Ptest -Dusername=$un -Dpassword=$pw -Dapigee.config.options=create -Denv=dev -Dorg=orgname

POST request for "https://login.apigee.com/oauth/token" resulted in 401 (Unauthorized); invoking error handler
18:47:35,881 ERROR MgmtAPIClient:123 - 401 Unauthorized
[ERROR] 401 Unauthorized

Is there another parameter I need to pass?

Former Community Member
Not applicable

It worked for me with this:

install -Ptest -Dusername=$un -Dpassword=$pw -Dauthtype=oauth -Dapigee.config.options=create -Denv=explore -Dorgname=org

As we have SAML enabled, I had to update the tokenURL (in the shared-pom.xml) from the default

https://login.apigee.com/oauth/token" to https://zonename.login.apigee.com/oauth/token"

You can try using ADT tool for deploying Apigee entities. It supports SAML also.

https://github.com/ashishkpathak/adt