从私有 bitbucket 仓库和 jenkins 自动构建 maven 项目
Auto build maven project from a private bitbucket repo and jenkins
我一直致力于使用 Jenkins 自动构建 Maven 项目。
手动,从 Jenkins 的 "start build",它工作正常,但来自 bitbucket webhook:
"jenkins_url/bitbucket-hook/",在提交并推送我的 bitbucket 存储库后,我进入了 Jenkins 的 Bitbucket Hook 记录此错误:
FATAL: hudson.plugins.git.GitException: Command "git ls-remote -h -- https://my_username@bitbucket.org/repo.git/" returned status code 128:
stdout:
stderr: remote: Invalid username or password
fatal: Authentication failed for 'https://bitbucket.org/repo.git/'
hudson.plugins.git.GitException: Command "git ls-remote -h -- https://my_username@bitbucket.org/repo.git/" returned status code 128:
stdout:
stderr: remote: Invalid username or password
fatal: Authentication failed for 'https://bitbucket.org/repo.git/'
我正在使用用户名和密码凭据。
希望你能帮助我。
我刚刚找到了解决我自己问题的方法,如果有人需要的话。
只需使用 ssh 访问密钥连接到您的 bitbucket 存储库(不是用户名密码凭据):
--> 通过 su jenkins
或 su -s /bin/bash jenkins
连接到 jenkins 用户
--> 通过 ssh-keygen
在 /var/lib/jenkins/.ssh
下生成你的 ssh 密钥
--> 在 jenkins 全局标识符中复制你的私钥
--> 将您的 public 密钥复制到位桶访问密钥中
并且构建将在两种情况下工作:手动和推送到您的
存储库
(您还需要 jenkins 中的 ssh 发布者插件来放置 bitbucket 主机 ID)。
我一直致力于使用 Jenkins 自动构建 Maven 项目。 手动,从 Jenkins 的 "start build",它工作正常,但来自 bitbucket webhook: "jenkins_url/bitbucket-hook/",在提交并推送我的 bitbucket 存储库后,我进入了 Jenkins 的 Bitbucket Hook 记录此错误:
FATAL: hudson.plugins.git.GitException: Command "git ls-remote -h -- https://my_username@bitbucket.org/repo.git/" returned status code 128:
stdout:
stderr: remote: Invalid username or password
fatal: Authentication failed for 'https://bitbucket.org/repo.git/'
hudson.plugins.git.GitException: Command "git ls-remote -h -- https://my_username@bitbucket.org/repo.git/" returned status code 128:
stdout:
stderr: remote: Invalid username or password
fatal: Authentication failed for 'https://bitbucket.org/repo.git/'
我正在使用用户名和密码凭据。
希望你能帮助我。
我刚刚找到了解决我自己问题的方法,如果有人需要的话。
只需使用 ssh 访问密钥连接到您的 bitbucket 存储库(不是用户名密码凭据):
--> 通过 su jenkins
或 su -s /bin/bash jenkins
--> 通过 ssh-keygen
/var/lib/jenkins/.ssh
下生成你的 ssh 密钥
--> 在 jenkins 全局标识符中复制你的私钥
--> 将您的 public 密钥复制到位桶访问密钥中 并且构建将在两种情况下工作:手动和推送到您的 存储库
(您还需要 jenkins 中的 ssh 发布者插件来放置 bitbucket 主机 ID)。