简体   繁体   中英

Passing parameterized build parameter to Jython plugin in Jenkins

I need to

  • run a parameterized build
  • have Jython script (provided by Jython plugin) to get the parameters (I have defined Jython script as build step in the parameterized build)

In a shell script build step params can easily be accessed using env variables. Do I have to do the same in Jython? (can I do it at all)?

I'm not sure about how you can access the variable from Parameterized parameter in Execute Jython script in Build section but if i run the Jython script in Windows (after selecting Execute Windows batch command option from the dropdown list in Build section), it works fine. Check the snapshots below where i have used Parameterized Trigger Plugin for creating a String Parameter and then using the same in Jython script. It works fine and displays the value of the variable in output.

在此处输入图片说明

在此处输入图片说明

Here's the sample script i used for accepting parameter:

import sys

for arg in sys.argv:
    print arg 

For *nix environment, you obviously have to select Execute shell in Build section's dropdown list and also change %var% to $var .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM