Execute AWS CLI command inside a pipeline Jenkins file

断了今生、忘了曾经 提交于 2019-12-12 19:22:03

问题


Do you know how to execute AWS CLI command inside a Jenkinsfile in order to build a pipeline? I didn't find any plugins


回答1:


First you need install aws cli on your server and make sure the jenkins user has permissions to run it.

Or simply use the Amazon AMI when creating the EC2 instance, it comes with the aws cli.

Assign a role the instance with the appropriate policy. ( it is simpler that using user key in aws configure )

Within your pipeline steps use sh 'aws ...'




回答2:


First of all you need to install AWS CLI in Jenkins instance in order to perform calls to your environment.

To setup it you need to create a new user to Jenkins in AWS and configure properly the keys. Take a look here: http://docs.aws.amazon.com/systems-manager/latest/userguide/automation-jenkins.html

After that you can do calls inside your Jenkins jobs using 'Shell commands' to AWS CLI:

aws ec2 describe-security-groups

If you are using Ansible as your automation tool, take a look here: https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/




回答3:


It was pretty easy. In order to execute aws command, you need to use

sh aws...



来源:https://stackoverflow.com/questions/37869632/execute-aws-cli-command-inside-a-pipeline-jenkins-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!