我正在嘗試使用 Jenkins 和 Docker 構建我的 Maven 專案。
我準備在我的存盤庫中跟蹤 Jenkinsfile。
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'
}
}
}
}
當我觸發該專案時,我得到了這個。
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
uj5u.com熱心網友回復:
Jenkins(Docker 守護程式)找不到影像。或者換句話說找不到注冊表。
docker pull registry.hub.docker.com/maven:3-jdk-8
Error response from daemon: unauthorized: authentication required
您只需要docker.io像這樣修改配置中的注冊表 URL。
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
}
}
或者您可以省略registryUrland,registryCredentialsId因為 maven 映像位于公共注冊表(Docker Hub)中。默認情況下,詹金斯會嘗試從那里拉出來。
stage('3-jdk-8') {
agent {
docker {
image 'maven:3-jdk-8'
args '-v $HOME/.m2:/root/.m2'
reuseNode true
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/415814.html
標籤:
上一篇:獲取指向將被呼叫的多載函式的指標
下一篇:如何使用githubpullrequestbuilder通過jenkinsjobdsl配置JenkinspipelineJob?
