zoukankan      html  css  js  c++  java
  • 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结果:

  • 相关阅读:
    Fortran学习记录1(Fortran数据类型)
    ABAQUS学习记录1——用户子程序综述
    Abaqus用户子程序umat的学习
    信号基础知识---线阵
    信号基础知识--FFT DFT
    信号基础知识
    服务器文件打压缩包下载(java)
    网页鼠标特效-点击漂浮文字
    jQuery父子页面之间元素、方法获取、调用
    常用数字与字母的正则表达式
  • 原文地址:https://www.cnblogs.com/yangwenbo214/p/9835515.html
Copyright © 2011-2022 走看看