Created
February 14, 2026 11:19
-
-
Save illarionov/11dbf2a6e7f62217071e2a75e84abfd8 to your computer and use it in GitHub Desktop.
Adding github credentials to all projects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 1) Generate classic token with read:packages permission | |
| // 2) Save this to ~/.gradle/init.d | |
| // 3) change <token> to generated token | |
| logger.info('Applying init.gradle to add Github credentials') | |
| def githubCredentials = { | |
| username = 'illarionov' | |
| password = '<token>' | |
| } | |
| settingsEvaluated { settings -> | |
| settings.dependencyResolutionManagement { | |
| repositories.withType(org.gradle.api.artifacts.repositories.MavenArtifactRepository).matching { | |
| it.url.host == 'maven.pkg.github.com' | |
| }.all { | |
| credentials(githubCredentials) | |
| } | |
| } | |
| } | |
| gradle.projectsLoaded { | |
| rootProject.allprojects { | |
| buildscript { | |
| repositories.withType(org.gradle.api.artifacts.repositories.MavenArtifactRepository).matching { | |
| it.url.host == 'maven.pkg.github.com' | |
| }.all { | |
| credentials(githubCredentials) | |
| } | |
| } | |
| repositories.withType(org.gradle.api.artifacts.repositories.MavenArtifactRepository).matching { | |
| it.url.host == 'maven.pkg.github.com' | |
| }.all { | |
| credentials(githubCredentials) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment