I need your help to solve this puzzle. At my job, we have a Jenkins pipeline to build one of our projects, a lib used for many of our projects.
This pipeline worked as expected until last week. I've made some changes and updated some dependencies and now the build on Jenkins isn't working. To run our tests on Jenkins, we have this Docker Image that we have created. An image with Java 8, Gradle 6.9.2, and some certs to connect on Active Directory. The problem occurs on the stage to execute JUnit tests.
The Image name that we are using is gradle692-certs-win-ad:gradle-6.9.2-jdk8
the error:
ERROR: Name must follow the pattern '^[a-zA-Z0-9] ((\.|_|__|- )[a-zA-Z0-9] )*$'
18:59:41 at hudson.util.FormValidation._errorWithMarkup(FormValidation.java:266)
18:59:41 at hudson.util.FormValidation.errorWithMarkup(FormValidation.java:252)
18:59:41 at hudson.util.FormValidation.error(FormValidation.java:143)
18:59:41 at hudson.util.FormValidation.error(FormValidation.java:168)
18:59:41 at org.jenkinsci.plugins.docker.commons.credentials.ImageNameValidator.validateName(ImageNameValidator.java:289)
18:59:41 at org.jenkinsci.plugins.docker.commons.credentials.ImageNameValidator.validateUserAndRepo(ImageNameValidator.java:115)
18:59:41 at org.jenkinsci.plugins.docker.commons.credentials.DockerRegistryEndpoint.imageName(DockerRegistryEndpoint.java:317)
18:59:41 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
18:59:41 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
18:59:41 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
18:59:41 at java.base/java.lang.reflect.Method.invoke(Unknown Source)
18:59:41 at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
18:59:41 at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
18:59:41 at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
18:59:41 at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
18:59:41 at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:47)
18:59:41 at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
18:59:41 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
18:59:41 at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
18:59:41 at org.jenkinsci.plugins.docker.workflow.Docker$Image.toQualifiedImageName(Docker.groovy:106)
18:59:41 at org.jenkinsci.plugins.docker.workflow.Docker$Image.imageName(Docker.groovy:110)
18:59:41 at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(Docker.groovy:115)
18:59:41 at org.jenkinsci.plugins.docker.workflow.Docker.node(Docker.groovy:66)
18:59:41 at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(Docker.groovy:114)
18:59:41 at org.jenkinsci.plugins.docker.workflow.declarative.DockerPipelineScript.runImage(DockerPipelineScript.groovy:57)
18:59:41 at org.jenkinsci.plugins.docker.workflow.declarative.AbstractDockerPipelineScript.configureRegistry(AbstractDockerPipelineScript.groovy:73)
18:59:41 at org.jenkinsci.plugins.docker.workflow.declarative.AbstractDockerPipelineScript.run(AbstractDockerPipelineScript.groovy:43)
18:59:41 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.inDeclarativeAgent(ModelInterpreter.groovy:594)
18:59:41 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:272)
18:59:41 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.stageInput(ModelInterpreter.groovy:356)
18:59:41 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.stageInput(ModelInterpreter.groovy:355)
18:59:41 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:261)
18:59:41 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.inWrappers(ModelInterpreter.groovy:618)
18:59:41 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.inWrappers(ModelInterpreter.groovy:617)
18:59:41 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:259)
18:59:41 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withEnvBlock(ModelInterpreter.groovy:443)
18:59:41 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withEnvBlock(ModelInterpreter.groovy:442)
18:59:41 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:254)
18:59:41 at ___cps.transform___(Native Method)
18:59:41 at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
18:59:41 at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
18:59:41 at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
18:59:41 at jdk.internal.reflect.GeneratedMethodAccessor354.invoke(Unknown Source)
18:59:41 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
18:59:41 at java.base/java.lang.reflect.Method.invoke(Unknown Source)
18:59:41 at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
18:59:41 at com.cloudbees.groovy.cps.impl.LocalVariableBlock$LocalVariable.get(LocalVariableBlock.java:39)
18:59:41 at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
18:59:41 at com.cloudbees.groovy.cps.impl.LocalVariableBlock.evalLValue(LocalVariableBlock.java:28)
18:59:41 at com.cloudbees.groovy.cps.LValueBlock$BlockImpl.eval(LValueBlock.java:55)
18:59:41 at com.cloudbees.groovy.cps.LValueBlock.eval(LValueBlock.java:16)
18:59:41 at com.cloudbees.groovy.cps.Next.step(Next.java:83)
18:59:41 at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
18:59:41 at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
18:59:41 at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
18:59:41 at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
18:59:41 at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
18:59:41 at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
18:59:41 at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
18:59:41 at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
18:59:41 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:403)
18:59:41 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:97)
18:59:41 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:315)
18:59:41 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:279)
18:59:41 at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
18:59:41 at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
18:59:41 at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
18:59:41 at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
18:59:41 at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
18:59:41 at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
18:59:41 at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
18:59:41 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
18:59:41 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
18:59:41 at java.base/java.lang.Thread.run(Unknown Source)
18:59:41 Finished: FAILURE
PS: I run on my local machine the gradle build using this same base docker image. Everything went well.
CodePudding user response:
it's me again
I found a ticket opened on the Jenkins forum and it helped me to solve this problem.
Just to explain what I did. On our Jenkinsfile, we had this environment called NOME_BASE_IMAGEM that we use on the stage to execute Junit Tests and analyze with sonarQube
NOME_BASE_IMAGEM = "registry.rancher.tcu.gov.br/public-images/gradle/gradle6-certs-win-ad:gradle-6.8.3-jdk8
stage('Analisa com sonarqube (inclui testes JUnit)') {
agent {
docker {
image '${NOME_BASE_IMAGEM}'
reuseNode true
}
}
steps {
sh 'gradle sonarqube -PmavenUser=usr_repo_maven -PmavenPassword=mvndeploy'
}
}
I guess what caused the problem was the double quotes on env value. I've changed the call on stage to the full path of the image in single quotes.
stage('Analisa com sonarqube (inclui testes JUnit)') {
agent {
docker {
image 'registry.rancher.tcu.gov.br/public-images/gradle/gradle6-certs-win-ad:gradle-6.8.3-jdk8'
reuseNode true
}
}
steps {
sh 'gradle sonarqube -PmavenUser=usr_repo_maven -PmavenPassword=mvndeploy'
}
}
Ps²: I'm not even good to express the ideia, sorry for anything from now. :D