Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws credentials entered into project config not persisting across reloading of page. #3

Closed
snspinn opened this issue Aug 24, 2018 · 5 comments

Comments

@snspinn
Copy link

snspinn commented Aug 24, 2018

I am running Jenkins ver. 2.121.3 as a docker container.
Docker ver. 18.06.1-ce.

I am having difficulty accessing aws credentials through Jenkins. I tried two approaches:

  • If I try to include credentials in Source Code Management -> Git -> Repositories (Enter URL and Credentials here) my AWS credentials do not appear despite being saved on Jenkins.
  • If I try Source Code Management -> Git -> Additional Behaviours -> AWS CodeCommit URL Helper at least here they appear as an option. However, after getting build errors I realised upon returning to the configuration page that the changes to this field had not been saved (I tried selecting both 'SAVE' and 'APPLY') despite getting the 'Saved'message from Jenkins.

The Error from my project build:
Started by user admin
Building in workspace /var/jenkins_home/workspace/CodeCommit-Project
FATAL: Meh
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@1fd4d944: profile file cannot be null, com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper@7d32b41c: 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)
at br.com.ingenieux.jenkins.plugins.codecommit.CodeCommitRequestSigner.<init>(CodeCommitRequestSigner.java:35)
at br.com.ingenieux.jenkins.plugins.codecommit.CodeCommitURLHelper.fetchCodeCommitRepositoryNames(CodeCommitURLHelper.java:156)
at br.com.ingenieux.jenkins.plugins.codecommit.CodeCommitURLHelper.decorate(CodeCommitURLHelper.java:123)
Caused: hudson.plugins.git.GitException: Meh
at br.com.ingenieux.jenkins.plugins.codecommit.CodeCommitURLHelper.decorate(CodeCommitURLHelper.java:129)
at hudson.plugins.git.GitSCM.createClient(GitSCM.java:823)
at hudson.plugins.git.GitSCM.createClient(GitSCM.java:812)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1180)
at hudson.scm.SCM.checkout(SCM.java:504)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
at hudson.model.Run.execute(Run.java:1798)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Finished: FAILURE

I have aws cli installed in the docker container. Could this be causing conflict? I initially did so because I thought it would be a prerequisite to getting CodeCommit to work with Jenkins.

@aldrinleal
Copy link
Member

On this scenario, it is resorting to the default behaviour, when no credentials are present. Did you upgrade the credentials and the AWS Credentials plugin as well?

@snspinn
Copy link
Author

snspinn commented Aug 27, 2018

All applications and Plugins are the latest version or up-to-date.

My point is that when I input my credentials and save the build configuration, exit the page and re-enter the build configuration, no credentials are listed in my build configuration.

I shall try this first by re-creating the docker container and if that is unsuccessful I shall see if the problem goes away if Jenkins is run outside of docker.

EDIT: I just tried rebuilding the docker image with apt-get update in the Dockerfile to update the awscli there. No change in behaviour.

@snspinn
Copy link
Author

snspinn commented Aug 27, 2018

@aldrinleal OK, this is embarrassing... I rebuild the image again, this time not installing awscli in the Dockerfile(as I had done previously). The "good" point here is that I didn't need to include this step at after all, helping reduce the size of my docker container/image.
The embarrassing part is that the above had no influence on the outcome of my tests. I was cloning the repo twice, once with the git plugin in the 'Source Code Management' section and again in the 'Build' section: sh git <https://myawsrepo> .
My errors were originating from the Build step all along and not where I (erroneously) assumed.

I got too caught up in the unorthodox behavior of this plugin to notice this simple mistake.

Presumably this plugin functions normally even when it appears like it might not be.

Closing issue. Thanks for your help.

@snspinn snspinn closed this as completed Aug 27, 2018
@snspinn snspinn reopened this Aug 27, 2018
@snspinn snspinn closed this as completed Aug 27, 2018
@aldrinleal
Copy link
Member

I believe a Jenkinsfile needs to be checked out first, so I guess the answer is no, right?

@bennymn
Copy link

bennymn commented Sep 10, 2019

I'm facing this issue now. Can you please help with the workaround?

The selection resets even after saving/applying changes to the pipeline and the build fails as it doesn't recognize the credentials.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants