【问题标题】:How can i access Git Repo from Azure PowerShell when im in a Release Pipeline我在发布管道中时如何从 Azure PowerShell 访问 Git Repo
【发布时间】:2019-01-25 09:41:31
【问题描述】:

当我执行发布管道时,我有一个 Powershell 任务,但它说该目录不是 git 存储库,我尝试使用发布管道变量,但它似乎不起作用。

try
{

"Initiated"
Set-Location "$(System.ArtifactsDirectory)"
git remote add target https://maliranguesnunezcontractor@dev.azure.com/maliranguesnunezcontractor/PDemo/_git/PDemo
"Added target"

}
catch [System.Management.Automation.CommandNotFoundException]
{
    "Error"
}

【问题讨论】:

  • 如果我理解正确,那么您只是试图从 Powershell 访问 git。剧本至少说明了这一点。参考THIS
  • 你能分享你的错误日志吗?你是使用内联 PowerShell 还是从文件中使用 PowerShell?

标签: git powershell azure-devops azure-pipelines


【解决方案1】:

我得到了答案,问题是文档中描述的环境变量的格式不起作用,最后我能够找到发布管道用于将位置更改为包含存储库的文件夹的格式以及如何得到它,这就是答案:

Function Get-EnvironmentVariable {
    param([string]$Name)

    Return [Environment]::GetEnvironmentVariable($Name)
}

try
{

"Initiated"
$SystemToken = Get-EnvironmentVariable -Name 'SYSTEM_ARTIFACTSDIRECTORY'
Set-Location $SystemToken\gitFolder
"Chnged Location"

}
catch [System.Management.Automation.CommandNotFoundException]
{
    "Error"
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-17
    • 1970-01-01
    • 2020-08-11
    • 2019-09-19
    • 1970-01-01
    • 1970-01-01
    • 2023-02-10
    • 1970-01-01
    相关资源
    最近更新 更多