我正在使用 Jenkins 和 Git SCM 在 GitHub 上构建一个项目。我告诉它构建一个已被强制推送的分支,但现在我的构建失败了,因为每次启动时它都会尝试构建远程上不再存在的提交:
19:30:31 Started by user admin
19:30:31 Building in workspace /Users/Shared/Jenkins/Home/workspace/myproject
19:30:31 [WS-CLEANUP] Deleting project workspace...
19:30:31 [WS-CLEANUP] Done
19:30:31 [ssh-agent] Looking for ssh-agent implementation...
19:30:31 [ssh-agent] Java/JNR ssh-agent
19:30:31 [ssh-agent] Skipped registering BouncyCastle, not running on a remote agent
19:30:31 [ssh-agent] Started.
19:30:31 [ssh-agent] Using credentials git (id_rsa)
19:30:31 Cloning the remote Git repository
19:30:31 Using shallow clone
19:30:31 Avoid fetching tags
19:30:31 Cloning repository https://github.com/myorg/myproject.git
19:30:31 > git init /Users/Shared/Jenkins/Home/workspace/myproject # timeout=10
19:30:31 Fetching upstream changes from https://github.com/myorg/myproject.git
19:30:31 > git --version # timeout=10
19:30:31 using GIT_ASKPASS to set credentials Jenkins GitHub login
19:30:31 > git fetch --no-tags --progress https://github.com/myorg/myproject.git +refs/heads/*:refs/remotes/origin/* --depth=1
19:30:43 > git config remote.origin.url https://github.com/myorg/myproject.git # timeout=10
19:30:43 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
19:30:43 > git config remote.origin.url https://github.com/myorg/myproject.git # timeout=10
19:30:43 Fetching upstream changes from https://github.com/myorg/myproject.git
19:30:43 using GIT_ASKPASS to set credentials Jenkins GitHub login
19:30:43 > git fetch --no-tags --progress https://github.com/myorg/myproject.git +refs/heads/*:refs/remotes/origin/* --depth=1
19:30:44 Seen branch in repository origin/master
19:30:44 Seen branch in repository origin/stable
19:30:44 Seen 2 remote branches
19:30:44 FATAL: Walk failure.
19:30:44 org.eclipse.jgit.errors.MissingObjectException: Missing commit 7253e881f2e53b7338b371cf979eccae7e9f68a7
19:30:44 at org.eclipse.jgit.internal.storage.file.WindowCursor.open(WindowCursor.java:159)
19:30:44 at org.eclipse.jgit.revwalk.RevWalk.getCachedBytes(RevWalk.java:903)
19:30:44 at org.eclipse.jgit.revwalk.RevCommit.parseHeaders(RevCommit.java:155)
19:30:44 at org.eclipse.jgit.revwalk.PendingGenerator.next(PendingGenerator.java:147)
19:30:44 at org.eclipse.jgit.revwalk.StartGenerator.next(StartGenerator.java:184)
19:30:44 at org.eclipse.jgit.revwalk.RevWalk.next(RevWalk.java:435)
19:30:44 at org.eclipse.jgit.revwalk.RevWalk.iterator(RevWalk.java:1322)
19:30:44 Caused: org.eclipse.jgit.errors.RevWalkException: Walk failure.
19:30:44 at org.eclipse.jgit.revwalk.RevWalk.iterator(RevWalk.java:1324)
19:30:44 at hudson.plugins.git.util.GitUtils$1.invoke(GitUtils.java:182)
19:30:44 at hudson.plugins.git.util.GitUtils$1.invoke(GitUtils.java:146)
19:30:44 at org.jenkinsci.plugins.gitclient.AbstractGitAPIImpl.withRepository(AbstractGitAPIImpl.java:29)
19:30:44 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.withRepository(CliGitAPIImpl.java:64)
19:30:44 at hudson.plugins.git.util.GitUtils.filterTipBranches(GitUtils.java:146)
19:30:44 at hudson.plugins.git.util.DefaultBuildChooser.getAdvancedCandidateRevisions(DefaultBuildChooser.java:250)
19:30:44 at hudson.plugins.git.util.DefaultBuildChooser.getCandidateRevisions(DefaultBuildChooser.java:54)
19:30:44 at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:995)
19:30:44 at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1098)
19:30:44 at hudson.scm.SCM.checkout(SCM.java:496)
19:30:44 at hudson.model.AbstractProject.checkout(AbstractProject.java:1278)
19:30:44 at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
19:30:44 at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
19:30:44 at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
19:30:44 at hudson.model.Run.execute(Run.java:1728)
19:30:44 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
19:30:44 at hudson.model.ResourceController.execute(ResourceController.java:98)
19:30:44 at hudson.model.Executor.run(Executor.java:405)
19:30:44 Archiving artifacts
19:30:44 Finished: FAILURE
我怎样才能告诉詹金斯忘记这个特定的 SHA 并转向其他的 SHA?
答案1
你好,你可以在 Jenkins GIT->要构建的分支->分支说明符中添加要由 Jenkins 拉取的分支
它将解决你的问题