如何在Jenkins的作业中执行powershell文件?

时间:2015-02-12 13:48:33

标签: powershell jenkins

  • 此外,我有de powershell instaled的插件。

在配置工作中,我有这个:

Command windows power shell

但是,执行作业时我有下一个错误:

.ps1 cannot be loaded because the
 execution of scripts is disabled on this system. Please see "get-help about_si
gning" for more details.
At line:1 char:2
+ & <<<<  'C:\Windows\TEMP\abc.ps1'
    + CategoryInfo          : NotSpecified: (:) [], PSSecurityException
    + FullyQualifiedErrorId : RuntimeException

Build step 'Windows PowerShell' marked build as failure
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE

我认为这是因为我的Jenkins实例不是管理员。

注意:

- I have a instance of Jenkins in my machine local
- And when I compile from my  windows power shell console, this if execute (This is possible with this instruction "Set-ExecutionPolicy Unrestricted")

2 个答案:

答案 0 :(得分:1)

您需要在服务器上设置执行策略。 您可以通过在PowerShell窗口中键入以下内容来设置执行策略:

Set-ExecutionPolicy RemoteSigned

有关详细信息https://technet.microsoft.com/en-us/library/ee176961.aspx

答案 1 :(得分:-2)

不要使用服务运行Jenkins服务器...在cmd窗口中运行jenkin服务器(没有窗口服务)