gpt4 book ai didi

git - Jenkins:获取远程仓库 'origin' 时出错

转载 作者:行者123 更新时间:2023-12-05 02:04:28 26 4
gpt4 key购买 nike

我是 Jenkins 的新用户,我收到以下错误 ERROR: Error fetching remote repo 'origin',我在 Stack 上阅读了一些关于此错误的帖子,其中一些提到“容量/tmp 中的 disk",其他人说了工作区默认值,但没有一个能帮助我解决这个问题。

ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://github.com/not-show-my-url.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:996)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1237)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1297)
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 --progress -- https://github.com/thiagolmoraes/Mobile-Contrato.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/not-show-my-url.git'

有趣的是,如果我使用 Freestyle 项目,使用我在 Pipeline 项目中使用的相同凭据添加 git 存储库,我必须克隆该项目,所以我认为身份验证不是问题。

码头文件

FROM node

RUN apt-get update && apt-get upgrade -y \
&& apt-get clean

RUN mkdir /app
WORKDIR /app

COPY package*.json /app/

RUN npm install

COPY src /app/src

EXPOSE 3000

CMD [ "npm", "start" ]

Jenkins 文件

pipeline {
agent any
tools {nodejs "node" }
stages {
stage('Cloning Git') {
steps {
git 'https://github.com/not-show-my-url.git'
}
}
stage('Build') {
steps {
sh 'npm install'
}
}
stage('Test') {
steps {
sh 'npm test'
}
}
}
}

最佳答案

凭据确实是个问题,您需要将凭据 ID 添加到您的 git 管道步骤中,如下所示:

pipeline {
agent any
tools {nodejs "node" }
stages {
stage('Cloning Git') {
steps {
git url: 'https://github.com/not-show-my-url.git',
credentialsId: 'your-credentials-id'
}
}
stage('Build') {
steps {
sh 'npm install'
}
}
stage('Test') {
steps {
sh 'npm test'
}
}
}
}

credentialsId可以从http://yourjenkinsinstall/credentials获取。

关于git - Jenkins:获取远程仓库 'origin' 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64294640/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com