我正在尝试运行一个简单的JenkinsFile
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'java -version'
}
}
stage('Test') {
steps {
echo 'Testing..'
}
}
}
}
正如你所看到的,这里并不多见。但即使我配置了一个存储库所有者的帐户,我也会收到一个禁止的错误。我发布了错误,因为它只是将username/repository
更改为my-account/my-repo
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/my-account/my-repo.git # timeout=10
Fetching without tags
Fetching upstream changes from https://github.com/my-account/my-repo.git
> git --version # timeout=10
using GIT_ASKPASS to set credentials Pull Request Builder
> git fetch --no-tags --progress https://github.com/my-account/my-repo.git +refs/heads/master:refs/remotes/origin/master
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://github.com/my-account/my-repo.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:817)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1084)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1115)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:109)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:83)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:73)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
at hudson.security.ACL.impersonate(ACL.java:221)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:473)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:748)
Caused by: hudson.plugins.git.GitException: Command "git fetch --no-tags --progress https://github.com/my-account/my-repo.git +refs/heads/master:refs/remotes/origin/master" returned status code 128:
stdout:
stderr: error: The requested URL returned error: 403 Forbidden while accessing https://github.com/my-account/my-repo.git/info/refs
fatal: HTTP request failed
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1924)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1643)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:352)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:815)
... 13 more
答案 0 :(得分:0)
一种解决方案是在签出代码时切换到SSH。(更容易且始终有效)
如果不能选择切换,则使用用户名/密码或更高的用户名/密码,生成一个密钥,然后使用该密钥来访问您的存储库。
由于您在猜测请求checkout scm
中使用了它,因此默认情况下它将使用https-,这对我使用403失败,不幸的是,该问题与我的git是旧版本1.7有关/1.8不确定。升级就像一个魅力:)
希望它会有所帮助:)