How to trigger the M2 Release Plugin with a REST call

Article ID:360034813552
1 minute readKnowledge base


I would like to trigger a Maven release using the M2 Release Plugin from a REST call.


The M2 Release Plugin does not offer a REST API (see the feature request in JENKINS-29519). However it remains possible to trigger a release. Here is a simple minimal example to trigger a release for the job located at "${JENKINS_URL}/${JOB}:

curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -u ${CREDENTIALS} --data-urlencode json='{"parameter":[]}' --data-urlencode releaseVersion="${RELEASE_VERSION}" --data-urlencode developmentVersion="${DEVELOPMENT_VERSION}" "${JENKINS_URL}/${JOB}/m2release/submit"

In case you need help to properly work with the CSRF protection, please refer to CSRF Protection Explained.

This minimal call will only pass the two parameters required for a release to work. You can add other parameters simply looking into the parameters in the code the list is here for version 0.15.0. As an example, please consider a case where you want to make a dryRun, in this case, you should add --data-urlencode isDryRun='true'.

Be aware that this method relies on an unpublished API. Therefore it may change in later versions.

Tested product/plugin versions