简体   繁体   中英

How do I use AWS credentials with Jenkins to deploy to Elastic Beanstalk?

I have entered AWS credentials in Jenkins at /credentials , however they do not show up in the drop down list for the Post Build steps in the AWS Elastic Beanstalk plugin.

在此处输入图片说明

If I click Validate Credentials, I get this strange error.

在此处输入图片说明

Failure com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain: [EnvironmentVariableCredentialsProvider: Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)), SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey), com.amazonaws.auth.profile.ProfileCredentialsProvider@5c932b96: profile file cannot be null, com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper@32abba7: The requested metadata is not found at http://169.254.169.254/latest/meta-data/iam/security-credentials/] at com.amazonaws.auth.AWSCredentialsProviderChain.getCredentials(AWSCredentialsProviderChain.java:136)

I don't know where it got that IP address. When I search for that IP in the Jenkins directory, I turn up with

-bash-4.2$ grep -r 169.254.169.254 *
plugins/ec2/AMI-Scripts/ubuntu-init.py:conn = httplib.HTTPConnection("169.254.169.254")

The contents of that file is here: https://pastebin.com/3ShanSSw


There are actually 2 different Amazon Elastic Beanstalk plugins.

Neither of them work. Neither will display the credentials in the drop down list. Since updating Jenkins, I am unable to even show "Deploy to Elastic Beanstalk" as a post-build step for the first one (v0.3.19) even though it is the only one installed.

For the 2nd plugin (v1.7.4), I see this screen shot:

在此处输入图片说明

When I fill in what I can, and run it, it gives the error

No credentials provided for build!!!
Environment found (environment id='e-yfwqnurxh6', name='appenvironment'). Attempting to update environment to version label 'sprint5-13'
'appenvironment': Attempt 0/5
'appenvironment': Problem:
com.amazonaws.services.elasticbeanstalk.model.AWSElasticBeanstalkException: No Application Version named 'sprint5-13' found. (Service: AWSElasticBeanstalk; Status Code: 400; Error Code: InvalidParameterValue; Request ID: af9eae4f-ad56-426e-8fe4-4ae75548f3b1)

I tried to add an S3 sub-task to the Elastic Beanstalk deployment, but it failed with an exception.

No credentials provided for build!!!
Root File Object is a file. We assume its a zip file, which is okay.
Uploading file awseb-4831053374102655095.zip as s3://appname-sprint5-15.zip
ERROR: Build step failed with exception
com.amazonaws.services.s3.model.AmazonS3Exception: The XML you provided was not well-formed or did not validate against our published schema (Service: Amazon S3; Status Code: 400; Error Code: MalformedXML; Request ID: 7C4734153DB2BC36; S3 Extended Request ID: x7B5HflSeiIw++NGosos08zO5DxP3WIzrUPkZOjjbBv856os69QRBVgic62nW3GpMtBj1IxW7tc=), S3 Extended Request ID: x7B5HflSeiIw++NGosos08zO5DxP3WIzrUPkZOjjbBv856os69QRBVgic62nW3GpMtBj1IxW7tc=

Jenkins is hopelessly out of date and unmaintained. I added the Post Build Task plugin, installed eb tool as jenkins user, ran eb init in the job directory, edited .elasticbeanstalk/config.yml to add the lines

deploy:
  artifact: target/AppName-Sprint5-SNAPSHOT-bin.zip

Then entered in the shell command to deploy the build.

/var/lib/jenkins/.local/bin/eb deploy -l sprint5-${BUILD_NUMBER}

在此处输入图片说明

对于 Elastic beanstalk 插件,配置 AWS 密钥的正确位置是 Jenkins Master configure

  http://{jenkinsURL}/configure

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM