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

feat: Added support for Git credential helper #121

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shaniru-aws
Copy link

Issue # (if applicable)

Closes #120 120.

Reason for this change

This is a feature request for CodeBuild created by SBT AppPlane to support cloning private Git repos.

Description of changes

I have added a field [here] (

)

The field I have added is to enable [git-credential-helper] (https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec.env.git-credential-helper)

Description of how you validated changes

I updated node modules locally and added the same field in the file 'bash-job-runner.js'

            buildSpec: codebuild.BuildSpec.fromObject({
                version: '0.2',
                env: {
                    'git-credential-helper': 'yes',
                    shell: 'bash',
                    ...(props.environmentVariablesToOutgoingEvent && {
                        'exported-variables': props.environmentVariablesToOutgoingEvent,
                    }),
                },
                phases: {
                    build: {
                        commands: props.script,
                    },
                    post_build: {
                        ...(props.postScript && { commands: props.postScript }),
                    },
                },
            }),
        });

I then executed

npm run build
npm install

and redeployed the SBT code. In the script supplied to Codebuild I executed the following command :

 git clone https://codestar-connections.ap-south-1.amazonaws.com/git-http/0123456789/ap-south-1/123456789123456/shaniru-aws/sample-github-repo.git

With this command I was able to clone the private GitHub repo where my source code was located.

Checklist

  • My code adheres to the CONTRIBUTING GUIDE
  • I have updated the relevant documentation (if applicable).

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

@shaniru-aws shaniru-aws changed the title Added support for Git credential helper feat: Added support for Git credential helper Dec 4, 2024
@suhussai
Copy link
Contributor

@shaniru-aws thanks for the contribution! Is there a reason why we are not parameterizing the git-credential-helper option? That way, users can decide for themselves whether they want to enable that instead of it being enabled by default (without any way of disabling it).

@shaniru-aws
Copy link
Author

shaniru-aws commented Dec 11, 2024

@suhussai yes we can do that. I will make the changes accordingly. I did not include that in my first iteration because even enabling the option would not change the behaviour of CodeBuild build run.

@suhussai
Copy link
Contributor

@suhussai yes we can do that. I will make the changes accordingly. I did not include that in my first iteration because even enabling the option would not change the behaviour of CodeBuild build run.

That's a good point, but it would be important to provide that flexibility in setting that option because it changes the default configuration of the CodeBuild project.

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

Successfully merging this pull request may close these issues.

CodeAppPlane CodeBuild Project: Add support to clone private Git repository as the application source code.
2 participants