python - 在 Jenkinsfile 管道 groovy 中获取 python 脚本的输出结果
问题描述
我正在尝试将 python 脚本的输出分配给变量。
这是我的设置
stage('Deployment on FTP') {
steps {
script {
def warName = sh(script: 'python ../scripts/myPythonScriptHere.py', returnStdout: true)
}
...
}
}
这是我的配置(在 linux 服务器上):
ci/
-- prod/
-- Jenkinsfile.groovy
-- scripts/
-- myPythonScriptHere.py
詹金斯告诉无法打开文件“...” [Errno 2] 没有这样的文件或目录
我怎样才能做到这一点 ?
谢谢
解决方案
stage('Deployment on FTP') {
steps {
script {
env.WAR_NAME = sh(script: "python scripts-ci/scripts/build/front/scripts/lib/war_name.py ${customerProfileId} ${FORCE_CUSTOMER_NAME}", returnStdout: true).toString().trim()
}
}
}
这是我当前 Jenkinsfile 工作的代码(当我克隆所需的 python 脚本时,scripts-ci 在文件夹中搜索。
stage("Git checkout") {
steps {
dir("scripts-ci") {
git branch: "${GIT_BRANCH_CI}",
credentialsId: "${GIT_CREDENTIALS_ID}",
url: "${GIT_URL_CI}"
}
}
}
推荐阅读
- asp.net-core - Asp.net MVC 核心中 Ajax.BeginForms 的替代方法是什么
- html - CSS 调整背景图片大小
- pyspark - PySpark - 我可以使用 Window.rowsBetween() 在当前行上旋转正在运行的窗口内容吗?
- flutter - 我的颤振应用程序有一个小问题。我无法在屏幕上打印位置值。应该做什么?
- python - 短跑范围滑块,每侧都有输入
- gnuplot - Gnuplot:x1y1 绘图和 x2y1 绘图不共享相同的 xtics
- excel - 无法访问 ActiveProjects
- rest - Http "Put" 方法更新记录并同时插入新记录
- javascript - 错误:当我将一小部分 REACT 代码重新编写为 REDUX 时,'import' 和 'export' 可能只出现在顶层
- r - R Shiny 的闪亮警报“X”图像问题