首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >詹金斯没能用码头建造

詹金斯没能用码头建造
EN

Stack Overflow用户
提问于 2022-01-18 01:10:27
回答 1查看 361关注 0票数 0

我正试图与Jenkins和Docker一起构建我的Maven项目。

我准备在我的存储库中跟踪Jenkinsfile。

代码语言:javascript
复制
pipeline {
    agent none
    stages {
        stage('3-jdk-8') {
            agent {
                docker {
                    registryUrl 'https://registry.hub.docker.com'
                    registryCredentialsId 'docker-hub'
                    image 'maven:3-jdk-8'
                    args '-v $HOME/.m2:/root/.m2'
                    reuseNode true
                }
            }
            steps {
                sh 'mvnw -B clean build'
            }
        }
        stage('3-jdk-11') {
            agent {
                docker {
                    registryUrl 'https://registry.hub.docker.com'
                    registryCredentialsId 'docker-hub'
                    image 'maven:3-jdk-11'
                    args '-v $HOME/.m2:/root/.m2'
                    reuseNode true
                }
            }
            steps {
                sh 'mvnw -B clean build'
            }
        }
    }
}

当我触发这个项目的时候,我得到了这个。

代码语言:javascript
复制
Started by user Jin Kwon
Checking out git https://....git into /var/lib/jenkins/workspace/...@script to read Jenkinsfile
Selected Git installation does not exist. Using Default
The recommended git tool is: NONE
using credential ...
 > git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/...@script/.git # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://....git # timeout=10
Fetching upstream changes from https://....git
 > git --version # timeout=10
 > git --version # 'git version 2.25.1'
using GIT_ASKPASS to set credentials 
 > git fetch --tags --force --progress -- https://....git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse origin/develop^{commit} # timeout=10
Checking out Revision c9627132515a20c209a6e0d5f14c3779fa1eb933 (origin/develop)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f c9627132515a20c209a6e0d5f14c3779fa1eb933 # timeout=10
Commit message: "Configure docker.registry(Url|registryCredentialId)"
 > git rev-list --no-walk c9627132515a20c209a6e0d5f14c3779fa1eb933 # timeout=10
[Pipeline] Start of Pipeline
[Pipeline] stage
[Pipeline] { (3-jdk-8)
[Pipeline] getContext
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/...
[Pipeline] {
[Pipeline] checkout
Selected Git installation does not exist. Using Default
The recommended git tool is: NONE
using credential ...
 > git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/.../.git # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://....git # timeout=10
Fetching upstream changes from https://....git
 > git --version # timeout=10
 > git --version # 'git version 2.25.1'
using GIT_ASKPASS to set credentials 
 > git fetch --tags --force --progress -- https://....git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse origin/develop^{commit} # timeout=10
Checking out Revision c9627132515a20c209a6e0d5f14c3779fa1eb933 (origin/develop)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f c9627132515a20c209a6e0d5f14c3779fa1eb933 # timeout=10
Commit message: "Configure docker.registry(Url|registryCredentialId)"
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withDockerRegistry
Using the existing docker config file.Removing blacklisted property: auths$ docker login -u onacit -p ******** https://registry.hub.docker.com
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /var/lib/jenkins/workspace/...@tmp/950e743c-139b-4e14-93c3-b9fda206b1f4/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] isUnix
[Pipeline] sh
+ docker inspect -f . maven:3-jdk-8

Error: No such object: maven:3-jdk-8
[Pipeline] isUnix
[Pipeline] sh
+ docker inspect -f . registry.hub.docker.com/maven:3-jdk-8

Error: No such object: registry.hub.docker.com/maven:3-jdk-8
[Pipeline] withEnv
[Pipeline] {
[Pipeline] isUnix
[Pipeline] sh
+ docker pull registry.hub.docker.com/maven:3-jdk-8
Error response from daemon: unauthorized: authentication required
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withDockerRegistry
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (3-jdk-11)
Stage "3-jdk-11" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-01-18 01:28:42

Jenkins (Docker )找不到图像。或者换句话说,找不到注册表。

代码语言:javascript
复制
+ docker pull registry.hub.docker.com/maven:3-jdk-8
Error response from daemon: unauthorized: authentication required

您只需要像这样使用docker.io修改配置中的注册表URL。

代码语言:javascript
复制
 stage('3-jdk-8') {
            agent {
                docker {
                    registryUrl 'https://docker.io'
                    registryCredentialsId 'docker-hub'
                    image 'maven:3-jdk-8'
                    args '-v $HOME/.m2:/root/.m2'
                    reuseNode true
                }
            }

或者您可以省略registryUrlregistryCredentialsId,因为maven映像位于公共注册表(Docker )中。詹金斯会在默认情况下尝试把它从那里拉出来。

代码语言:javascript
复制
 stage('3-jdk-8') {
            agent {
                docker {
                    image 'maven:3-jdk-8'
                    args '-v $HOME/.m2:/root/.m2'
                    reuseNode true
                }
            }
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70749239

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档