小编Pet*_*tor的帖子

为什么我的 VSTS 自定义任务通过并退出代码为 1?

我有以下烦人的问题。我的自定义 VSTS 构建任务不会失败。它总是通过,而 $LASTEXITCODE 不为零。

代码按预期执行。它在日志中生成错误。尽管如此,该步骤仍然成功并且构建/发布继续。

截屏: 截屏 我还包含了一个带有退出代码的写入主机,它也显示退出代码 1。

代码:

Try {
    ....
    #Loop through the server list
    Foreach ($Server in $machines) 
    {
        # Use SSL or not    
        If($UseSSL -eq $true) 
        {
            Write-Host "Connecting to $Server using a SSL connection (TCP/5986), Skip CA Check: $CheckCA ..."
            $s = New-PSSession -ComputerName $Server -Credential $Cred -UseSSL -SessionOption $SessionOptions
        }
        Else
        {
            Write-Host "Connecting to $Server with an unsecure connection (TCP/5985) ..."
            $s = New-PSSession -ComputerName $Server -Credential $Cred
        }

        # Run
        $ExitCode …
Run Code Online (Sandbox Code Playgroud)

tfs azure-devops azure-pipelines-build-task azure-pipelines-release-task

5
推荐指数
1
解决办法
7859
查看次数