gpt4 book ai didi

Azure Pipeline Maven 版本 :perform fails with "The git-clone command failed."

转载 作者:行者123 更新时间:2023-12-05 04:35:52 24 4
gpt4 key购买 nike

目前,我尝试构建一个 Spring Boot 应用程序并使用 Azure Pipelines 和 maven-release-plugin 进行发布。

我的 Azure Pipeline YAML 如下所示:

- stage: BuildRelease
condition: true
displayName: Building a Release with Maven
jobs:
- job: BuildReleaseJob
displayName: Create a Maven release with version $(releaseVersion)
steps:
- checkout: self
persistCredentials: true

- task: MavenAuthenticate@0
displayName: 'Authenticate to Maven'
inputs:
artifactsFeeds: 'ciam'

- task: Bash@3
displayName: Set Git Credentials
inputs:
targetType: 'inline'
script: |
git config --global user.email "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ec958399ac89948d819c8089c28f8381" rel="noreferrer noopener nofollow">[email protected]</a>"
git config --global user.name "Azure Pipeline Release"
git checkout develop

- task: Bash@3
displayName: Maven Clean & Prepare Release
inputs:
targetType: 'inline'
script: |
mvn --batch-mode release:clean release:prepare -DscmCommentPrefix=***NO_CI***

- task: Bash@3
displayName: Maven Perform Release
inputs:
targetType: 'inline'
script: |
mvn --batch-mode release:perform -DscmCommentPrefix=***NO_CI***

我还在 Azure Dev 中向项目集合构建服务 (MyCompany) 添加了允许贡献、创建分支、创建标记和读取权限Ops 项目设置 -> 存储库 -> -> 安全

因此一切正常,直到最后一个任务执行release:perform显示的错误是:

[INFO] Executing: /bin/sh -c cd /home/vsts/work/1/s/target && git clone --branch projectName-0.0.36 https:********@dev.azure.com/MyCompany/Project/_git/projectName-service /home/vsts/work/1/s/target/checkout
[INFO] Working directory: /home/vsts/work/1/s/target
[ERROR] The git-clone command failed.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.136 s
[INFO] Finished at: 2022-02-01T14:18:31Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:perform (default-cli) on project projectName-service: Unable to checkout from SCM
[ERROR] Provider message:
[ERROR] The git-clone command failed.
[ERROR] Command output:
[ERROR] Cloning into '/home/vsts/work/1/s/target/checkout'...
[ERROR] fatal: could not read Password for 'https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dfb2a6bcb0b2afbeb1a69fbbbaa9f1bea5aaadbaf1bcb0b2" rel="noreferrer noopener nofollow">[email protected]</a>': terminal prompts disabled
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

有人能指出我做错的地方吗?

之后,在SCM中构建并提交git标签

更新我尝试在批处理内联脚本中执行 Maven 在发布执行中尝试执行的操作,并且它确实有效。现在我更困惑了。

    - task: Bash@3
displayName: TestClone
inputs:
targetType: inline
script: |
ls -laf /home/vsts/work/1/s/target/checkout
/bin/sh -c cd '/home/vsts/work/1/s/target' && 'git' 'clone' '--depth' '1' '--branch' 'myaccount-service-0.0.43' 'https://$(System.AccessToken)@dev.azure.com/kiongroup/CxP/_git/myaccount-service' 'checkout'
cd /home/vsts/work/1/s/target/checkout
ls

输出是:

ls: cannot access '/home/vsts/work/1/s/target/checkout': No such file or directory
Cloning into 'checkout'...
Note: switching to '1653266b5f151fd6137b7b579044eef1867d8d5b'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

git switch -c <new-branch-name>

Or undo this operation with:

git switch -

Turn off this advice by setting config variable advice.detachedHead to false

/home/vsts/work/_temp/358629de-4b6b-4548-942e-f9a05281c5a5.sh: line 3: cd: /home/vsts/work/1/s/target/checkout: No such file or directory
Dockerfile
README.md
azure-pipelines.yml
checkout
docker
mvnw
mvnw.cmd
pom.xml
pom.xml.releaseBackup
postman
release.properties
src
target

最佳答案

我能够在不使用 SSH 身份验证的情况下修复上述问题。通过指定组织名称作为用户名,SystemAccessToken作为密码,release:perform能够成功运行:

- task: Maven@3
displayName: Perform release
inputs:
mavenPomFile: 'pom.xml'
options: '-Dusername="<name of your DevOps organisation>" -Dpassword="$(System.AccessToken)"'

关于Azure Pipeline Maven 版本 :perform fails with "The git-clone command failed.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70946651/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com