Thanks again Carlos. Unfortunately that syntax doesn't seem to work. I have this:

  environment {
    IMAGE_TAG       = "${env.IMAGE_TAG}"
    JOB_NAME        = "${env.JOB_NAME}"
    AGENT_IMAGE_TAG = "${env.AGENT_IMAGE_TAG}"
    ACCOUNT_ID      = "${env.ACCOUNT_ID}"
  }
  agent {
    kubernetes {
      label "${JOB_NAME}"
      inheritFrom 'default'
      containerTemplates {
        containerTemplate {
          name 'jnlp'
image '${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/jenkins/jnlp-slave:${AGENT_IMAGE_TAG}'
          resourceRequestCpu '200m'
          resourceLimitCpu '1'
          resourceRequestMemory '256Mi'
          resourceLimitMemory '1Gi'
        }
      }
    }


but I get this when I try to run the pipeline. I think maybe generating a static yaml is better.


[Pipeline] End of Pipeline
java.lang.UnsupportedOperationException: must specify $class with an implementation of interface java.util.List at org.jenkinsci.plugins.structs.describable.DescribableModel.resolveClass(DescribableModel.java:474) at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:401) at org.jenkinsci.plugins.structs.describable.DescribableModel.injectSetters(DescribableModel.java:360) at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:283) at org.jenkinsci.plugins.pipeline.modeldefinition.withscript.WithScriptDescriptor.newInstance(WithScriptDescriptor.java:74) at org.jenkinsci.plugins.pipeline.modeldefinition.agent.DeclarativeAgentDescriptor.instanceForDescriptor(DeclarativeAgentDescriptor.java:159) at org.jenkinsci.plugins.pipeline.modeldefinition.agent.DeclarativeAgentDescriptor$instanceForDescriptor$2.call(Unknown Source) at org.jenkinsci.plugins.pipeline.modeldefinition.model.Agent.getDeclarativeAgent(Agent.groovy:81)
        at sun.reflect.GeneratedMethodAccessor968.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at 
org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20) Caused: java.lang.IllegalArgumentException: Could not instantiate {label=Redhat_SSO_Deploy, inheritFrom=default, containerTemplates={containerTemplate={name=jnlp, image=${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/jenkins/jnlp-slave:${AGENT_IMAGE_TAG}, resourceRequestCpu=200m, resourceLimitCpu=1, resourceRequestMemory=256Mi, resourceLimitMemory=1Gi}}} for KubernetesDeclarativeAgent(activeDeadlineSeconds?: int, cloud?: String, containerTemplate?: ContainerTemplate(name?: String, image?: String, alwaysPullImage?: boolean, args?: String, command?: String, envVars?: TemplateEnvVar{ContainerEnvVar(key: String, value: String) | KeyValueEnvVar(key: String, value: String) | PodEnvVar(key: String, value: String) | SecretEnvVar(key: String, secretName: String, secretKey: String)}[], livenessProbe?: ContainerLivenessProbe(execArgs: String, timeoutSeconds: int, initialDelaySeconds: int, failureThreshold: int, periodSeconds: int, successThreshold: int), ports?: PortMapping(name?: String, containerPort?: int, hostPort?: int)[], privileged?: boolean, resourceLimitCpu?: String, resourceLimitMemory?: String, resourceRequestCpu?: String, resourceRequestMemory?: String, shell?: String, ttyEnabled?: boolean, workingDir?: String), containerTemplates?: ContainerTemplate(name?: String, image?: String, alwaysPullImage?: boolean, args?: String, command?: String, envVars?: TemplateEnvVar{ContainerEnvVar(key: String, value: String) | KeyValueEnvVar(key: String, value: String) | PodEnvVar(key: String, value: String) | SecretEnvVar(key: String, secretName: String, secretKey: String)}[], livenessProbe?: ContainerLivenessProbe(execArgs: String, timeoutSeconds: int, initialDelaySeconds: int, failureThreshold: int, periodSeconds: int, successThreshold: int), ports?: PortMapping(name?: String, containerPort?: int, hostPort?: int)[], privileged?: boolean, resourceLimitCpu?: String, resourceLimitMemory?: String, resourceRequestCpu?: String, resourceRequestMemory?: String, shell?: String, ttyEnabled?: boolean, workingDir?: String)[], defaultContainer?: String, idleMinutes?: int, inheritFrom?: String, instanceCap?: int, label?: String, nodeSelector?: String, serviceAccount?: String, workingDir?: String, yaml?: String, yamlFile?: String) at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:286) at org.jenkinsci.plugins.pipeline.modeldefinition.withscript.WithScriptDescriptor.newInstance(WithScriptDescriptor.java:74) at org.jenkinsci.plugins.pipeline.modeldefinition.agent.DeclarativeAgentDescriptor.instanceForDescriptor(DeclarativeAgentDescriptor.java:159) at org.jenkinsci.plugins.pipeline.modeldefinition.agent.DeclarativeAgentDescriptor$instanceForDescriptor$2.call(Unknown Source) at org.jenkinsci.plugins.pipeline.modeldefinition.model.Agent.getDeclarativeAgent(Agent.groovy:81)
        at sun.reflect.GeneratedMethodAccessor968.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at 
org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.inDeclarativeAgent(jar:file:/var/jenkins_home/plugins/pipeline-model-definition/WEB-INF/lib/pipeline-model-definition.jar!/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy:579) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.call(jar:file:/var/jenkins_home/plugins/pipeline-model-definition/WEB-INF/lib/pipeline-model-definition.jar!/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy:75)
        at WorkflowScript.run(WorkflowScript:2)
        at ___cps.transform___(Native Method)
at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
        at sun.reflect.GeneratedMethodAccessor362.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.LocalVariableBlock$LocalVariable.get(LocalVariableBlock.java:39) at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30) at com.cloudbees.groovy.cps.impl.LocalVariableBlock.evalLValue(LocalVariableBlock.java:28)
        at 
com.cloudbees.groovy.cps.LValueBlock$BlockImpl.eval(LValueBlock.java:55)
        at com.cloudbees.groovy.cps.LValueBlock.eval(LValueBlock.java:16)
        at com.cloudbees.groovy.cps.Next.step(Next.java:83)
        at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
        at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122) at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261)
        at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$101(SandboxContinuable.java:34) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.lambda$run0$0(SandboxContinuable.java:59) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:58) at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:332) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:83) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:244) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:232) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131) at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
        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

On 08/09/18 11:25, Carlos Sanchez wrote:
yaml is not expanded with environment variables. You need to keep using containerTemplate (or

containerTemplates {
   containerTemplate {
...
   }
}

in the meantime


--
You received this message because you are subscribed to the Google Groups "Jenkins 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/c3439697-1878-8254-b56c-287d8730df0d%40fascinatedcow.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to