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

Support authentication for plugin repositories #31

Closed
jb-2020 opened this issue Dec 13, 2023 · 5 comments
Closed

Support authentication for plugin repositories #31

jb-2020 opened this issue Dec 13, 2023 · 5 comments
Labels
enhancement New feature or request
Milestone

Comments

@jb-2020
Copy link

jb-2020 commented Dec 13, 2023

In gradle/gradle-build-action#933 the gradle configurations were enhanced to support a custom plugin repository provided by the user. These plugin repositories can require authentication but there is currently no mechanism to also provide a credentials block to this configuration.

It would be helpful if we could also provide a username and password to the custom plugin repository e.g.

  repositories {
    maven { 
      url "<private gradle plugin repository>
      credentials {
        username = System.getenv("USERNAME")
        password = System.getenv("PASSWORD")
      }
    }
  }
@jb-2020 jb-2020 changed the title Support authenication for plugin repositories Support authentication for plugin repositories Dec 14, 2023
@bigdaz
Copy link
Member

bigdaz commented Dec 20, 2023

Yep, this makes sense. Would you be willing to develop, test and submit a fix?
The implementation should be a pretty simple change to this file, but I don't have an environment to easily test this functionality.

@jb-2020
Copy link
Author

jb-2020 commented Dec 20, 2023

@bigdaz I did attempt this a while back and I couldn't seem to use the the project credentials: e.g.

    val user: String by project
    val password: String by project

I think I'm misunderstanding the startup behavior of gradle and these 'init' scripts, the behavior is different than our typical method of gradle configuration. The only work around I found was to reference environment variables directly.

@bigdaz
Copy link
Member

bigdaz commented Dec 21, 2023

You won't be able to access the project instance from within the init-script. The script is loaded very early well before any project is loaded.

Just a thought: before trying to modify the init-script to load 2 new environment variables, can you try using a repository URL like:
https://user:password@repo.mycompany.com?
This is a valid URL format, but I'm not certain if Gradle will translate it to the correct AUTH headers.

@bigdaz bigdaz added the enhancement New feature or request label Jan 8, 2024
@bigdaz bigdaz transferred this issue from gradle/gradle-build-action Feb 9, 2024
@bigdaz
Copy link
Member

bigdaz commented Mar 11, 2024

Fixed in #61

@bigdaz bigdaz closed this as completed Mar 11, 2024
@bigdaz
Copy link
Member

bigdaz commented Mar 12, 2024

Also fixed in 7b589d9

@bigdaz bigdaz added this to the v3.2 milestone Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants