Git Product home page Git Product logo

codeartifact-gradle-plugin's Introduction

Codeartifact gradle plugin

Gradle plugin which authenticates against AWS CodeArtifact using your local credentials to obtain the token.

Usage

In your build.gradle file:

plugins {
    id 'ai.clarity.codeartifact' version '0.0.11'
}

repositories {
    maven {
        url 'https://domain-id.d.codeartifact.eu-central-1.amazonaws.com/maven/repository/'
    }
}

publishing {
    repositories {
        maven {
            url 'https://domain-id.d.codeartifact.eu-central-1.amazonaws.com/maven/repository/'
        }
    }
}

Advanced Usage

If you need a concrete profile for AWS authentication you have 4 different options:

1 - Add the profile name to the repository url as a query param:

repositories {
    maven {
        url 'https://domain-id.d.codeartifact.eu-central-1.amazonaws.com/maven/repository/?profile=prod'
    }
}

Note: The query param is used to configure the profile and automatically removed from the url in any request to AWS.

2 - Define the environment var AWS_PROFILE with the profile name you want to use

This plugin uses AWS SDK for authorization, all the standard environment vars are applicable.

3 - Define the environment var CODEARTIFACT_PROFILE with the profile name you want to use

If you need a different profile for codeartifact than for the rest of AWS calls you can use this environment var.

4 - Define the profile using a system property

If you need a different profile for codeartifact and you cannot define a enviroment variable, you can define it via system property also:

This way using gradle.properties file:

systemProp.codeartifact.profile=<your profile>

Or using command line:

gradle -Dcodeartifact.profile=<your profile> ...

codeartifact-gradle-plugin's People

Contributors

darquesdev avatar dependabot[bot] avatar elliotsegler avatar jerolba avatar jfisbein avatar sdelamo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codeartifact-gradle-plugin's Issues

Builds fail with error "Could not find method getSharedServices()"

I added this plugin to a project exactly as described in the instructions and now any Gradle task, including clean fails with the following error:

> Configure project :
Evaluating root project '[project]' using build file '/Users/benfa/repos/[project]/build.gradle'.

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/benfa/repos/[project]/build.gradle' line: 5

* What went wrong:
An exception occurred applying plugin request [id: 'ai.clarity.codeartifact', version: '0.0.12']
> Failed to apply plugin [id 'ai.clarity.codeartifact']
   > Could not find method getSharedServices() for arguments [] on build '[project]' of type org.gradle.invocation.DefaultGradle.

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

I'm using the latest version of this plugin (0.0.12) and Gradle 5.3. Is there a minimum Gradle version this plugin can be used with?

The token caching does not seem to work (at least not when using the plugin for allprojects from init.gradle.kts)

From looking at your code, I could see you intended to cache tokens for the lifetime of the plugin.
But it seems that, despite the gradle daemon staying around, the plugin instance does not.

To test the hypothesis, I ran the same command twice, and expected the second one to not output anything (ie. no GetAuthorization, because the token from the first one is not expired yet).

$ gradle build --debug | grep "/v1/authorization-token"
2021-09-17T13:12:28.564+0200 [DEBUG] [software.amazon.awssdk.request] Sending Request: DefaultSdkHttpFullRequest(httpMethod=POST, protocol=https, host=codeartifact.eu-central-1.amazonaws.com, encodedPath=/v1/authorization-token, headers=[amz-sdk-invocation-id, User-Agent], queryParameters=[domain, domain-owner])
2021-09-17T13:12:28.674+0200 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Executing request POST /v1/authorization-token?domain=SCRUBBED&domain-owner=411628588745 HTTP/1.1
2:17
$ gradle build --debug | grep "/v1/authorization-token"
2021-09-17T13:12:34.989+0200 [DEBUG] [software.amazon.awssdk.request] Sending Request: DefaultSdkHttpFullRequest(httpMethod=POST, protocol=https, host=codeartifact.eu-central-1.amazonaws.com, encodedPath=/v1/authorization-token, headers=[amz-sdk-invocation-id, User-Agent], queryParameters=[domain, domain-owner])
2021-09-17T13:12:35.107+0200 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Executing request POST /v1/authorization-token?domain=SCRUBBED&domain-owner=411628588745 HTTP/1.1

Add support for SSO based profiles

Hi

When using AWS SSO based profiles (i.e. profiles relying on the SsoCredentialsProvider) builds fails to pull dependencies with the following:

$ ./gradlew

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'TestProject'.
> To use Sso related properties in the 'test-aws-sso-profile' profile, the 'sso' service module must be on the class path.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

It looks like the BOM is missing the sso service as a dependency.

Unable to get the plugin to work for repositories within a pluginManagement block

As I don't see any pluginManagement in your README.md, I assume it's not supported.

Are you aware of any such limitation?

This is what I'm trying to do:

pluginManagement {
    repositories {
        maven {
            url = uri(
                "https://SCRUBBED.codeartifact.REGION.amazonaws.com/maven/SCRUBBED/"
            )
        }
    }
}

As I intend to publish gradle plugins to CodeArtifact, other projects need a way to consume said plugins...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.