I am trying to push my image through Jenkinsfile on repository but when I do that I am facing below error.
Error response from daemon: Get https://mydockerregistryurl/v1/users/: x509: certificate signed by unknown authority
I have found many articles about this but did not understand any of this.
Can anyone try to help me?
Below is my jenkinsfile.
#!groovy
pipeline {
agent {
node {
label 'otd-agent'
}
}
stages{
stage('Test Stage'){
steps{
sh 'mvn clean test'
}
}
stage('SonarQube Analysis'){
steps{
withSonarQubeEnv('otd-sonar') {
sh 'mvn sonar:sonar'
}
}
}
stage('Package Stage'){
steps{
sh 'mvn clean package'
}
}
stage('Building Docker image') {
steps{
script {
sh 'docker build . -t jagathe-spike'
}
}
}
stage('Deploy Docker Image') {
steps{
script {
sh 'docker login -u username -p password docker-registry-default'
sh 'docker push docker-registry-default/otd-agathe'
}
}
}
}
}
If target registry docker-registry-default
is running on OpenShift
, you should deploy the OCP
CA
certificate which download from OCP
on your Jenkins host. Refer Installing a certificate authority certificate for external registries for more details.
For instance,
jenkins ~# scp root@master1.ocp.example.com:/etc/origin/master/ca.crt \
/etc/pki/ca-trust/source/anchors/ocp-ca.crt
jenkins ~# update-ca-trust extract
/etc/docker/certs.d
as follows.(${} is placeholder, you should replace it properly with your information) jenkins ~# cp /etc/pki/ca-trust/source/anchors/ocp-ca.crt \
/etc/docker/certs.d/${docker-registry-default}:${PORT}
jenkins ~# systemctl restart docker.service
I hope it help you.
按照https://jenkins.io/doc/book/pipeline/docker/上的说明使用withRegistry()方法
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.