Jenkins GitHub plugin, readTrusted stage fails with 404 if the tag was pushed to origin/master

北城余情 提交于 2021-01-29 09:03:48

问题


Jenkins build job started to fail if the tag was pushed to the origin/master. We're using a private repository, credentials are Ok, validate works correctly. In case of commit to master build successfully build.

Steps to reproduce:

  • git push origin <tagname>
  • press build job -> will lead to error described below in log section

Pipeline Steps:

  • Start of Pipeline - (5.3 sec in block) __________Success
  • Read trusted file from SCM - (0.76 sec in self) _ Failed

If I remove the tag and commit some changes the new build will be Successfully completed

Here is the log of the job:

17:06:49 Connecting to https://api.github.com using ...build/****** (*** GitHub Build User)
ERROR: Could not do lightweight checkout, falling back to heavyweight
java.io.FileNotFoundException: https://raw.githubusercontent.com/***/myrepository/7ae6037fe8/Jenkinsfile?token=ALR5FLRJSV5UVVRE442KWCC6C42PA
    at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:243)
    at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
    at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:25)
    at org.kohsuke.github.Requester.asStream(Requester.java:340)
Caused: org.kohsuke.github.GHFileNotFoundException: 404: Not Found

    at org.kohsuke.github.Requester.handleApiError(Requester.java:699)
    at org.kohsuke.github.Requester.asStream(Requester.java:342)
    at org.kohsuke.github.GHContent.read(GHContent.java:117)
    at org.jenkinsci.plugins.github_branch_source.GitHubSCMFile.content(GitHubSCMFile.java:183)
    at jenkins.scm.api.SCMFile.contentAsString(SCMFile.java:335)
    at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:107)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:299)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:427)

Here is the git plugin configuration:

Previously tags were building fine, but can't what was changed.

What can be a reason for such error, is it no permissions to access the file?

Update1: The problem is not with tag, but with Rebuild the same build. When Build Now button triggres again, this error will reproduce

Thanks in advance


回答1:


I would clean the workspace at the very beginning of the stage. On a traditional free style job I would try the Workspace Cleanup plugin https://wiki.jenkins.io/display/JENKINS/Workspace+Cleanup+Plugin

on a Jenkins pipeline DSL I would use

            checkout([$class: 'GitSCM',
                branches: scm.branches,
                extensions:  scm.extensions + [[$class: 'WipeWorkspace']],
                userRemoteConfigs: scm.userRemoteConfigs
            ])


来源:https://stackoverflow.com/questions/59670453/jenkins-github-plugin-readtrusted-stage-fails-with-404-if-the-tag-was-pushed-to

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!