我的目标是通过 TFS 任务“ ”在远程服务器上执行 PowerShell 文件,PowerShell on Target Machines到目前为止我采取的步骤是:
构建和远程服务器都已启用
Enable-PSRemoting -Force
Run Code Online (Sandbox Code Playgroud)
还添加了 trusthost 服务器 IP
Set-Item wsman:\localhost\client\trustedhosts *
Run Code Online (Sandbox Code Playgroud)
和
Restart-Service WinRM
Run Code Online (Sandbox Code Playgroud)
完成上述所有步骤后,TFS 任务仍然出现以下错误
##[错误]连接到远程服务器“远程服务器 IP”失败,并显示以下错误消息客户端无法连接到请求中指定的目标。验证目标上的服务正在运行并且正在接受请求。请查阅在目标(最常见的是 IIS 或 WinRM)上运行的 WS-Management 服务的日志和文档。如果目标是 WinRM 服务,请在目标上运行以下命令来分析和配置 WinRM 服务:“winrm Quickconfig”。有关详细信息,请参阅 about_Remote_Troubleshooting 帮助主题。
原因是什么或者我错过了什么。
目前,我的 YAML 管道和应用程序的源代码位于两个不同的分支中。
我试图找到证据证明正在检查的确实是源代码的分支,而不是我的管道的分支。
我看到末尾的签出调用git fetch是针对特定的提交,而不是针对指定的分支名称。
这是我的资源定义:
resources:
repositories:
- repository: RepoName
type: git
name: 'MyRepository' # repository in Azure DevOps
trigger:
branches:
include:
- UAT
Run Code Online (Sandbox Code Playgroud)
在我的一个步骤中,我做了一个checkout: RepoName.
我本来期待git checkout UAT在拉出源代码后,但正如所说,我看到了特定提交的签出。
我如何确定正在检查哪个分支?
我有一个用例,我想在 yaml 管道中使用用户名和密码的管道参数。对于用户名来说很简单,因为我只需在参数部分添加以下内容。
parameters:
- name: Username
type: string
displayName: Username(Email)
Run Code Online (Sandbox Code Playgroud)
我还想使用密码作为管道参数,但我还没有找到将其声明为秘密的方法。有没有办法像变量一样使用管道参数作为秘密?到目前为止,我找到了一个解决方法,将一个变量声明为秘密,并在每次运行之前更新该变量。但这不是最好的体验。也许我错过了文档中的某些内容?
如果它像下面的代码一样工作那就太棒了:
parameters:
- name: Username
type: string
displayName: Username(Email)
- name: Password
type: secret
displayName: Password
Run Code Online (Sandbox Code Playgroud) 我收到的错误消息是Error: The agent request is not running because all potential agents are running other requests. Current position in queue: 1
当我使用 Microsoft 代理执行构建定义时,会导致上述错误。构建执行花了几天时间,而且已经很多了。有人可以帮我解决这个问题吗?
我尝试使用 Microsoft 代理“Azure pipelines”的场景:
我正在为 python 包构建创建 Azure DevOps 管道,但任务 ArchiveFiles@2 失败。
- stage: Build
jobs:
- job: BuildApp
pool:
vmImage: 'ubuntu-latest'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Build.SourcesDirectory)'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
verbose: true
Run Code Online (Sandbox Code Playgroud)
错误日志是这样的
Found 20 files
Archiving file: .env_sample
... 21 more ...
##[debug]Checking for archive destination folder:/__w/1/a
##[debug]Creating archive with zip: /__w/1/a/1009007.zip
##[debug]which 'zip'
##[debug]not found
##[debug]Unable to locate executable file: 'zip'. Please verify either the file path exists or the file can be found within a …Run Code Online (Sandbox Code Playgroud) 我尝试使用or表达式在模板上定义布尔值,如下所示:
parameters:
- name: A
default: true
- name: B
default: false
stages:
- template: bacon.yml@template
parameters:
booleanParameter: or(eq(${{ parameters.A }}, true), eq(${{ parameters.B}}, true))
Run Code Online (Sandbox Code Playgroud)
在我看来,它应该工作得很好,但我不断收到同样的错误:
The 'booleanParameter' parameter value 'or(eq(True, true), eq(False, true))' is not a valid Boolean.
Run Code Online (Sandbox Code Playgroud)
我尝试了一些语法的小变化,所有这些都会导致相同的错误。
我在这里缺少什么?
更新:
是否可以添加或更改在 Azure DevOps 上执行管道的命令?
在Visual Studio Code上本地运行我的程序,我确实得到了输出。
但是,在Azure DevOps上运行我的GitHub原始分支不会产生任何输出。
我遵循了 Stack Overflow 的答案,该答案引用了GitHub 问题的解决方案。
我已经实现了以下内容,但 Azure 的原始日志在我的 Python 上返回空白logging。
test_logging.py:
import logging
filename = "my.log"
global logger
logger = logging.getLogger()
logger.setLevel(logging.INFO)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
open(filename, "w").close() # empty logs
fileHandler = logging.FileHandler(filename)
fileHandler.setFormatter(formatter)
fileHandler.setLevel(logging.INFO)
logger.addHandler(fileHandler)
logger.error('TEST')
# fetch logs
with open(filename, "r") as fileHandler:
logs = [log.rstrip() for log in …Run Code Online (Sandbox Code Playgroud) 我们拥有适用于 iOS 和 UWP 项目的 Xamarin.Forms 解决方案。我们使用 Azure 管道来构建 iOS 项目。直到昨天一切都工作正常。现在,构建在 NuGet Restore 步骤失败,并出现错误:
##[错误]nuget 命令失败,退出代码(1) 和错误(/Users/runner/work/1/s/"MyProjectName.UWP".csproj :错误 MSB4057:目标“_IsProjectRestoreSupported”不存在于项目。
我们可以看到,尝试在 Mac OS 构建主机上恢复 UWP 项目的 NuGet 包时会出现问题。图片:macOS-11
解决方法是将其从解决方案中排除,但我们将其用于测试目的,这对我们来说不是一个好的选择。
我在自托管代理上有一个 Azure Pipeline我使用此任务
- task: AzureCLI@2
displayName: Azure CLI task with Python SDK
inputs:
azureSubscription: 'SUBSCRIPTION-SERVICE-CONNECTION'
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
python ./magic-script.py
Run Code Online (Sandbox Code Playgroud)
这样我就可以使用凭据来验证Azure Python SDK:
client = get_client_from_cli_profile(GraphRbacManagementClient)
Run Code Online (Sandbox Code Playgroud)
当我将此过程转移到MS 托管代理时,我收到此错误:
File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/azure/common/client_factory.py", line 85, in get_client_from_cli_profile
with_tenant=True,
File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/azure/common/credentials.py", line 98, in get_azure_cli_credentials
cred, subscription_id, tenant_id = profile.get_login_credentials(resource=resource)
File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/azure/cli/core/_profile.py", line 335, in get_login_credentials
credential = self._create_credential(account, client_id=client_id)
File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/azure/cli/core/_profile.py", line 592, in _create_credential
return identity.get_service_principal_credential(username_or_sp_id)
File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/azure/cli/core/auth/identity.py", line 185, in get_service_principal_credential
entry …Run Code Online (Sandbox Code Playgroud) 最近正在研究 Azure DevOps 模板。并遇到了这种双花括号语法。只是想知道如何在 Azure DevOps 中使用双花括号。
看过一些关于相同内容的帖子。
可以说,我在组中定义了一个变量,如下所示。
我们还可以在 yaml 文件中定义变量,如下所示。
variables:
- name: BuildConfiguration
value: 'Release'
- name: finalBuildArtifactName
value: 'TempFolderName'
Run Code Online (Sandbox Code Playgroud)
什么时候应该使用双大括号语法?
我有关于并使用以下方法来引用变量的想法。
与上述两个相比,我们可以用双花括号完成什么?
让 yaml 管道中的东西正常工作非常困难。进行更改、签入、运行管道、查看结果并再次返回。这非常耗时,而且至少可以说并不顺利。
azure-pipelines ×10
azure-devops ×7
python ×2
azure ×1
logging ×1
powershell ×1
tfs-2018 ×1
windows ×1
xamarin.ios ×1