Skip to content

Instantly share code, notes, and snippets.

@darinpope
Last active April 2, 2023 20:41
Show Gist options
  • Save darinpope/cbdc036cec4cd49ae2548a4d2d050abd to your computer and use it in GitHub Desktop.
Save darinpope/cbdc036cec4cd49ae2548a4d2d050abd to your computer and use it in GitHub Desktop.

Pipeline version 1

pipeline {
  agent { label "linux" }
  stages {
    stage('Hello') {
      steps {
        sh '''
          aws --version
        '''
      }
    }
  }
}

Pipeline version 2

pipeline {
  agent { label "linux" }
  stages {
    stage('Hello') {
      steps {
        sh '''
          aws --version
          aws ec2 describe-instances
        '''
      }
    }
  }
}

Pipeline version 3

pipeline {
  agent { label "linux" }
  environment {
    AWS_DEFAULT_REGION="us-east-1"
  }
  stages {
    stage('Hello') {
      steps {
        sh '''
          aws --version
          aws ec2 describe-instances
        '''
      }
    }
  }
}

Pipeline version 4

pipeline {
  agent { label "linux" }
  environment {
    AWS_DEFAULT_REGION="us-east-1"
  }
  stages {
    stage('Hello') {
      steps {
        withCredentials([aws(accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'darinpope-aws-creds', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY')]) {
          sh '''
            aws --version
            aws ec2 describe-instances
          '''
        }
      }
    }
  }
}

Pipeline version 5

pipeline {
  agent { label "linux" }
  environment {
    AWS_DEFAULT_REGION="us-east-1"
    THE_BUTLER_SAYS_SO=credentials('darinpope-aws-creds')
  }
  stages {
    stage('Hello') {
      steps {
        sh '''
          aws --version
          aws ec2 describe-instances
        '''
      }
    }
  }
}

Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment