Lets say I have a gitlab registry in my corporate network which has the following url:
https://gitlab.corp.xyz.com/api/v4/projects/1234/packages/maven
To connect to it, a private token is needed. Lets say my account has the following token
Name: Private-Token
Value: rVV8qr58zrkO5CV37HYf4
I have an application using gradle. In order to pull the needed jar files from that repository, to be used in my application....In my build.gradle file repositories section, I attempted the following:
repositories {
maven {
url "https://gitlab.corp.xyz.com/api/v4/projects/1234/packages/maven"
authentication {
basic(BasicAuthentication)
withHeaders {
header('Private-Token', 'rVV8qr58zrkO5CV37HYf4')
}
}
}
}
But I get the following error upon build:
Cannot create a Authentication named 'withHeaders' because this container does not support creating elements by name alone. Please specify which subtype of Authentication to create. Known subtypes are: BasicAuthentication, DigestAuthentication
I tried another way, as recommended in here but it didnt work either.
repositories {
maven {
url "https://gitlab.corp.xyz.com/api/v4/projects/1234/packages/maven"
credentials(HttpHeaderCredentials) {
name = "Private-Token"
value = "rVV8qr58zrkO5CV37HYf4"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
I am using an old version. Gradle 3.0.
Can anyone help me on this? so I could download my needed jars from that particular gitlab repository