简体   繁体   中英

Is jenkins somehow running powershell step with the -noprofile param?

I want to customize the profile of the PS sessions jenkins runs

I copied my profile to pretty much every possible location and ran this in a pipeline to confirm its there and its contents are correct:

powershell 'cat $PsHome\\Profile.ps1'

In the profile I set some aliases and environment variables

In powershell steps though if I check the aliases list and env vars I dont see the changes my profile contains:

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

It doesn't look like jenkins is running powershell with -noprofile: https://github.com/jenkinsci/powershell-plugin/blob/d3e8aec4074bdfa5f5032c71a3e6ba4a3c6c8340/src/main/java/hudson/plugins/powershell/PowerShell.java

Why isn't my profile being executed?

The powershell command in a Pipeline job is not coming from the PowerShell plugin, as your post seems to assume.

The PowerShell plugin is only meant to add an Execute PowerShell step on Freestyle jobs and doesn't support pipelines.

Does this plugin support pipelines? No, but there is a powershell step provided by the Pipeline: Nodes and Processes plugin

They were experiencing the opposite situation, where profiles were always loaded, and the problem was how to avoid them when needed. A new PR mas merged recently to integrate a switch to choose whether profiles should be loaded or not

The implementation of powershell for Pipeline jobs comes from the Pipeline: Nodes and Processes plugin (aka workflow-durable-task-step-plugin ) and currently, it doesn't include a parameter to enable disable loading Profiles.

The relevant files are here and here , in case you can get your head around them and create a new PR with the additional parameter.

The project in GitLab seems to have Issues disabled, so no reporting/requesting is possible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM