1
votes

I am trying to run python script which has code to access s3 using boto3 sdk. I have created default profile in my windows machine.

  1. aws cli commands are working fine in window cmd to access s3 bucket.
  2. python script is also working fine in when launched manually in window cmd

I am trying to automate it through jenkins. It is failing and complaining about Invalid token.

For testing purpose i ran following command in jenkins job.

aws sts get-caller-identity --debug

ClientError: An error occurred (InvalidClientTokenId) when calling the GetCallerIdentity operation: The security token included in the request is invalid 2019-06-17 18:09:06,513 - MainThread - awscli.clidriver - DEBUG - Exiting with rc 255

An error occurred (InvalidClientTokenId) when calling the GetCallerIdentity operation: The security token included in the request is invalid Build step 'Execute Windows batch command' marked build as failure

I tried following

  1. injecting AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN and AWS_ACCESS_KEY_ID, but no success.

  2. Added S3 profile plugin in jenkins and tried both option IAM role and by providing access token and secret.

Its not working.

I observed that jenkins is running on System User but i have created profile in window user.Is this the problem ?

1
the issue certainly seems to be with the variables not getting source to the jenkins user. the default creds would be loaded from the .credentials from the jenkins user profile. Assuming the user through which jenkins is running is jenkins user and the credetials are configured for that usererror404
@error404 is there any way to run on local user instead of System user in jenkins ? I am using jenkins latest community versionChris_vr
Is your jenkins on windows a master or slave ?error404
@error404 jenkins is installed on my local machine. I don't think i have set it up asmaster\slave.Chris_vr
@error404 Looks like you right issue is because credential are not configured properly for that user.Now it is working.Chris_vr

1 Answers

1
votes

The issue was with the USERPROFILE with which jenkins was running.

The default user profile creds were not loaded because the configurations was done for local user and not SYSTEM USER.

Adding .credentials under SYSTEM USER Jenkins worked fine.