Jenkins post build python 脚本文件 [英] Jenkins post build python script file

查看:97
本文介绍了Jenkins post build python 脚本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Jenkins 的新手,特别是在 Jenkins 中使用 python 脚本.我面临的问题如下:

I am new to Jenkins, specially with using python script in Jenkins. The problem I am facing is as follow:

我试图在 Jenkins 的构建后步骤中从 python 文件运行 python 脚本.我已将为此目的所需的所有插件添加到我的理解中.即我包含了 Post-BuildScript 插件、python jenkins 插件等.现在,当我构建控制台输出时显示无效的脚本命令导致失败.我附上了下面的结果.有人可以帮我吗?在后期构建步骤中,我提供了 python 脚本文件的完整或绝对路径,即

I am trying to run a python script from a python file in the post-build step of the Jenkins. I have added all the plugins required for that purpose to my understanding. i.e I have included Post-BuildScript plugin, python jenkins plugin etc. Now when I build console output shows invalid script command caused the failure. I have attached the results below. can anybody help me with that please? In post build step I am providing the full or absolute path to the python script file i.e

执行pythonScriptpath

结果

在这里提到可能很有用,我也尝试过只使用路径而不在路径前写 python,也尝试在路径中使用正斜杠和反斜杠.没有任何成功.

It may be useful to mention here I have also tried using just the path without writing python preceding the path, also tried with forward as well as backward slash in the path. without any success.

推荐答案

我已经设法解决了这个问题.解决方案有两部分:第一个是如果您想在后期构建中运行简单的 python 脚本-->为执行 python 脚本添加后期构建步骤(这将需要您为后期构建安装插件).在添加后期构建步骤后创建的窗口中,您可以简单地运行任何 python 命令.

I have managed to resolve that issue. There are two parts of solution: First one is if you want to run simple python script in post-build -->Add a post build step for Execute python Script (That will require you install plugin for post build ) . In that window created after adding post build step you can simply put any python command to run.

解决方案的第二部分是,当用户想要从同一个构建后步骤窗口中的 python 脚本文件运行命令列表时,在这种情况下,用户必须确保将所有必需的 python 文件放在想要执行到 Jenkins 工作区->项目目录(我们正在运行 Jenkins 的项目).此外,对于 Python2.7,为了执行该 python 脚本文件,用户只需将脚本编写为

Second part of the solution is for, when user would like to run a list of commands from a python script file from the same post build step window in that case user has to make sure to put all the required python files which you want to execute into the Jenkins workspace->project directory(project for which we are running the Jenkins ) . Moreover, for Python2.7 in order to execute that python script file user simply need to write script as

execfile(file.py)

还要记住的一件事是在环境变量中插入 python.exe 路径.

One more thing to remember is insert python.exe path in the environment variables.

这篇关于Jenkins post build python 脚本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆