简体   繁体   English

Jenkins 报告 Github 凭据的用户名和密码不正确

[英]Jenkins reports incorrect username and password for Github credentials

Problem Statement: I am getting error like " stderr: remote: Invalid username or password. " for Jenkins build.问题陈述:对于 Jenkins 版本,我收到类似“ stderr: remote: Invalid username or password. ”的错误。

My Jenkinsfile is as follows:我的Jenkinsfile如下:

node {节点{

    stage('SCM Checkout') {
        git 'https://github.com/xxxxxxxxxxxx/java-app'
    }
        stage('Compile Package'){
        // Get path of Maven Home
        def MavenHome = tool name: 'MVN_HOME', type: 'maven'
        sh "${MavenHome}/bin/mvn package"
    }
}

I have saved my credentials in Jenkins as below:我已将我的凭据保存在 Jenkins 中,如下所示: 在此处输入图像描述

My Jenkins looks like below:我的 Jenkins 如下所示:

在此处输入图像描述

Unfortunately, I am getting error/log output as below:不幸的是,我收到错误/日志 output 如下:

Checking out git https://github.com/xxxxxxxxxxx/java-app into /var/lib/jenkins/workspace/My-app-Jenkinspipeline@script to read Jenkinsfile
using credential githubcredentials
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/xxxxxxxxxxx/java-app # timeout=10
Fetching upstream changes from https://github.com/xxxxxxxxxxx/java-app
 > git --version # timeout=10
using GIT_ASKPASS to set credentials Github Credentials
 > git fetch --tags --force --progress -- https://github.com/xxxxxxxxxxx/java-app +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 691f79125928ce480176fd04e96c4f61297c8051 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 691f79125928ce480176fd04e96c4f61297c8051 # timeout=10
Commit message: "Added Checkout step"
 > git rev-list --no-walk 371a72a8024ce467f287f5297efaa5662c3c5181 # timeout=10
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/My-app-Jenkinspipeline
[Pipeline] {
[Pipeline] stage
[Pipeline] { (SCM Checkout)
[Pipeline] git
No credentials specified
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/xxxxxxxxxxx/java-app # timeout=10
Fetching upstream changes from https://github.com/xxxxxxxxxxx/java-app
 > git --version # timeout=10
 > git fetch --tags --force --progress -- https://github.com/xxxxxxxxxxx/java-app +refs/heads/*:refs/remotes/origin/* # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://github.com/xxxxxxxxxxx/java-app
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:909)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1131)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1167)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:125)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:93)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:80)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --force --progress -- https://github.com/xxxxxxxxxxx/java-app +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/xxxxxxxxxxx/java-app/'

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2430)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2044)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:81)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:569)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:907)
    ... 11 more
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE

Please assist as I want to understand why I am getting an incorrect username and password even though I can login with the same credentials to Github请协助,因为我想了解为什么我得到的用户名和密码不正确,即使我可以使用相同的凭据登录 Github

To get SCM Checkout working we need to add credentials.要使 SCM Checkout 正常工作,我们需要添加凭据。 I did as below:我做了如下:

git changelog: false, credentialsId: 'githubcredentials', poll: false, url: 'https://github.com/xxxxxxxxxxxx/java-app'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM