• Jenkins中使用Azure Powershell连接Service Fabric报错not recognized的原因与解决办法


    一、使用背景

    在涉及Azure service Fabric的自动化应用场景中,依赖于Service Fabric的Azure Powershell cmdlets,我们可以使用Jenkins能实现cicd,当然VSTS也是一种选择。

    二、报错现象

    在Jenkins的Console output中,有如下报错:

    '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.

    四、解决办法

    我个人尝试过的解决办法有两种,第一种较为简单,推荐使用。第二种比较麻烦,需要下载JRE,需要改动jenkins的配置文件。

    方法1:(实质是使用正确的Powershell.exe的路径为sysnative下)

    我们在jenkins的configration下添加一个Environment variables 名称为path,在path中添加C:WindowssysnativeWindowsPowerShellv1.0 为我们的powershell.exe的启动路径。

    方法2:修改jenkins本身(解决方法可能值得商榷?慎用

    我们需要下载JRE,进入Jenkins的配置文件目录C:Program Files (x86)Jenkinsjenkins.xml),做如下修改

    <executable>C:Program FilesJavajre1.8.0_151injava</executable> 
    <executable>C:ProgramDataOracleJavajavapathjava.exe</executable>
    

    同样我们在jenkins的configration下添加一个Environment variables 名称为path,在path中添加C:WindowsSystem32WindowsPowerShellv1.0 为我们的powershell.exe的启动路径。

    五、旁支问题的解决方法

    1. 如果上述过程后,你还遇到FabricCommon.dll could not be found的问题

    你需要在上述的path中再加入C:Program FilesMicrosoft Service FabricinFabricFabric.Code 对方法1而言:
    最后你的Jenkins Environment variables path 应该是如下:

    C:WindowssysnativeWindowsPowerShellv1.0;C:WindowsSystem32;C:Program FilesMicrosoft Service FabricinFabricFabric.Code
    

    2.做一个简单测试

    创建一个Pipeline ,在你的local service fabric启动的情况下,写入如下测试脚本:

    你会得到如下的output结果:

  • 相关阅读:
    ASP.NET 3.5 的 ListView 控件与 CSS Friendly
    从 Adobe SHARE 说到 Silverlight 的 XPS 支持
    编写 iPhone Friendly 的 Web 应用程序 (Part 5 交互入门)
    初为项目经理
    管理的最高境界不是完美
    url传递中文的解决方案总结
    我想跟什么样的人合作
    异步Socket通信总结
    让机器自动支持中文文件名
    Socket基本编程
  • 原文地址:https://www.cnblogs.com/yangwenbo214/p/9835515.html
Copyright © 2020-2023  润新知