Azure DevOps任务-如何连接到服务矩阵群集?

时间:2019-04-05 19:30:07

标签: azure-devops azure-pipelines-build-task

我是第一次创建Azure DevOps任务,请耐心等待。我创建了一个任务,该任务需要连接到托管在Azure上的Service Fabric群集。我从github上的serviceFabricDeployv1任务借来了一段代码,以连接到集群。当我发布并使用此任务时,出现以下错误:无法索引为空数组。然后,我启用了调试模式,并且错误点指向Connect-ServiceFabricClusterFromServiceEndpoint:

2019-04-05T17:43:58.7031978Z ##[debug]Entering D:\a\_tasks\CleanupServiceFabricApplicationVersions_5164728d-cfca-4576-a066-ZZZZZZZZZZZZ\0.0.10\powershell.ps1.
2019-04-05T17:43:58.7326382Z ##[debug]Loading module from path 'D:\a\_tasks\CleanupServiceFabricApplicationVersions_5164728d-cfca-4576-a066-ZZZZZZZZZZZZ\0.0.10\ps_modules\ServiceFabricHelpers\ServiceFabricHelpers.psm1'.
2019-04-05T17:43:58.7457125Z ##[debug]Loading resource strings from: D:\a\_tasks\CleanupServiceFabricApplicationVersions_5164728d-cfca-4576-a066-ZZZZZZZZZZZZ\0.0.10\ps_modules\ServiceFabricHelpers\module.json
2019-04-05T17:43:58.7798307Z ##[debug]Loaded 17 strings.
2019-04-05T17:43:58.7852857Z ##[debug]SYSTEM_CULTURE: 'en-US'
2019-04-05T17:43:58.7877741Z ##[debug]Loading resource strings from: D:\a\_tasks\CleanupServiceFabricApplicationVersions_5164728d-cfca-4576-a066-ZZZZZZZZZZZZ\0.0.10\ps_modules\ServiceFabricHelpers\Strings\resources.resjson\en-US\resources.resjson
2019-04-05T17:43:58.8294503Z ##[debug]Loaded 17 strings.
2019-04-05T17:43:58.8552233Z ##[debug]Entering Find-VstsFiles.
2019-04-05T17:43:58.8652603Z ##[debug] LiteralDirectory: 'D:\a\_tasks\CleanupServiceFabricApplicationVersions_5164728d-cfca-4576-a066-ZZZZZZZZZZZZ\0.0.10\ps_modules\ServiceFabricHelpers'
2019-04-05T17:43:58.8675211Z ##[debug] LegacyPattern: '*.ps1'
2019-04-05T17:43:59.5468797Z ##[debug]Entering Get-MatchingItems.
2019-04-05T17:43:59.5509999Z ##[debug] IncludePatterns: 'D:\a\_tasks\CleanupServiceFabricApplicationVersions_5164728d-cfca-4576-a066-ZZZZZZZZZZZZ\0.0.10\ps_modules\ServiceFabricHelpers\*.ps1'
2019-04-05T17:43:59.5573606Z ##[debug] ExcludePatterns: ''
2019-04-05T17:43:59.5624335Z ##[debug] IncludeFiles: 'True'
2019-04-05T17:43:59.5666234Z ##[debug] IncludeDirectories: 'False'
2019-04-05T17:43:59.5684855Z ##[debug] Force: 'False'
2019-04-05T17:44:00.0606696Z ##[debug]Paths: D:\a\_tasks\CleanupServiceFabricApplicationVersions_5164728d-cfca-4576-a066-ZZZZZZZZZZZZ\0.0.10\ps_modules\ServiceFabricHelpers\
2019-04-05T17:44:00.0629904Z ##[debug] CommonHelpers.ps1
2019-04-05T17:44:00.0630803Z ##[debug] Connect-ServiceFabricClusterFromServiceEndpoint.ps1
2019-04-05T17:44:00.0631002Z ##[debug] Get-ServiceFabricEncryptedText.ps1
2019-04-05T17:44:00.0631429Z ##[debug] SFOperations.ps1
2019-04-05T17:44:00.0632558Z ##[debug]Leaving Get-MatchingItems.
2019-04-05T17:44:00.0796566Z ##[debug]Total found: 4
2019-04-05T17:44:00.0818584Z ##[debug]Leaving Find-VstsFiles.
2019-04-05T17:44:00.0836639Z ##[debug]Exporting function 'Connect-ServiceFabricClusterFromServiceEndpoint'.
2019-04-05T17:44:00.0854254Z ##[debug]Exporting function 'Remove-ClientCertificate'.
2019-04-05T17:44:00.0873015Z ##[debug]Exporting function 'Get-ServiceFabricEncryptedText'.
2019-04-05T17:44:00.0895219Z ##[debug]Exporting variable 'SF_Operations'.
2019-04-05T17:44:00.0913326Z ##[debug]Exporting function 'Publish-Telemetry'.
2019-04-05T17:44:00.0931512Z ##[debug]Exporting function 'Get-SfSdkVersion'.
2019-04-05T17:44:00.0948589Z ##[debug]Exporting function 'Trace-WarningIfCertificateNotPresentInLocalCertStore'.
2019-04-05T17:44:00.2293992Z ##[debug]Importing function 'Connect-ServiceFabricClusterFromServiceEndpoint'.
2019-04-05T17:44:00.2348563Z ##[debug]Importing function 'Get-ServiceFabricEncryptedText'.
2019-04-05T17:44:00.2364893Z ##[debug]Importing function 'Get-SfSdkVersion'.
2019-04-05T17:44:00.2365479Z ##[debug]Importing function 'Publish-Telemetry'.
2019-04-05T17:44:00.2365962Z ##[debug]Importing function 'Remove-ClientCertificate'.
2019-04-05T17:44:00.2366440Z ##[debug]Importing function 'Trace-WarningIfCertificateNotPresentInLocalCertStore'.
2019-04-05T17:44:00.2381806Z ##[debug]Importing variable 'SF_Operations'.
2019-04-05T17:44:00.2595362Z ##[debug]INPUT_NAME: 'Test'
2019-04-05T17:44:00.2618846Z ##[debug]INPUT_SERVICECONNECTIONNAME: '9d750132-3d2f-4be1-9896-ZZZZZZZZZZZZ'
2019-04-05T17:44:00.2743138Z ##[debug]ENDPOINT_URL_9d750132-3d2f-4be1-9896-ZZZZZZZZZZZZ: 'tcp://XXXXXXX-dev.eastus.cloudapp.azure.com:19000/'
2019-04-05T17:44:00.2768982Z ##[debug]ENDPOINT_AUTH_9d750132-3d2f-4be1-9896-ZZZZZZZZZZZZ: '********'
2019-04-05T17:44:00.2795548Z ##[debug]ENDPOINT_DATA_9d750132-3d2f-4be1-9896-ZZZZZZZZZZZZ: '{}'
2019-04-05T17:44:00.2825549Z ##[debug]INPUT_APPLICATIONTYPENAME: 'YYYYYYYYYAdminApplicationType'
2019-04-05T17:44:00.2851562Z ##[debug]INPUT_VERSIONSTOKEEP: '25'
2019-04-05T17:44:00.2859654Z Hello Test
2019-04-05T17:44:00.2940936Z 
2019-04-05T17:44:00.3971664Z ##[debug]Entering Connect-ServiceFabricClusterFromServiceEndpoint.
2019-04-05T17:44:00.4005857Z ##[debug] ClusterConnectionParameters: ''
2019-04-05T17:44:00.4049759Z ##[debug] ConnectedServiceEndpoint: '@{Url=tcp://XXXXXXX-dev.eastus.cloudapp.azure.com:19000/; Data=; Auth=}'
2019-04-05T17:44:00.4073037Z ##[debug]Loading module from path 'D:\a\_tasks\CleanupServiceFabricApplicationVersions_5164728d-cfca-4576-a066-ZZZZZZZZZZZZ\0.0.10\ps_modules\TlsHelper_\TlsHelper_.psm1'.
2019-04-05T17:44:00.4131899Z ##[debug]Loading resource strings from: D:\a\_tasks\CleanupServiceFabricApplicationVersions_5164728d-cfca-4576-a066-ZZZZZZZZZZZZ\0.0.10\ps_modules\TlsHelper_/module.json
2019-04-05T17:44:00.4222463Z ##[debug]Loaded 3 strings.
2019-04-05T17:44:00.4254490Z ##[debug]SYSTEM_CULTURE: 'en-US'
2019-04-05T17:44:00.4276566Z ##[debug]Loading resource strings from: D:\a\_tasks\CleanupServiceFabricApplicationVersions_5164728d-cfca-4576-a066-ZZZZZZZZZZZZ\0.0.10\ps_modules\TlsHelper_\Strings\resources.resjson\en-US\resources.resjson
2019-04-05T17:44:00.4371091Z ##[debug]Loaded 3 strings.
2019-04-05T17:44:00.4389647Z ##[debug]Exporting function 'Add-Tls12InSession'.
2019-04-05T17:44:00.4408086Z ##[debug]Exporting function 'Assert-TlsError'.
2019-04-05T17:44:00.4427407Z ##[debug]Importing function 'Add-Tls12InSession'.
2019-04-05T17:44:00.4445734Z ##[debug]Importing function 'Assert-TlsError'.
2019-04-05T17:44:00.4468489Z ##[debug]Loading module from path 'D:\a\_tasks\CleanupServiceFabricApplicationVersions_5164728d-cfca-4576-a066-ZZZZZZZZZZZZ\0.0.10\ps_modules\PowershellHelpers\PowershellHelpers.psm1'.
2019-04-05T17:44:00.4520413Z ##[debug]Loading resource strings from: D:\a\_tasks\CleanupServiceFabricApplicationVersions_5164728d-cfca-4576-a066-ZZZZZZZZZZZZ\0.0.10\ps_modules\PowershellHelpers\module.json
2019-04-05T17:44:00.4616048Z ##[debug]Loaded 3 strings.
2019-04-05T17:44:00.4644750Z ##[debug]SYSTEM_CULTURE: 'en-US'
2019-04-05T17:44:00.4665426Z ##[debug]Loading resource strings from: D:\a\_tasks\CleanupServiceFabricApplicationVersions_5164728d-cfca-4576-a066-ZZZZZZZZZZZZ\0.0.10\ps_modules\PowershellHelpers\Strings\resources.resjson\en-US\resources.resjson
2019-04-05T17:44:00.4762919Z ##[debug]Loaded 3 strings.
2019-04-05T17:44:00.4815247Z ##[debug]Exporting function 'Invoke-ActionWithRetries'.
2019-04-05T17:44:00.4833170Z ##[debug]Exporting function 'Get-TempDirectoryPath'.
2019-04-05T17:44:00.4852570Z ##[debug]Importing function 'Get-TempDirectoryPath'.
2019-04-05T17:44:00.4869307Z ##[debug]Importing function 'Invoke-ActionWithRetries'.
2019-04-05T17:44:00.8779229Z ##[debug]TLS 1.2 already present in session.
2019-04-05T17:44:01.1396847Z ##[debug]Leaving Connect-ServiceFabricClusterFromServiceEndpoint.
2019-04-05T17:44:01.3539036Z ##[debug]Leaving D:\a\_tasks\CleanupServiceFabricApplicationVersions_5164728d-cfca-4576-a066-ZZZZZZZZZZZZ\0.0.10\powershell.ps1.
2019-04-05T17:44:01.4231167Z ##[debug]Caught exception from task script.
2019-04-05T17:44:01.4260902Z ##[debug]Error record:
2019-04-05T17:44:01.4795495Z ##[debug]Cannot index into a null array.
2019-04-05T17:44:01.4807469Z ##[debug]At D:\a\_tasks\CleanupServiceFabricApplicationVersions_5164728d-cfca-4576-a066-ZZZZZZZZZZZZ\0.0.10\ps_modules\ServiceFabricHelpers\Connect-ServiceFabricClusterFromServiceEndpoint.ps1:183 char:9
2019-04-05T17:44:01.4819503Z ##[debug]+         $clusterConnectionParameters["ConnectionEndpoint"] = $connect ...
2019-04-05T17:44:01.4833117Z ##[debug]+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-04-05T17:44:01.4845957Z ##[debug]    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
2019-04-05T17:44:01.4858471Z ##[debug]    + FullyQualifiedErrorId : NullArray
2019-04-05T17:44:01.4871142Z ##[debug] 
2019-04-05T17:44:01.4891780Z ##[debug]Script stack trace:
2019-04-05T17:44:01.4933518Z ##[debug]at Connect-ServiceFabricClusterFromServiceEndpoint, D:\a\_tasks\CleanupServiceFabricApplicationVersions_5164728d-cfca-4576-a066-ZZZZZZZZZZZZ\0.0.10\ps_modules\ServiceFabricHelpers\Connect-ServiceFabricClusterFromServiceEndpoint.ps1: line 183
2019-04-05T17:44:01.4947432Z ##[debug]at <ScriptBlock>, D:\a\_tasks\CleanupServiceFabricApplicationVersions_5164728d-cfca-4576-a066-ZZZZZZZZZZZZ\0.0.10\powershell.ps1: line 33
2019-04-05T17:44:01.4961200Z ##[debug]at <ScriptBlock>, <No file>: line 1
2019-04-05T17:44:01.4976344Z ##[debug]at <ScriptBlock>, <No file>: line 22
2019-04-05T17:44:01.4991236Z ##[debug]at <ScriptBlock>, <No file>: line 18
2019-04-05T17:44:01.5004268Z ##[debug]at <ScriptBlock>, <No file>: line 1
2019-04-05T17:44:01.5024099Z ##[debug]Exception:
2019-04-05T17:44:01.5063789Z ##[debug]System.Management.Automation.RuntimeException: Cannot index into a null array.
2019-04-05T17:44:01.5078978Z ##[debug]   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2019-04-05T17:44:01.5092694Z ##[debug]   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2019-04-05T17:44:01.5107807Z ##[debug]   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2019-04-05T17:44:01.5120140Z ##[debug]   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2019-04-05T17:44:01.5414310Z ##[error]Cannot index into a null array.
2019-04-05T17:44:01.5423078Z ##[debug]Processed: ##vso[task.logissue type=error]Cannot index into a null array.
2019-04-05T17:44:01.5443902Z ##[debug]Processed: ##vso[task.complete result=Failed]

我已验证所有必需的模块已包含在任务中,并且我正在从列表中选择正确的服务结构连接。

这是我用来调用Connect-ServiceFabricClusterFromServiceEndpoint函数的powershell脚本:

Import-Module $PSScriptRoot\ps_modules\ServiceFabricHelpers
    # Get inputs. 
    $inputName = Get-VstsInput -Name 'name' -Require 
    $serviceConnectionName = Get-VstsInput -Name serviceConnectionName -Require
    $connectedServiceEndpoint = Get-VstsEndpoint -Name $serviceConnectionName -Require
    $ApplicationTypeName = Get-VstsInput -Name 'ApplicationTypeName' -Require 
    $VersionsToKeep = Get-VstsInput -Name 'VersionsToKeep' -Require 

    Write-Host "Hello $inputName" 

    if ($connectedServiceEndpoint.Auth.Scheme -ne "None" -and !$connectedServiceEndpoint.Auth.Parameters.ServerCertThumbprint)
    {
        Write-Warning (Get-VstsLocString -Key ServiceEndpointUpgradeWarning)
        if ($publishProfile)
        {
            $clusterConnectionParameters["ServerCertThumbprint"] = $publishProfile.ClusterConnectionParameters["ServerCertThumbprint"]
        }
        else
        {
            throw (Get-VstsLocString -Key PublishProfileRequiredServerThumbprint)
        }
    }

    write-output $connectedServiceEndpoint

    # Connect to cluster
    $certificate = Connect-ServiceFabricClusterFromServiceEndpoint -ClusterConnectionParameters $clusterConnectionParameters -ConnectedServiceEndpoint $connectedServiceEndpoint

我希望将连接属性传递给Connect-ServiceFabricClusterFromServiceEndpoint函数,以便可以在群集上执行操作。

0 个答案:

没有答案