![](/img/trans.png)
[英]Linux vs. Windows: How does the console render unicode characters?
[英]On Jenkins how can you detect if a server is Windows vs. Linux?
在Jenkins上,我使用的是條件構建步驟插件。 有沒有一種方法可以使其運行某些構建步驟,具體取決於它運行的從屬節點是Windows還是Linux?
您可以使用jenkins中提供的isUnix()函數來標識操作系統類型。
因此,您可以在腳本塊下的jenkinsfile中使用以下內容:
if (isUnix()) {
sh 'ls -la'
} else {
bat 'dir'
}
要僅在當前服務器是Windows時運行命令,請使用條件BuildStep插件進行檢查:
Strings match:
String 1: ${ENV,var="OS"}
String 2: Windows_NT
要僅在當前服務器是Linux時運行命令,請檢查:
Strings match:
String 1: ${ENV,var="OS"}
String 2:
(將字符串2留空。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.