我正在尝试学习如何在Python脚本中使用Jenkins中的变量。我已经知道我需要调用变量,但是我不确定如何在使用时实现它们os.path.join操作系统(). 在
我不是开发者,我是技术作家。这个代码是别人写的。我只是尝试修改Jenkins脚本,使它们参数化,这样我们就不必为每个版本修改Python脚本。在
我在Jenkins作业中使用内联Jenkins python脚本。Jenkins字符串参数是“BranchID”和“BranchIDShort”。我已经看了很多关于如何在Python脚本中建立变量的问题,但是os.path.join操作系统(),我不知道该怎么办。在
这是原始代码。我添加了从Jenkins参数建立变量的部分,但是我不知道如何在os.path.join操作系统()功能。在# Delete previous builds.
import os
import shutil
BranchID = os.getenv("BranchID")
BranchIDshort = os.getenv("BranchIDshort")
print "Delete any output from a previous build."
if os.path.exists(os.path.join("C:\\Doc192CS", "Output")):
shutil.rmtree(os.path.join("C:\\Doc192CS", "Output"))
我希望输出如下:c:\Doc192CS\output
我担心如果我执行以下代码:
^{pr2}$
我将得到:c:\Doc\192\CS\Output。在
有没有办法在这个上下文中使用branchhidshort变量来获得输出c:\Doc192CS\output?在