简体   繁体   中英

passing parameters from groovy to python ( Jenkins job)

I am using groovy to call a python in my Jenkins job. i would like to pass few parameters also to the python and i need to use those in the python

I am calling the python like below

result = sh(returnStdout:true , script: '#!/bin/sh -e\n' + 'python test.py').trim()

The parameters i need to pass are jenkins build job parameters.

Can you suggest a solution to this problem.?

Try:

cmd = """#!/bin/sh -e\n' + 'python test.py ${JENKINS_VAR_1} ${JENKINS_VAR_1}"""
result = sh(returnStdout:true , script: cmd).trim()

Assuming you already have the code in python to access the argument.

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