diff --git a/src/registry/artifactory.rs b/src/registry/artifactory.rs index 33428092..ab88869c 100644 --- a/src/registry/artifactory.rs +++ b/src/registry/artifactory.rs @@ -54,9 +54,45 @@ impl Artifactory { uri.into() }; - let response = self.client.get(repositories_url).send().await?; + let response = { + let builder = reqwest::Client::builder() + .redirect(reqwest::redirect::Policy::none()) + .build() + .wrap_err("client error")? + .get(repositories_uri.as_str()); + + let builder = if let Some(token) = self.credentials.registry_tokens.get(&self.registry) + { + tracing::info!( + uri=?repositories_uri.as_str(), + token_length=?token.len(), + "Pinging with the {} header set", + Self::JFROG_AUTH_HEADER, + ); + builder.header(Self::JFROG_AUTH_HEADER, token) + } else { + tracing::info!( + uri=?repositories_uri.as_str(), + "Pinging WITHOUT the {} header set", + Self::JFROG_AUTH_HEADER + ); + builder + }; + + builder.send().await? + }; - ensure!(response.status().is_success(), "Failed to ping artifactory"); + let status = response.status(); + + if !status.is_success() { + tracing::info!("Artifactory response header: {:?}", response); + } + + ensure!( + status.is_success(), + "Failed to ping artifactory. Status {status}", + status = status.as_u16() + ); tracing::debug!("pinging artifactory succeeded");