git - 在 gitlab 中发布 Maven
问题描述
我们正在尝试使用 maven 执行 maven 版本。我们使用gitlab作为我们的 CI 工具。问题是当我们尝试执行 maven 发布时,maven 无法将pom.xml更新到下一次迭代。
谷歌无法回答我的问题。我尝试过的是:
- 尝试检查尝试推送的用户的权限(对 repo 具有主访问权限并且分支受到保护)
- 大师可以在我的仓库中推送受保护的分支。
下面是我的 .gitlab-ci.yml 文件-
Maven_Release:
stage: Maven_Release
image: maven_Build:Latest
script:
- git config --global user.name "username"
- git config --global user.email "Email"
- git checkout -f master
- git remote set-url origin https://gitlab.com/test1/project/${CI_PROJECT_NAME}.git
- mkdir -p ~/.ssh
- echo "$SSH_PRIVATE_KEY" > /root/.ssh/id_rsa
- ssh-keyscan -p 10022 gitlab.com >> ~/.ssh/known_hosts
- mvn -B -s settings.xml -DdeployAtEnd=false -Dmaven.site.deploy.skip=true -Dresume=false -DautoVersionSubmodules=true -DdryRun=false -Djsse.enableSNIExtension=false -Dmaven.test.skip=true -DreleaseVersion=1.0.0 -DdevelopmentVersion=1.0.1 -DskipITs -DscmCommentPrefix="[ci skip]" release:prepare release:perform
when: manual
only:
- master
我尝试运行此作业,它能够部署,标记版本,但由于以下错误,它无法将 pom.xml 版本更改为下一次迭代,
[INFO] Checking in modified POMs...
[INFO] commit done: [ci skip]prepare release REL_xxxxx
[INFO] push changes to remote... refs/heads/master:refs/heads/master
[INFO] fetch url: https:/usrname:password@gitlabt.com/test/project/projectname.git
[INFO] push url: https:/usrname:password@gitlabt.com/test/project/projectname.git
[INFO] REJECTED_OTHER_REASON - RemoteRefUpdate[remoteName=refs/heads/master, REJECTED_OTHER_REASON, (null)...xx3xxx9c7cdc6dxx, fastForward, srcRef=refs/heads/master, message="pre-receive hook declined"]
[INFO] Tagging release with the label REL_xxxxx...
[INFO] push tag [REL_xxxxxx] to remote...
[INFO] fetch url: https:/usrname:password@gitlabt.com/test/project/projectname.git
[INFO] push url: https:/usrname:password@gitlabt.com/test/project/projectname.git
[INFO] OK - RemoteRefUpdate[remoteName=refs/tags/REL_xxxxx, OK, (null)...c5ce4d1fdf5f0a9415d9f02a48aab4f536eab52c, fastForward, srcRef=refs/tags/REL_xxxxx, message=null]
[INFO] Transforming 'project name'...
[INFO] Transforming 'Rproject'...
[INFO] Transforming 'project'...
[INFO] Updating project name to xxx-SNAPSHOT
[INFO] Not removing release POMs
[INFO] Checking in modified POMs...
[INFO] commit done: [ci skip]prepare for next development iteration
[INFO] push changes to remote... refs/heads/master:refs/heads/master
[INFO] fetch url: https:/usrname:password@gitlabt.com/test/project/projectname.git
[INFO] push url: https:/usrname:password@gitlabt.com/test/project/projectname.git
[INFO] REJECTED_OTHER_REASON - RemoteRefUpdate[remoteName=refs/heads/master, REJECTED_OTHER_REASON, (null)...1xxxxx541baf208dxxxd, fastForward, srcRef=refs/heads/master, message="pre-receive hook declined"]
[INFO] Release preparation complete.
[INFO]
[INFO] --- maven-release-plugin:2.5.1:perform (default-cli) @ mobile-interface-parent ---
解决方案
你开始:
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > /root/.ssh/id_rsa
ssh-keyscan -p 10022 gitlab.com >> ~/.ssh/known_hosts
这非常适合提供具有开发人员权限的正确 SSH 密钥以推回 GitLab 存储库(或具有相同权限的部署密钥)
但是……你不使用它!
git remote set-url origin https://gitlab.com/test1/project/${CI_PROJECT_NAME}.git
这是一个 https URL,而不是 SSH URL(ssh://git@gitlabt.com/test/project/projectname.git
或git@gitlabt.com:test/project/projectname.git
)。
(我假设gitlabt.com
是一个错字,你实际上看到了gitlab.com
)
任何 https URL 都将使用git config credential.helper
具有为该 URL 存储的凭据的 。这些凭据可能不是允许mvn release:prepare
推回 GitLab 存储库的正确凭据。
检查您的pom.xml
: 它可以将 URLmvn release
与该scm
部分一起提供:
<scm>
<developerConnection>scm:git:ssh://git@gitlab.com:/test1/project/${CI_PROJECT_NAME}.git</developerConnection>
</scm>
developerConnection
如果您希望自己~/.ssh/id_rsa
真正有用,请确保其中包含 SSH URL。
我给出了不同的电子邮件 ID。但是 maven 无法找出确切的问题并给出了 put 作为“
REJECTED_OTHER_REASON - RemoteRefUpdate
”。
因此,我尝试提供其他电子邮件 ID,并且效果很好。此外,在 GitLab 我尝试修改 push
rules :::: project settings>Repository>push Rules
。
如果我们需要使用不同的电子邮件地址,我也删除了提交者限制。
推荐阅读
- javascript - 挂钩 window.location.* assignments 和 window.location.assign
- polymorphism - 哪些语言(如果有)实现 rank-2 参数多态性,为什么不实现 ML?
- stanford-nlp - zsh 和 Mac 用户的安装手册应该有一个编辑
- ios - 上传数据后获取内部URI存储位置(gs://)
- php - WordPress插件中的ReactPHP阻塞过程
- arrays - 如何使用标签中的用户输入打印随机结果?
- intellij-idea - 如何更改远程主机工具中的文件前景色 - PhpStorm
- go - 无法为 rest api 手动设置查询参数(使用 mux)
- java - Intellij IDEA 中 Apache POI 的依赖关系问题。不一致的错误
- r - 在 R 中查找事件的顺序和顺序