jenkinsci / pipeline-aws-plugin

Jenkins Pipeline Step Plugin for AWS
https://plugins.jenkins.io/pipeline-aws/
Apache License 2.0
431 stars 203 forks source link

Error: profile file cannot be null #162

Open amuresia opened 5 years ago

amuresia commented 5 years ago

Description

I am unable to use a configured profile. I can run aws commands from the terminal, using the --profile parameter so the configuration is ok, however the plugin fails on Jenkins

Steps to Reproduce

use withAWS(profile: 'xyz') block to retrieve locally stored profile under .aws/ directory

Expected behavior: Profile should be successfully used. Actual behavior: java.lang.IllegalArgumentException: profile file cannot be null at com.amazonaws.util.ValidationUtils.assertNotNull(ValidationUtils.java:37) at com.amazonaws.auth.profile.ProfilesConfigFile.<init>(ProfilesConfigFile.java:142) at com.amazonaws.auth.profile.ProfilesConfigFile.<init>(ProfilesConfigFile.java:133) at com.amazonaws.auth.profile.ProfilesConfigFile.<init>(ProfilesConfigFile.java:100) at com.amazonaws.auth.profile.ProfileCredentialsProvider.getCredentials(ProfileCredentialsProvider.java:135) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.getCredentialsFromContext(AmazonHttpClient.java:1213) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.runBeforeRequestHandlers(AmazonHttpClient.java:789) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:739) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:732) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:714) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:674) at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:656) at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:520) at com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient.doInvoke(AWSSecurityTokenServiceClient.java:1368) at com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient.invoke(AWSSecurityTokenServiceClient.java:1335) at com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient.invoke(AWSSecurityTokenServiceClient.java:1324) at com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient.executeGetCallerIdentity(AWSSecurityTokenServiceClient.java:1012) at com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient.getCallerIdentity(AWSSecurityTokenServiceClient.java:984) at de.taimos.pipeline.aws.AWSIdentityStep$Execution.run(AWSIdentityStep.java:86) at de.taimos.pipeline.aws.AWSIdentityStep$Execution.run(AWSIdentityStep.java:77) at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Finished: FAILURE

Environment

Jenkins-Version: 2.165

Java-Version: openjdk version "1.8.0_191"

Plugin-Version: 1.36

Master/Slave Setup: Yes. The plugin is meant to be used on the slave. The slave has the profile configured and readable.

hoegertn commented 5 years ago

withAWS, like all non-workspace steps in Jenkins, is executed on the master and tries to read the file there. This is a known limitation and there are some tickets open for this. If anybody finds a way to change this, I am open to pull requests.

arianne-detorres commented 5 years ago

withAWS, like all non-workspace steps in Jenkins, is executed on the master and tries to read the file there. This is a known limitation and there are some tickets open for this. If anybody finds a way to change this, I am open to pull requests.

Does this mean this plugin can only work on master? Or it can be run on a slave, so long as the profile is configured on master?

hoegertn commented 5 years ago

This means that all steps that do not touch data in the workspace are executed on the master. Steps that need data, are run in the workspace on the agent.

arianne-detorres commented 5 years ago

We have the profile and credentials on the master, but still getting this error:

com.amazonaws.AmazonClientException: Unable to complete transfer: profile file cannot be null at com.amazonaws.services.s3.transfer.internal.AbstractTransfer.unwrapExecutionException(AbstractTransfer.java:286) at com.amazonaws.services.s3.transfer.internal.AbstractTransfer.rethrowExecutionException(AbstractTransfer.java:265) at com.amazonaws.services.s3.transfer.internal.AbstractTransfer.waitForCompletion(AbstractTransfer.java:103) at com.amazonaws.services.s3.transfer.internal.MultipleFileUploadImpl.waitForCompletion(MultipleFileUploadImpl.java:75) at de.taimos.pipeline.aws.S3UploadStep$RemoteListUploader.invoke(S3UploadStep.java:649) at de.taimos.pipeline.aws.S3UploadStep$RemoteListUploader.invoke(S3UploadStep.java:570) at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3086) at hudson.remoting.UserRequest.perform(UserRequest.java:212) at hudson.remoting.UserRequest.perform(UserRequest.java:54) at hudson.remoting.Request$2.run(Request.java:369) at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:93) at java.lang.Thread.run(Thread.java:748) Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1741) at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:357) at hudson.remoting.Channel.call(Channel.java:955) at hudson.FilePath.act(FilePath.java:1072) at hudson.FilePath.act(FilePath.java:1061) at de.taimos.pipeline.aws.S3UploadStep$Execution.run(S3UploadStep.java:416) at de.taimos.pipeline.aws.S3UploadStep$Execution.run(S3UploadStep.java:262) at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ... 1 more Caused by: java.lang.IllegalArgumentException: profile file cannot be null at com.amazonaws.util.ValidationUtils.assertNotNull(ValidationUtils.java:37) at com.amazonaws.auth.profile.ProfilesConfigFile.<init>(ProfilesConfigFile.java:142) at com.amazonaws.auth.profile.ProfilesConfigFile.<init>(ProfilesConfigFile.java:133) at com.amazonaws.auth.profile.ProfilesConfigFile.<init>(ProfilesConfigFile.java:100) at com.amazonaws.auth.profile.ProfileCredentialsProvider.getCredentials(ProfileCredentialsProvider.java:135) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.getCredentialsFromContext(AmazonHttpClient.java:1213) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.runBeforeRequestHandlers(AmazonHttpClient.java:789) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:739) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:732) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:714) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:674) at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:656) at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:520) at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4705) at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4652) at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1807) at com.amazonaws.services.s3.transfer.internal.UploadCallable.uploadInOneChunk(UploadCallable.java:133) at com.amazonaws.services.s3.transfer.internal.UploadCallable.call(UploadCallable.java:125) at com.amazonaws.services.s3.transfer.internal.UploadMonitor.call(UploadMonitor.java:143) at com.amazonaws.services.s3.transfer.internal.UploadMonitor.call(UploadMonitor.java:48) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ... 1 more

dvsingh9 commented 4 years ago

I got same while creating PinpointClient..