title: How to pass AWS credential when building Docker image in Jenkins?
body: <p>Hi I am working in jenkins to build my AWS CDK project. I have created my docker file as below.</p>
  
  <pre><code>FROM python:3.7.4-alpine3.10
  ENV CDK_VERSION='1.14.0'
  
  RUN mkdir /cdk
  
  COPY ./requirements.txt /cdk/
  COPY ./entrypoint.sh /usr/local/bin/
  COPY ./aws /cdk/
  WORKDIR /cdk
  
  RUN apk -uv add --no-cache groff jq less
  RUN apk add --update nodejs npm
  RUN apk add --update bash &amp;&amp; rm -rf /var/cache/apk/*
  RUN npm install -g aws-cdk
  RUN pip3 install -r requirements.txt
  
  RUN ls -la
  ENTRYPOINT ["entrypoint.sh"]
  
  RUN cdk synth
  RUN cdk deploy
  </code></pre>
  
  <p>In jenkins I am building this Docker image as below.</p>
  
  <pre><code> stages {
       stage('Dev Code Deploy') {
        when {
          expression {
            return BRANCH_NAME = 'Develop'
          }
        }
        agent {
          dockerfile {
            additionalBuildArgs "--build-arg 'http_proxy=${env.http_proxy}' --build-arg 'https_proxy=${env.https_proxy}'"
            filename 'Dockerfile'
            args '-u root:root'
          }
        }
  </code></pre>
  
  <p>In the above code I am not supplying AWS credentials So when cdk synth is executed I get error <code>Need to perform AWS calls for account 1234567 but no credentials found. Tried: default credentials.</code></p>
  
  <p>In jenkins I have my AWS credentials and I can access this like</p>
  
  <pre><code> steps {
          withCredentials([[$class: 'AmazonWebServicesCredentialsBinding',credentialsId: "${env.PROJECT_ID}-aws-${env.ENVIRONMENT}"]]) {
             sh 'ls -la'
             sh "bash ./scripts/build.sh"
          }
        }
  </code></pre>
  
  <p>But how can I pass these credentialsId when building docker image. Can someone help me to figure it out. Any help would be appreciated. Thanks</p>