The Leap CodeArtifact Plugin is designed to simplify the process of injecting CodeArtifact Maven repository credentials into the Maven settings file (~/.m2/settings.xml)
. It uses the selected Leapp session to retrieve the information and credentials from the AWS account.
- Account Introspection: It lists CodeArtifact repositories
- Credentials Injection: It injects the maven configuration generating a new set of credentials automatically for each repository
- Open the Settings menu in your Leapp session.
- Add the package by specifying:
leapp-codeartifact-maven-plugin
That's it! The plugin will be installed and ready to use.
To customize the injected Maven profile, set the AWS_MAVEN_PROFILE
environment variable. Otherwise, the codeartifact
profile will be used. (after you do, restart the Leapp application)
- Right-Click on an AWS Active Session
- Select "Inject CodeArtifact Credentials" The session must be already active!
The application will perform the following tasks:
- Detect all CodeArtifact repositories associated with the selected session (credentials\region).
- Backup the existing user-defined file if have not been injected yet
(~/.m2/settings.xml.xxxx.bak)
. - For each CodeArtifact repository, the plugin will inject a server definition into the Maven configuration settings with the updated access token.
- Will generate a Maven profile and for each CodeArtifact repository will inject both a maven repository and a mavenPlugin repository entry.
The plugin operates in an “append-only” mode, which means it won’t remove any deleted CodeArtifact repositories. In the event of an id
collision, it will overwrite the related properties resource URL, username, or password.
You can continue to manage the maven settings file on your own freely. The plugin will place the generated profile into the activeProfile
section of the Maven Settings only the first time or when a new CodeArtifact repository is added to the configuration. This approach allows you to deactive the profile globally, and the plugin will inject the updated credentials without overriding your user choice.
A similar behavior has been implemented for the repository and pluginRepository profile section; if you delete one entry from only one of the two lists the plugin will not add it back, in this manner, you will be able to maintain a repository only as a pluginRepository or as a standard repository as your need.
- Clone this repository locally
- Install the dependencies
npm install
- To build and install the plugin inside the Leapp application locally you can run
npm run build-local
- Ensure you quit the Leapp application from the system tray before testing the plugin, if the plugin has already been loaded before the build the updated version will not be loaded
- Open the Leapp application, go to settings, and ensure that the plugin is enabled
To test the execution locally without the Leapp application you can run the inject
script,
The inject script will use any default AWS SDK session configuration.
- export AWS_PROFILE="aws-session-name"
- npm run inject
- $env:AWS_PROFILE="aws-session-name"
- npm run inject
- set AWS_PROFILE="aws-session-name"
- npm run inject
Please note that this plugin has been developed quickly and may not adhere to best practices or standards, it is provided as-is, without any guarantees or safety measures. Use it responsibly and consider security implications. :*D