1

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!

StephenKing
  • 36,187
  • 11
  • 83
  • 112
user1164061
  • 4,222
  • 13
  • 48
  • 74

1 Answers1

11

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.

k2zinger
  • 382
  • 7
  • 15
  • wow! thank you so much for the detailed explanation. I wish I can give you more than 1 point for this answer.. – user1164061 Dec 05 '16 at 19:22
  • Great thing. Also there is an option to pass custom parameter in the job that does release via json query parameter `json={"parameter": {"name":"CUSTOM_PARAM_1", "value":"CUSTOM_PARAM_1_VALUE"}}` – Dzmitry Hubin Sep 17 '18 at 15:45