As part of an Apache Ant execution I need to download a set of artefacts using an incantation as shown below using resolve and retrieve.
The artefacts are located in a Maven Repository that is part of a private project. Due to this, I need to retrieve the artefacts using authenticated access.
<ivy:resolve>
<dependency org="org.some"
name="artefact"
rev="0.0.1-SNAPSHOT" />
</ivy:resolve>
<ivy:retrieve />
How do I need to configure such access?
I have
- read the advice that I need to authenticate to download.
- looked for and not found a means to use Custom HTTP headers
- looked for and not found a means to use Basic Auth
- looked at the ivy settings and the credentials in particular.
The solution uses
basic authand is based on this comment on sbt.The
credentialselement has four attributes:host: the name of the hostrealm: the name of the realm (optional)username: the usernamepasswd: the passwordThe
realmcan be left out, as it is automatically set by Gitlab.The
usernameis one of the Custom HTTP header Token type names, in the example below it isPrivate-Token.The
passwdis the value of the private token.The
hostmust be the DNS name of the gitlab host, below it isgitlab.comBelow is the resulting
<ivysettingsfile: Two maven2 compatible resolvers are chained, with the first lacking arootattribute and so defaulting to${ivy.ibiblio.default.artifact.root}which is Maven Central. The second points at the private repository on gitlab.These settings can be enhanced to make use of interpolation of the project ID, so this template can be copied. Likewise, username and password can be extracted.
using the Predefined Variable
CI_PROJECT_IDvia Ivy Properties and Ant environment import as shown here.