gpt4 book ai didi

git - 在使用 Hudson/Jenkins 等 CI 工具时,我如何通过 GitHub(或 GitHub 企业版)成功使用 Maven 发布插件

转载 作者:太空狗 更新时间:2023-10-29 13:33:49 25 4
gpt4 key购买 nike

在使用 Hudson/Jenkins 等 CI 工具时,我如何通过 GitHub(或 GitHub 企业版)成功使用 Maven 发布插件

遇到的问题是

  • 如果 pom.xml 位于子文件夹而不是顶级文件夹中,Maven 不会提交。由于此后续构建失败,标签名称已存在。
  • 尽管在运行 CI 作业的源服务器之间设置了公钥身份验证,但 git push 失败并出现以下错误之一
    • 公钥认证失败
    • 未知服务 git

最佳答案

要使它正常工作,需要做很多事情。

  1. 为了使pom.xml 的子文件夹commit 正常工作,该错误已在Maven 发布插件2.5.1 中得到解决。获取最新的依赖项。以下部分显示了 pom.xml

    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.5.1</version>

    <dependencies>
    <dependency>
    <groupId>org.apache.maven.scm</groupId>
    <artifactId>maven-scm-provider-gitexe</artifactId>
    <version>1.9.2</version>
    </dependency>
    </dependencies>

    <configuration>
    <checkModificationExcludes>
    <checkModificationExclude>pom.xml</checkModificationExclude>
    </checkModificationExcludes>
    </configuration>
    </plugin>
  2. 正确配置 pom.xml 中的 SCM 部分。要使公钥身份验证起作用,请使用 SSH 协议(protocol)。对于 https 协议(protocol),将需要用户名/密码,此答案不包括在内。应该可以通过在服务器部分的 Maven settings.xml 中提供用户/密码来实现。

    <scm>
    <developerConnection>scm:git:ssh://github.com/org/repo.git</developerConnection>
    <url>https://github.com/org/repo</url>
    <tag>HEAD</tag>
    </scm>
  3. 在您的源服务器中创建一个名为 git 的用户。如果您以任何其他用户身份运行,则 developerConnection url 需要包含 git@github.com 而不是 github.com。 Maven 将尝试在 git push 命令中放入一个 git:****** 并且由于服务未知而失败。如果您使用任何其他用户通过 SSH 连接到 github,它将因公钥身份验证失败而拒绝。

  4. 使用 git 作为用户,生成 SSH key 并按照下面的简单步骤进行配置

    https://help.github.com/articles/generating-ssh-keys/

  5. 如下所示编辑您的 Hudson/Jenkins 作业

    • 在源代码管理部分下,提供 git 存储库的 URL。您可能需要将 git 作为协议(protocol),因为某些 CI 安装不支持 https。
    • 在要构建的分支中提及您的分支(例如开发)
    • 单击高级并将相同的分支名称放在“ checkout /merge 到本地分支(可选)”部分

使用 maven 目标运行你的工作 clean compile release:prepare 和 release:perform。它应该有效。

关于git - 在使用 Hudson/Jenkins 等 CI 工具时,我如何通过 GitHub(或 GitHub 企业版)成功使用 Maven 发布插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27019671/

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