title: Jenkins declarative pipeline - use withcredential of AWS
body: <p>In my prev Jenkinsfile, I used to have this:</p>
  
  <pre><code>withCredentials([[ $class: 'AmazonWebServicesCredentialsBinding',
                     credentialsId : 'aws',                                                 
                     accessKeyVariable: 'KEY_1',
                     secretKeyVariable: 'KEY_2'
                                       ]]) {
      node(..) { .. } }
  </code></pre>
  
  <p>e.g. all stages where I need to use AWS creds are wrapped with withCreds, however with declarative syntax, I have to use that <code>withCredentials</code> block <strong>per stage</strong> which is not acceptable.  I read that there is some <code>credentials('aws')</code> option in <code>environments {}</code> block, though I can't figure out how I can specify my cred class there and seems, it's wrong thing to look at.</p>
  
  <pre><code>pipeline {
     stages {
         stage('A') {
             steps {
                withCredentials([[ $class: 'AmazonWebServicesCredentialsBinding',
                     credentialsId : 'aws',                                                 
                     accessKeyVariable: 'KEY_1',
                     secretKeyVariable: 'KEY_2'
                                       ]]) { .. }
             }
         }
         stage('B') {
             steps {
                withCredentials([[ $class: 'AmazonWebServicesCredentialsBinding',
                     credentialsId : 'aws',                                                 
                     accessKeyVariable: 'KEY_1',
                     secretKeyVariable: 'KEY_2'
                                       ]]) { .. }
             }
         }
     }
  
  }
  </code></pre>
  
  <p>Please let me know how I can wrap my several stages <code>withCredentials</code> in Jenkins declarative syntax. Thanks</p>