将Docker映像推送到Google Container Registry时出现UnsupportedOperationException

时间:2019-12-18 11:05:49

标签: jenkins google-cloud-platform jenkins-pipeline

我试图将Docker映像从詹金斯推送到GCR。

到目前为止我尝试过的脚本。

stage('Push Docker image to gcr'){
                    script{
                         docker
                                .image('google/cloud-sdk')
                                .inside("--network=host  -e DOCKER_HOST=tcp://localhost:2375 -u 0"){
                    withCredentials([file(credentialsId: 'gcr- credentials', variable: 'File')]) {
                      sh '''
                        gcloud auth activate-service-account --key-file ${File}
                        gcloud --quiet config set project order-status-api-0j7p
                        gcloud auth configure-docker
                        docker push gcr.io/order-status-api-0j7p/test-image:$BUILD_NUMBER
                        '''
                      }
                    }
                }
           }

但是我不理解詹金斯抛出的异常。

java.lang.UnsupportedOperationException
    at com.google.jenkins.plugins.googlecontainerregistryauth.GoogleContainerRegistryCredential.getDescriptor(GoogleContainerRegistryCredential.java:179)
    at com.google.jenkins.plugins.googlecontainerregistryauth.GoogleContainerRegistryCredential.getDescriptor(GoogleContainerRegistryCredential.java:66)
    at com.cloudbees.plugins.credentials.CredentialsNameProvider.name(CredentialsNameProvider.java:79)
    at com.cloudbees.plugins.credentials.CredentialsNameComparator.compare(CredentialsNameComparator.java:103)
    at com.cloudbees.plugins.credentials.CredentialsNameComparator.compare(CredentialsNameComparator.java:40)
    at java.util.TimSort.binarySort(TimSort.java:296)
    at java.util.TimSort.sort(TimSort.java:221)
    at java.util.Arrays.sort(Arrays.java:1512)
    at java.util.ArrayList.sort(ArrayList.java:1462)
    at java.util.Collections.sort(Collections.java:177)
    at com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(CredentialsProvider.java:563)
    at com.cloudbees.plugins.credentials.CredentialsProvider.findCredentialById(CredentialsProvider.java:906)
    at com.cloudbees.plugins.credentials.CredentialsProvider.findCredentialById(CredentialsProvider.java:850)
    at org.jenkinsci.plugins.credentialsbinding.MultiBinding.getCredentials(MultiBinding.java:144)
    at org.jenkinsci.plugins.credentialsbinding.impl.AbstractOnDiskBinding.bindSingle(AbstractOnDiskBinding.java:39)
    at org.jenkinsci.plugins.credentialsbinding.Binding.bind(Binding.java:150)
    at org.jenkinsci.plugins.credentialsbinding.impl.BindingStep$Execution2.doStart(BindingStep.java:135)
    at org.jenkinsci.plugins.workflow.steps.GeneralNonBlockingStepExecution.lambda$run$0(GeneralNonBlockingStepExecution.java:77)
    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)

有人可以帮我解决这个问题吗?

0 个答案:

没有答案