如何将 Bitbucket 存储库添加到 jenkins?
How to add Bitbucket repository in to jenkins?
我在 bitbucket 私有存储库中的 rails 代码上有一个 ruby。我已经将我的存储库远程添加到 jenkins 中,如下所示:
https://bitbucket.org/myuser_name/demo_app
后跟凭据:
Kind: username and password
并且我已将 bitbucket 用户名和密码输入其中。
在我保存项目配置之前,我在 Repository URL
下没有遇到任何错误。所以我认为我配置 source code management
正确。但是当我构建项目时出现此错误。
Building in workspace /var/lib/jenkins/workspace/demo_app
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://bitbucket.org/myuser_name/demo_app # timeout=10
Fetching upstream changes from https://bitbucket.org/myuser_name/demo_app
> git --version # timeout=10
using .gitcredentials to set credentials
> git config --local credential.username myuser_name # timeout=10
> git config --local credential.helper store --file=/tmp/git1159546302445779982.credentials # timeout=10
> git -c core.askpass=true fetch --tags --progress https://bitbucket.org/myuser_name/demo_app +refs/heads/*:refs/remotes/origin/*
> git config --local --remove-section credential # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://bitbucket.org/myuser_name/demo_app
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:810)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1066)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1097)
at hudson.scm.SCM.checkout(SCM.java:485)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:607)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1738)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Caused by: hudson.plugins.git.GitException: Command "git -c core.askpass=true fetch --tags --progress https://bitbucket.org/myuser_name/demo_app +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: error: cannot fork() for git credential-store --file=/tmp/git1159545779982.credentials get: Cannot allocate memory
error: cannot fork() for /bin/echo: Cannot allocate memory
fatal: could not read Password for 'https://myuser_name@bitbucket.org': No such device or address
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1719)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1463)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access0(CliGitAPIImpl.java:63)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.execute(CliGitAPIImpl.java:314)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:808)
... 11 more
ERROR: null
Finished: FAILURE
所以我哪里错了?
不知道今天有没有改方法,前段时间不得不在 Bitbucket 中做一个 hook 来执行这个任务:
最好将您的项目包含在部署密钥中,而不是 username/password。
要将部署密钥添加到您的 bitbucket 项目,请转到 https://bitbucket.org/myuser_name/demo_app/admin/deploy-keys/。
将您的密钥添加到 Jenkins。在项目配置页面 'Source Code Management' -> 'Credentials' -> 'Add'。选择 'SSH Username and privat key'。添加您的用户名 'git' 和您的私钥。
我在 bitbucket 私有存储库中的 rails 代码上有一个 ruby。我已经将我的存储库远程添加到 jenkins 中,如下所示:
https://bitbucket.org/myuser_name/demo_app
后跟凭据:
Kind: username and password
并且我已将 bitbucket 用户名和密码输入其中。
在我保存项目配置之前,我在 Repository URL
下没有遇到任何错误。所以我认为我配置 source code management
正确。但是当我构建项目时出现此错误。
Building in workspace /var/lib/jenkins/workspace/demo_app
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://bitbucket.org/myuser_name/demo_app # timeout=10
Fetching upstream changes from https://bitbucket.org/myuser_name/demo_app
> git --version # timeout=10
using .gitcredentials to set credentials
> git config --local credential.username myuser_name # timeout=10
> git config --local credential.helper store --file=/tmp/git1159546302445779982.credentials # timeout=10
> git -c core.askpass=true fetch --tags --progress https://bitbucket.org/myuser_name/demo_app +refs/heads/*:refs/remotes/origin/*
> git config --local --remove-section credential # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://bitbucket.org/myuser_name/demo_app
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:810)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1066)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1097)
at hudson.scm.SCM.checkout(SCM.java:485)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:607)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1738)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Caused by: hudson.plugins.git.GitException: Command "git -c core.askpass=true fetch --tags --progress https://bitbucket.org/myuser_name/demo_app +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: error: cannot fork() for git credential-store --file=/tmp/git1159545779982.credentials get: Cannot allocate memory
error: cannot fork() for /bin/echo: Cannot allocate memory
fatal: could not read Password for 'https://myuser_name@bitbucket.org': No such device or address
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1719)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1463)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access0(CliGitAPIImpl.java:63)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.execute(CliGitAPIImpl.java:314)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:808)
... 11 more
ERROR: null
Finished: FAILURE
所以我哪里错了?
不知道今天有没有改方法,前段时间不得不在 Bitbucket 中做一个 hook 来执行这个任务:
最好将您的项目包含在部署密钥中,而不是 username/password。
要将部署密钥添加到您的 bitbucket 项目,请转到 https://bitbucket.org/myuser_name/demo_app/admin/deploy-keys/。
将您的密钥添加到 Jenkins。在项目配置页面 'Source Code Management' -> 'Credentials' -> 'Add'。选择 'SSH Username and privat key'。添加您的用户名 'git' 和您的私钥。