jenkins是否通过-noprofile参数以某种方式运行powershell步骤?

时间:2019-07-26 00:38:49

标签: powershell jenkins jenkins-pipeline jenkins-plugins

我想自定义詹金斯(Jenkins)运行的PS会话的配置文件

我将个人资料复制到几乎所有可能的位置,并在管道中运行此文件以确认其位置和内容正确:

powershell 'cat $PsHome\\Profile.ps1'

在配置文件中,我设置了一些别名和环境变量

在powershell步骤中,但是如果我检查别名列表和env vars,我看不到我的配置文件包含的更改:

powershell 'ls alias:'
powershell 'ls env:'

jenkins似乎没有使用-noprofile:https://github.com/jenkinsci/powershell-plugin/blob/d3e8aec4074bdfa5f5032c71a3e6ba4a3c6c8340/src/main/java/hudson/plugins/powershell/PowerShell.java

运行powershell

为什么我的个人资料没有被执行?

1 个答案:

答案 0 :(得分:2)

正如您的文章所假设的那样,管道作业中的powershell命令不是来自PowerShell插件。

PowerShell插件仅用于在Freestyle作业和doesn't support pipelines.

上添加“执行PowerShell”步骤

此插件是否支持管道? 否,但管道提供了一个强大的步骤:节点和流程插件

他们遇到了相反的情况,即总是加载概要文件,而问题是如何在需要时避免使用它们。最近有一个新的PR mas合并到integrate a switch to choose whether profiles should be loaded or not

用于Pipeline作业的Powershell的实现来自Pipeline:Nodes and Processes插件(也称为workflow-durable-task-step-plugin),当前是it doesn't include a parameter to enable disable loading Profiles.

相关文件为herehere,以防万一,您可以使用其他参数来创建新的PR。

GitLab中的项目似乎已禁用“问题”,因此无法进行报告/请求。

相关问题