如何使用&#34解决Git获取状态码128;您的帐户被暂停"

时间:2018-04-06 17:16:52

标签: jenkins-pipeline github-enterprise

我有一个Jenkins master,有两个构建代理,其中一个是Windows框,另一个是Mac。以下Jenkinsfile尝试从 Github Enterprise 服务器检出git存储库。

properties([
    parameters([
        string(
            name: 'GIT_URL',
            defaultValue: params.GIT_URL?:'https://github.com/',
            description: 'URL to clone the Git repo.'
        ),
        string(
            name: params.GIT_SELECTOR?:'GIT_SELECTOR',
            defaultValue: params.GIT_SELECTOR?:'refs/heads/master',
            description: 'Branch, tag or commit.'
        ),
        [
            $class: 'CredentialsParameterDefinition',
            name: 'GIT_CREDENTIALS',
            credentialType: 'com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl',
            defaultValue: params.GIT_CREDENTIALS?:'',
            description: 'User and password to clone the Git repository',
            required: true
        ]
    ])
])

node('build'){

    stage('Clean'){
        cleanDir()
        sh('''
            pwd
            ls -la
        ''')
    }

    stage('Identify host'){
        def host = command("hostname")
        def hostOS = isUnix()?'mac':'win'
        currentBuild.description = " ${hostOS}-host"
    }

    stage('Check out'){
        checkout([
            $class: 'GitSCM',
            branches: [
                [name: params.GIT_SELECTOR]
            ],
            extensions: [
                [
                    $class: 'RelativeTargetDirectory',
                    relativeTargetDir: 'app'
                ]
            ],
            userRemoteConfigs: [
                [
                    credentialsId: params.GIT_CREDENTIALS,
                    url: GIT_URL
                ]
            ]
        ])
    }
}

当构建进入Windows框时它会成功,但它最近开始在Mac上失败,没有明显的原因。我得到的错误是:

Cloning the remote Git repository
Cloning repository https://github.acme.com/Acme/foo-project.git
 > git init /Jenkins/workspace/.tests/test-checkout/app # timeout=10
Fetching upstream changes from https://github.acme.com/Acme/foo-project.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials my-git-credentials
 > git fetch --tags --progress https://github.acme.com/Acme/foo-project.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress https://github.acme.com/Acme/foo-project.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: remote: Your account is suspended. Please check with your installation administrator.
fatal: unable to access 'https://github.acme.com/Acme/foo-project.git/': The requested URL returned error: 403

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1877)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1596)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:348)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:545)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:153)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:146)
    at hudson.remoting.UserRequest.perform(UserRequest.java:153)
    at hudson.remoting.UserRequest.perform(UserRequest.java:50)
    at hudson.remoting.Request$2.run(Request.java:332)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at hudson.remoting.Engine$1$1.run(Engine.java:85)
    at java.lang.Thread.run(Thread.java:745)
    at ......remote call to Channel to /208.83.1.25(Native Method)
    at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1545)
    at hudson.remoting.UserResponse.retrieve(UserRequest.java:253)
    at hudson.remoting.Channel.call(Channel.java:830)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:146)
    at sun.reflect.GeneratedMethodAccessor1126.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:132)
    at com.sun.proxy.$Proxy75.execute(Unknown Source)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1067)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1107)
    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:260)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

注意消息GitExceptiongit fetch的{​​{1}}和status code 128错误。当然,因为它确实在Windows机器上工作,我知道它绝对不是凭证。可能是什么原因造成的?我该怎么看?

编辑:我尝试使用The requested URL returned error: 403从两个从属设备上攻击Github API,而在Windows框中它可以正常工作,在我得到的Mac上:

curl -X GET https://github.acme.com/api/v3/user -H 'Authorization: token *****...****'

2 个答案:

答案 0 :(得分:1)

你可以尝试一些事情:

  • 您的GitHub企业实例将包含详细说明失败身份验证的日志。请咨询管理员,因为他们可能会立即得到答案。

  • 如果您有权与您的用户进行此操作,请尝试使用基本身份验证(例如https://github.acme.com/api/v3/user)从问题框中点击GitHub REST API的经过身份验证的端点 - 如果该命令也因403失败您应该在响应正文和标题中获得有关它的原因的一些信息。

答案 1 :(得分:0)

经过大量的故障排除后,我们发现解决此问题的唯一方法是Mac build agent的硬重启。弹开该框后,发送给它的所有作业都可以再次访问Git服务器。

我无法找到发生这种情况的原因,所以这是迄今为止最好的答案。如果有人对导致这种行为的潜在原因有任何建议,我倾向于将其标记为答案,而不是这个。