Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException com.google.jenkins.plugins.googlecontainerregistryauth.GoogleContainerRegistryTokenSource.convert #94

Open
aresares opened this issue Sep 7, 2020 · 6 comments

Comments

@aresares
Copy link

aresares commented Sep 7, 2020

java.lang.NullPointerException
at com.google.jenkins.plugins.googlecontainerregistryauth.GoogleContainerRegistryTokenSource.convert(GoogleContainerRegistryTokenSource.java:48)
at com.google.jenkins.plugins.googlecontainerregistryauth.GoogleContainerRegistryTokenSource.convert(GoogleContainerRegistryTokenSource.java:32)
at jenkins.authentication.tokens.api.AuthenticationTokens.convert(AuthenticationTokens.java:148)
at jenkins.authentication.tokens.api.AuthenticationTokens.convert(AuthenticationTokens.java:110)
at org.jenkinsci.plugins.docker.commons.credentials.DockerRegistryEndpoint.getToken(DockerRegistryEndpoint.java:222)
at org.jenkinsci.plugins.docker.commons.credentials.DockerRegistryEndpoint.newKeyMaterialFactory(DockerRegistryEndpoint.java:295)
at org.jenkinsci.plugins.docker.workflow.RegistryEndpointStep$Execution2.newKeyMaterialFactory(RegistryEndpointStep.java:95)
at org.jenkinsci.plugins.docker.workflow.AbstractEndpointStepExecution2.doStart(AbstractEndpointStepExecution2.java:52)
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)
Finished: FAILURE

@donmccasland
Copy link
Collaborator

Thanks for filing!

Do you have any steps for reproducing this issue?

@aresares
Copy link
Author

aresares commented Sep 8, 2020

I used this pipeline with all required plugins installed:

  • Jenkins 2.176.3
  • JDK 15
  • MAVEN 3.6.2
  • Google Container Registry Auth Plugin v.0.3
  • Google OAuth Credentials plugin v.1.0.2
pipeline {
  agent {
    kubernetes {
      label 'fiscalcode-pod'  			// all your pods will be named with this prefix, followed by a unique id
      idleMinutes 10  				// how long the pod will live after no jobs have run on it
      yamlFile 'build-pod.yaml'  		// path to the pod definition relative to the root of our project 
      defaultContainer 'jnlp-fiscalcode'  	// define a default container if more than a few stages use it, will default to jnlp container
    }
  }
  tools {
        jdk JDK_VERSION
        maven MAVEN_VERSION
    }
	
	environment {
		//Use Pipeline Utility Steps plugin to read information from pom.xml into env variables
		IMAGE = readMavenPom().getArtifactId()
		VERSION = readMavenPom().getVersion()
    }
  stages {

        stage('Build') {
            steps {
                configFileProvider([configFile(fileId: params.MAVEN_SETTINGS_ID, variable: 'MAVEN_GLOBAL_SETTINGS')]) {
					sh "mvn -gs $MAVEN_GLOBAL_SETTINGS clean package -DskipTests=true"
                }
            }
        }

		stage('Analysis') {
            steps {
			    configFileProvider([configFile(fileId: params.MAVEN_SETTINGS_ID, variable: 'MAVEN_GLOBAL_SETTINGS')]) {
					withSonarQubeEnv(SONARQUBE_ENV) {
						sh "mvn -gs $MAVEN_GLOBAL_SETTINGS clean verify sonar:sonar"
					}
				}
            }
        }
        stage('Quality Gate'){
            steps{
				script{
					// Just in case something goes wrong, pipeline will be killed after a timeout
					timeout(time: 8, unit: 'MINUTES') {
    					sleep 10

						// Reuse taskId previously collected by withSonarQubeEnv
    					def qg = waitForQualityGate()
    					if (qg.status != 'OK') {
    					  error "Pipeline aborted due to quality gate failure: ${qg.status}"
    					}
					}
				}
            }
        }

        stage('Deploy'){
        	steps{
	            configFileProvider([configFile(fileId: params.MAVEN_SETTINGS_ID, variable: 'MAVEN_GLOBAL_SETTINGS')]) {
                   sh "mvn deploy -gs $MAVEN_GLOBAL_SETTINGS -DskipTests=true"
	            }
            }
        }

        stage('Build & Publish docker image on Google') {
            steps{
                script {
                    def imageName = "eu.gcr.io/terraform-gke/fiscalcode"
                    docker.withRegistry("https://eu.gcr.io", "gcr:terraform-gke") {
                        def customImage = docker.build(imageName)
                        customImage.push("${VERSION}")
                    }
                }
            }
        }
    }
}

@donmccasland
Copy link
Collaborator

Looking into this

@jason-kane
Copy link

jason-kane commented Apr 17, 2021

I just got an identical traceback; essentially the same groovy. Nothing exotic. Relevant bit looks like:

REGISTRY='gcr.io/projectname'
GCR_CREDENTIALS='gcr:credential-id'

docker_image = docker.build(...)

    stage('Publish') {
        figlet STAGE_NAME
        docker.withRegistry(
            "https://${REGISTRY}",
            GCR_CREDENTIALS
        ) {
            docker_image.push('latest')
        }
    }

where credential-id is a json service account uploaded into a "Google Service Account from private key" credential.

Jenkins 2.249.1
Google OAuth Credentials 1.0.2
Google Container Registry Auth Plugin 0.3

I've re-uploaded the service account json and I'm retrying the build to see if I'm just unlucky, it's a crazy huge docker image.

--- UPDATE ---

Generating a new service account json and replacing the credential in Jenkins fixed this for me. I suspect but have not verified that the "old" service account json was disabled/removed in GCP. I suppose it is also possible but much less likely there was something about the old service account that broke jenkins.

Still a 'bug' but only in that java.lang.NullPointerException isn't a very helpful error message.

@aarnaud
Copy link

aarnaud commented Aug 10, 2021

Any idea ? I still have the issue, with new service account

15:47:11  java.lang.NullPointerException
15:47:11  	at com.google.jenkins.plugins.googlecontainerregistryauth.GoogleContainerRegistryTokenSource.convert(GoogleContainerRegistryTokenSource.java:48)
15:47:11  	at com.google.jenkins.plugins.googlecontainerregistryauth.GoogleContainerRegistryTokenSource.convert(GoogleContainerRegistryTokenSource.java:32)
15:47:11  	at jenkins.authentication.tokens.api.AuthenticationTokens.convert(AuthenticationTokens.java:148)
15:47:11  	at jenkins.authentication.tokens.api.AuthenticationTokens.convert(AuthenticationTokens.java:110)
15:47:11  	at org.jenkinsci.plugins.docker.commons.credentials.DockerRegistryEndpoint.getToken(DockerRegistryEndpoint.java:222)
15:47:11  	at org.jenkinsci.plugins.docker.commons.credentials.DockerRegistryEndpoint.newKeyMaterialFactory(DockerRegistryEndpoint.java:295)
15:47:11  	at org.jenkinsci.plugins.docker.workflow.RegistryEndpointStep$Execution2.newKeyMaterialFactory(RegistryEndpointStep.java:95)
15:47:11  	at org.jenkinsci.plugins.docker.workflow.AbstractEndpointStepExecution2.doStart(AbstractEndpointStepExecution2.java:52)
15:47:11  	at org.jenkinsci.plugins.workflow.steps.GeneralNonBlockingStepExecution.lambda$run$0(GeneralNonBlockingStepExecution.java:77)
15:47:11  	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
15:47:11  	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
15:47:11  	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
15:47:11  	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
15:47:11  	at java.base/java.lang.Thread.run(Thread.java:829)
15:47:11  Finished: FAILURE

@bhat-ganesh
Copy link

bhat-ganesh commented Mar 23, 2022

This is still an issue. It was working fine and now getting the similar error.

java.lang.NullPointerException
	at com.google.jenkins.plugins.googlecontainerregistryauth.GoogleContainerRegistryCredentialModule.getToken(GoogleContainerRegistryCredentialModule.java:73)
	at com.google.jenkins.plugins.googlecontainerregistryauth.GoogleContainerRegistryCredential.getPassword(GoogleContainerRegistryCredential.java:224)
	at com.google.jenkins.plugins.googlecontainerregistryauth.GoogleContainerRegistryTokenSource.convert(GoogleContainerRegistryTokenSource.java:48)
	at com.google.jenkins.plugins.googlecontainerregistryauth.GoogleContainerRegistryTokenSource.convert(GoogleContainerRegistryTokenSource.java:32)
	at jenkins.authentication.tokens.api.AuthenticationTokens.convert(AuthenticationTokens.java:148)
	at jenkins.authentication.tokens.api.AuthenticationTokens.convert(AuthenticationTokens.java:110)
	at org.jenkinsci.plugins.docker.commons.credentials.DockerRegistryEndpoint.getToken(DockerRegistryEndpoint.java:223)
	at org.jenkinsci.plugins.docker.commons.credentials.DockerRegistryEndpoint.newKeyMaterialFactory(DockerRegistryEndpoint.java:296)
	at org.jenkinsci.plugins.docker.workflow.RegistryEndpointStep$Execution2.newKeyMaterialFactory(RegistryEndpointStep.java:95)
	at org.jenkinsci.plugins.docker.workflow.AbstractEndpointStepExecution2.doStart(AbstractEndpointStepExecution2.java:52)
	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:750)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants