How to Change Your P2 Repository Configuration with the REST API

Yarden Gitta
2023-01-22 11:11

The following steps will help you to change your P2 repository configuration via REST API.

We have also created a cURL command-deployable user plugin, which is available HERE. This will enable you to get and set P2 URLs that are used by P2 repositories, about which more information is available HERE.
Information on how to deploy the P2 user plugin is available HERE.

This user plugin supports two commands:
 

1. getP2Urls – Returns the current P2 settings in your Artifactory application. The cURL command to execute this is:

curl -uadmin:password -X POST "http://localhost:8081/artifactory/api/plugins/execute/getP2Urls?params=repo=repoKey"

Set the value of repoKey to the name of your P2 virtual repository.

2. modifyP2Urls – Will modify the P2 according to the version configured in the JSON file. Here’s an example:

{"repo": "p2-virtual","urls": ["http://dl.google.com/eclipse/plugin/3.7","http://download.eclipse.org/releases/luna","http://download.eclipse.org/mylyn/releases/luna","http://download.eclipse.org/eclipse/updates/4.4","local://p2-local/eclipse-repository/eclipse-repository/1.0.0-SNAPSHOT/eclipse-repository-1.0.0-20141213.002711-2.zip!/"]}


 

Here’s an example of the cURL command:

curl -uadmin:password -T /path/to/jsonFile -X POST "http://localhost:8081/artifactory/api/plugins/execute/modifyP2Urls"