在涉及Azure service Fabric的自动化应用场景中,依赖于Service Fabric的Azure Powershell cmdlets,咱们可使用Jenkins能实现cicd,固然VSTS也是一种选择。java
在Jenkins的Console output中,有以下报错:shell
'Connect-ServiceFabricCluster' is not recognized测试
官网中是这么描述的:
If you try to run any of the Service Fabric PowerShell cmdlets, such as Connect-ServiceFabricCluster in an Azure PowerShell window, it fails, saying that the cmdlet is not recognized. The reason for this is that Azure PowerShell uses the 32-bit version of Windows PowerShell (even on 64-bit OS versions), whereas the Service Fabric cmdlets only work in 64-bit environments.this
我我的尝试过的解决办法有两种,第一种较为简单,推荐使用。第二种比较麻烦,须要下载JRE,须要改动jenkins的配置文件。spa
咱们在jenkins的configration下添加一个Environment variables 名称为path,在path中添加C:\Windows\sysnative\WindowsPowerShell\v1.0 为咱们的powershell.exe的启动路径。code
咱们须要下载JRE,进入Jenkins的配置文件目录C:\Program Files (x86)\Jenkins\jenkins.xml),作以下修改 xml
<executable>C:\Program Files\Java\jre1.8.0_151\bin\java</executable> <executable>C:\ProgramData\Oracle\Java\javapath\java.exe</executable>
一样咱们在jenkins的configration下添加一个Environment variables 名称为path,在path中添加C:\Windows\System32\WindowsPowerShell\v1.0 为咱们的powershell.exe的启动路径。blog
你须要在上述的path中再加入C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code 对方法1而言:
最后你的Jenkins Environment variables path 应该是以下:ip
C:\Windows\sysnative\WindowsPowerShell\v1.0;C:\Windows\System32;C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code
建立一个Pipeline ,在你的local service fabric启动的状况下,写入以下测试脚本:ci
你会获得以下的output结果: