Jenkins报告Github凭据的用户名和密码不正确
问题陈述:对于Jenkins build,我遇到了类似“stderr:remote:无效用户名或密码。”的错误 我的Jenkins文件如下所示: 节点{Jenkins报告Github凭据的用户名和密码不正确,jenkins,Jenkins,问题陈述:对于Jenkins build,我遇到了类似“stderr:remote:无效用户名或密码。”的错误 我的Jenkins文件如下所示: 节点{ stage('SCM Checkout') { git 'https://github.com/xxxxxxxxxxxx/java-app' } stage('Compile Package'){ // Get path of Maven Home def Mave
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"
}
}
我已将我的凭据保存在Jenkins中,如下所示:
我的詹金斯如下所示:
不幸的是,我得到的错误/日志输出如下:
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
git changelog: false, credentialsId: 'githubcredentials', poll: false, url: 'https://github.com/xxxxxxxxxxxx/java-app'
请协助我,因为我想了解为什么我的用户名和密码不正确,即使我可以使用相同的凭据登录Github要使SCM签出工作正常,我们需要添加凭据。我做了以下操作:
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
git changelog: false, credentialsId: 'githubcredentials', poll: false, url: 'https://github.com/xxxxxxxxxxxx/java-app'
要使SCM签出工作正常,我们需要添加凭据。我执行了以下操作:
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
git changelog: false, credentialsId: 'githubcredentials', poll: false, url: 'https://github.com/xxxxxxxxxxxx/java-app'
从Jenkins控制台签出时,您似乎提供了凭据。但在管道中,您没有传递任何凭据。好的,您认为既然我从控制台提供了凭据,它也应该在管道中继承吗?感谢@saurabh14292修复了它,通过下面的git函数和参数使它工作。您似乎提供了creden从Jenkins控制台签出时提示。但是在管道内部,您还没有传递任何凭据。好的,认为既然我从控制台提供了它,它也应该在管道中继承吗?感谢@saurabh14292修复了它,通过下面的git函数和参数使它工作。