Jenkins addition to being used as a CI (continuous integration) tools, can also be used with other plugin for other reasons (egIIS restart, file compression backup ...), today take a look at how you can integrate with the PowerShell PowerShell command execution
Article Outline
- Install PowerShell plugin
- Setting Powershell plugin
- PowerShell 丟出 build fail
1. Install PowerShell plugin
Manage Jenkins –> Manage Plugins
Available –> Filter
2. Setting Powershell plugin
Build –> ADD BUILD STEP –> Windows PowerShell
Command
Direct write Powershell Syntax
Big Box Jenkins 2 How to use PowerShell and custom build fail (designated code Exit) sercontent.com/assets/3851540/22322570/e4af87d6-e3d7-11e6-9451-a82bd90e3358.png "alt =" 4commnad "/>
3. PowerShell 丟出 build fail
By default Jenkins as long as the implementation of PowerShell, whether or not executed correctly are considered as having SUCCESS
, so it is necessary to manually throw build fail
Manual throws an error (using a try catch, for example)
- The actual implementation of a command PowerShell try catch bag
catch section threw
exit 1
to notify the Jenkins throw build failTry { Get-Content C:securestringa.txt -ErrorAction Stop } Catch { write-output "get data fail!" exit 1 }