Thanks for taking the time to read!
I am attempting to configure my grapeConfig (ivysettings) file to utilize a remote maven repository (github Packages) for grape installations while writing groovy scripts. For a specific questions, what from my config outlined below could be the problem preventing my credentials from being properly provided causing a 401 access error?
I am attempting to follow the instructions provided here (http://docs.groovy-lang.org/latest/html/documentation/grape.html#Grape-CustomizeIvysettings) and here (https://ant.apache.org/ivy/history/latest-milestone/settings/credentials.html)
And several other posts like the following where they instruct to use the credentials tag similar to the documentation provided by apache.
How to enrich "GrabResolver" with Login Credentials
Where do I put my credentials when using Ivy and a private company repository?
but when my script attempts to download the grapes i receive a 401.
For "TLDR" I am receieving a 401 from the remote repository "authentication: k='GitHub Package [email protected]' c='null' HTTP response status: 401 url=https://maven.pkg.github.com/<github-organization/repository>///0.0.1-SNAPSHOT/maven-metadata.xml"
i think my access problem is due to the line above shown from the debug statements. the "authentication:" has a parameter "K" set to what seems to be the realm and the variable "c" seems to be set to null. I am wondering if there is some misconfiguration in the way that the repositories credentials are being provided causing the 401.
Here is my configuration.
<ivysettings>
<property name="repo.pass" value="<git-hub-token>" override="false"/>
<property name="repo.user" value="<github-user>" override="false"/>
<property name="repo.realm" value="GitHub Package Registry" override="false"/>
<credentials host="https://maven.pkg.github.com" realm="${repo.realm}" username="${repo.user}" passwd="${repo.pass}"/>
<settings defaultResolver="downloadGrapes"/>
<resolvers>
<chain name="downloadGrapes" returnFirst="true">
<ibiblio name="gitHub" root="https://maven.pkg.github.com/<github-organization/repository>" m2compatible="true" />
<ibiblio name="localm2" root="${user.home.url}/.m2/repository/" checkmodified="true" changingPattern=".*" changingMatcher="regexp" m2compatible="true" usepoms="false"/>
<ibiblio name="ibiblio" m2compatible="true"/>
<ibiblio name="mirror" root="http://mirrors.ibiblio.org/maven2/" m2compatible="true"/>
</chain>
</resolvers>
</ivysettings>
If i happen to build the artifact that i am trying to pull from the remote repository locally (mvn install ) then i can resolve the dependency based on my "localm2" ibiblio.
while running the script with debug i can see that the settings i provided and the credentials i provided are detected and output. groovy -Divy.message.logger.level=4 test.groovy
---- snipit from debug output.
setting 'ivy.default.settings.dir' to 'jar:file:/C:/Program%20Files%20(x86)/Groovy/lib/ivy-2.5.1.jar!/org/apache/ivy/core/settings'
setting 'ivy.basedir' to 'C:\Users\<user>\IdeaProjects\homework\groovy\src\.'
setting 'ivy.default.conf.dir' to 'jar:file:/C:/Program%20Files%20(x86)/Groovy/lib/ivy-2.5.1.jar!/org/apache/ivy/core/settings'
.....
setting 'ivy.build.artifacts.dir' to '${ivy.project.dir}/build/artifacts'
setting 'ivy.lib.dir' to '${ivy.project.dir}/lib'
setting 'ivy.cache.ttl.default' to '10s'
setting 'ivy.buildlist.ivyfilepath' to 'ivy.xml'
setting 'ivy.distrib.dir' to '${ivy.project.dir}/distrib'
setting 'repo.pass' to '<git-hub-token>'
setting 'repo.user' to '<git-hub-user>'
setting 'repo.realm' to 'GitHub Package Registry'
credentials added: GitHub Package Registry@https://maven.pkg.github.com <username>/****************************************
......
settings loaded (208ms)
default cache: C:\Users\<user>\.ivy2\cache
default resolver: downloadGrapes
default latest strategy: latest-revision
default conflict manager: latest-revision
circular dependency strategy: warn
validate: true
check up2date: true
-- 5 resolvers:
downloadGrapes [chain] [gitHub, localm2, ibiblio, mirror]
return first: true
dual: false
-> gitHub
-> localm2
-> ibiblio
-> mirror
mirror [ibiblio]
cache: null
m2compatible: true
ivy patterns:
http://mirrors.ibiblio.org/maven2/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]
artifact patterns:
http://mirrors.ibiblio.org/maven2/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]
repository: mirror
root: http://mirrors.ibiblio.org/maven2/
pattern: [organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]
usepoms: true
useMavenMetadata: true
gitHub [ibiblio]
cache: null
m2compatible: true
ivy patterns:
https://maven.pkg.github.com/<github-organization/repository>/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]
artifact patterns:
https://maven.pkg.github.com/<github-organization/repository>/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]
repository: gitHub
root: https://maven.pkg.github.com/<github-organization/repository>/
pattern: [organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]
usepoms: true
useMavenMetadata: true
localm2 [ibiblio]
cache: null
m2compatible: true
ivy patterns:
artifact patterns:
file:/C:/Users/<user>//.m2/repository/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]
repository: localm2
root: file:/C:/Users/<user>//.m2/repository/
pattern: [organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]
usepoms: false
useMavenMetadata: true
ibiblio [ibiblio]
cache: null
m2compatible: true
ivy patterns:
https://repo1.maven.org/maven2/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]
artifact patterns:
https://repo1.maven.org/maven2/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]
repository: ibiblio
root: https://repo1.maven.org/maven2/
pattern: [organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]
usepoms: true
useMavenMetadata: true
module settings:
NONE
== resolving dependencies caller#all-caller;working52-><group>#<artifactId>;0.0.1-SNAPSHOT [default->default]
loadData of <group>#<artifactId>;0.0.1-SNAPSHOT of rootConf=default
using downloadGrapes to resolve <group>#<artifactId>;0.0.1-SNAPSHOT
downloadGrapes: Checking cache for: dependency: <group>#<artifactId>;0.0.1-SNAPSHOT {default=[default]}
no ivy file in cache for <group>#<artifactId>;0.0.1-SNAPSHOT: tried C:\Users\<user>\.groovy\grapes\<group>\<artifactid>\ivy-0.0.1-SNAPSHOT.xml
don't use cache for <group>#<artifactId>;0.0.1-SNAPSHOT: changing=true
try to get credentials for: GitHub Package [email protected]
authentication: k='GitHub Package [email protected]' c='null'
HTTP response status: 401 url=https://maven.pkg.github.com/<github-organization/repository>/<group>/<artifactId>/0.0.1-SNAPSHOT/maven-metadata.xml
CLIENT ERROR: Unauthorized url=https://maven.pkg.github.com/<github-organization/repository>/<group>/<artifactId>/0.0.1-SNAPSHOT/maven-metadata.xml
maven-metadata not available for: <group>#<artifactId>;0.0.1-SNAPSHOT
trying https://maven.pkg.github.com/<github-organization/repository>/<group>/<artifactId>/0.0.1-SNAPSHOT/<artifactId>-0.0.1-SNAPSHOT.pom
tried https://maven.pkg.github.com/<github-organization/repository>/<group>/<artifactId>/0.0.1-SNAPSHOT/<artifactId>-0.0.1-SNAPSHOT.pom
try to get credentials for: GitHub Package [email protected]
authentication: k='GitHub Package [email protected]' c='null'
The portion from the above that I am concerned about is the following.
authentication: k='GitHub Package [email protected]' c='null'
HTTP response status: 401 url=https://maven.pkg.github.com/<github-organization/repository>/<group>/<artifactId>/0.0.1-SNAPSHOT/maven-metadata.xml
CLIENT ERROR: Unauthorized url=https://maven.pkg.github.com/<github-organization/repository>/<group>/<artifactId>/0.0.1-SNAPSHOT/maven-metadata.xml
the "authentication:" has a parameter "K" set to what seems to be the realm" and the variable "c" seems to be set to null. I am wondering if there is some miss configuration in the way that the repositories credentials are being provided causing the 401.
I have verified my access to this remote repository by creating a separate maven project whos settings.xml are configured with the credentials i have provided in the ivySettings above. With this separate maven project when i conduct a build i can see the artifact being installed in my local m2.
I am assuming that there must something im doing incorrectly while providing the credentials. I do have an alternate solution if i cant get this solved, i will turn the project running the groovy script into a maven project utilizing a maven package to install the jars into my localm2 then allowing the ivyConfig to pull them from there.
Thanks for reading!