Azure Pipeline,无法提示,因为终端提示已被禁用 [英] Azure Pipeline, Cannot prompt because terminal prompts have been disabled

查看:51
本文介绍了Azure Pipeline,无法提示,因为终端提示已被禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将管道设置为仅签出与项目相关的特定文件夹,以便减少签出时间.

I am trying to set up my pipeline to only checkout specific folders related to a project so that I can reduce the checkout time.

我正在使用以下在许多其他问题上找到的代码,但似乎无法正常工作.

I am using the following code found on many other questions but I cannot seem to get it to work.

- script: |
    cd $(Build.SourcesDirectory)

    git init
    git remote set-url origin $(Build.Repository.Uri)
    git config core.sparsecheckout true

    echo STARS/Source/ >> .git/info/sparse-checkout

    git pull origin $(Build.SourceBranch)
  displayName: 'Project Specific Checkout'
  env:
    SYSTEM_ACCESSTOKEN: $(System.AccessToken)

我在日志中不断收到以下错误:

I keep getting the following error in the logs:

Reinitialized existing Git repository in C:/Agent001/_work/20/s/.git/
fatal: Cannot prompt because terminal prompts have been disabled.
fatal: could not read Password for 'https://organization@dev.azure.com/...': terminal prompts disabled

我似乎无法弄清楚如何启用终端提示.

I cannot seem to work out how to enable terminal prompts.

更新:

基于@Repcak注释,我更新了代码,但仍然收到终端提示已被禁用错误.

Based on @Repcak comment I updated my code but still receiving the terminal prompts have been disabled error.

推荐答案

实际问题不在于拥有交互式终端,而是与提供访问目标存储库的凭据有关.

The actual issue is not about having an interactive terminal, it is about providing credentials to access the target repository.

要进行的设置取决于您访问存储库的方式(您似乎使用https,是ssh选项吗?)以及某种程度上的测试平台(如果您打算在客户端使用凭据管理器).

The setup to follow depends on how you access the repo (you seem to use https, is ssh an option ?) and to some extent the testing platform, if you intend to use a credential manager on the client side.

  • 通过https:如果 SYSTEM_ACCESSTOKEN 是为您的测试环境生成的PAT,则您必须以某种方式在脚本中使用它,就像输入密码一样.
  • through https : if SYSTEM_ACCESSTOKEN is a PAT generated for your test environment, you have to somehow use it in your script, as you would with a password.

您可以通过在目标url中指定 username:password 来传递它(您在错误消息中张贴的url仅包含 username 部分),也可以进行设置凭据管理器,以便它包含所述登录名的密码,或找到以某种方式颁发身份验证令牌的方法,或...

You can pass the username:password by specifying it in the target url (the url you posted in the error message only has the username part), or set up the credential manager so that it contains the password for said login, or find a way to issue an auth token in some way, or ...

  • 如果您可以切换到ssh访问:为管道设置ssh密钥,然后选择一种在测试平台上部署所述ssh密钥的方法.

这篇关于Azure Pipeline,无法提示,因为终端提示已被禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆