user1164061
user1164061

Reputation: 4342

Trigger "perform maven release" of a jenkins job from another job

Looking for ways to trigger a "perform maven" release job from another jenkins job. It can be a rest api (or) a plugin that can do it. I saw posts about "trigger paramterized" plugin which can do this, but I cant see a way to do it . So I need real examples on how to try it.

Thanks!

Upvotes: 1

Views: 1702

Answers (1)

k2zinger
k2zinger

Reputation: 382

This task has been open in Jenkin's Jira since July 2015 with no movement yet.

Since this is the case, I suggest using an HTTP POST to accomplish this task. To do this, you will need to do the following:

  1. Install the HTTP Request Plugin
  2. Create an httpUser (or use an existing one) with the appropriate Matrix Permissions and then grab its API Token Jenkins -> People -> httpUser -> Configure -> API Token -> Show API Token...Show API Token...
  3. Jenkins -> Manage Jenkins -> Configure System -> HTTP Request -> Basic/Digest Authentication -> Add -> create a Global HTTP Authentication Key with the information from step 2 Global HTTP Authentication Key
  4. Create a "parent" job that will trigger other Jenkins job(s) via the M2-Release-Plugin and configure it as follows:
  5. This build is parameterized
    • releaseVersion (Text Parameter)
    • developmentVersion (Text Parameter)
    • (add other parameters as required, look in the doSubmit method for details)
  6. Build -> Add build step -> HTTP Request
    • URL (should have this format) = http://JenkinsServerName/job/JenkinsJobName/m2release/submit
    • HTTP mode = POST
    • Advanced...
    • Authorization -> Authenticate = select the Authenticate option created in step 3
    • Headers -> Custom headers -> Add
    • Header = Content-type
    • Value = application/x-www-form-urlencoded
    • Body -> Pass build params to URL? = Yes
    • Request body = (your parameters from step 5 and a json parameter object with any additional parameters required)
    • Response body in console? = Yes HTTP Request

These are the steps I followed to have one Jenkins job trigger an m2release on another job in my environment. Hopefully this helps others and should I lose my notes or memory, I can refer to this post as well.

Upvotes: 11

Related Questions