question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Send custom HTTP headers when publishing

See original GitHub issue

Hello,

When publishing to a private repository, it’s necessary for us to send custom HTTP headers when doing this. These headers contain, for example, authentication tokens.

I know that Maven uses a ~/.m2/settings.xml file for this where custom httpHeaders can be configured per server/repository. I haven’t found an analogous functionality in SBT to do this aside from basic authentication.

Is it possible to do this at the moment with SBT? If not, please consider this a feature request. 👍

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:39 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
alterationx10commented, Jul 20, 2020

@christianri if it helps, here is what I threw together https://gitlab.com/SLUDG/gitlab-sbt

I’ve never written an SBT plugin before, so I’m sure it’s far from perfect, but I got it to work!

Edit: I’ve moved the repo over to https://github.com/k8ty-app/sbt-publish

6reactions
ramabucommented, Aug 3, 2020

Hi @gilandose

Thank you so much for all the explanations. To sum this up:

To upload an artifact -

addSbtPlugin("com.gilcloud" % "sbt-gitlab" % "0.0.4")  // Add plugin; note version (project/plugin.sbt)
enablePlugin(GitlabPlugin)   // Enable the plugin (build.sbt)

// Define the plugin's settings(build.sbt):
GitlabPlugin.autoImport.gitlabProjectId :=  Option(1234)
GitlabPlugin.autoImport.gitlabDomain :=  "my.gitlab.net"
GitlabPlugin.autoImport.gitlabCredentials := Option(GitlabCredentials("Deploy-Token", "some-value"))

To download an artifact (dependency)

// in build.sbt
val glHost      = "my.gitlab.net"
val glGroup     = 4321
val glGrpRegistry=s"https://$glHost/api/v4/groups/$glGroup/-/packages/maven"

resolvers += s"gitlab at $glGrpRegistry"

val auth:Authentication = Authentication(Seq(("Private-Token","some-value")))
csrConfiguration ~= (_.addRepositoryAuthentication("gitlab",auth))
updateClassifiers / csrConfiguration ~= (_.addRepositoryAuthentication("gitlab",auth))

Read more comments on GitHub >

github_iconTop Results From Across the Web

Requests with custom HTTP headers - Progress Documentation
Custom HTTP headers can be used to filter requests or specify a value for the Accept header. Some endpoints employ custom HTTP headers...
Read more >
How To Send Custom HTTP Headers While Sending HTTP ...
Goal. Requirement is to send custom HTTP headers when sending data to external application with the EAI HTTP Transport.
Read more >
Back to Basics: Custom HTTP Response Header Manipulation ...
The simplest way you can add custom headers to every request response is by using a generic Middleware handler which uses app.Use() ....
Read more >
Publishing HTTP Headers to Monitoring Response with ...
The HttpStackHeaders.cs script allows showing the request, response, or both headers in the response, in the Online Report. Custom Script File ...
Read more >
Add custom HTTP headers · Cloudflare Pages docs
Cloudflare provides HTTP header customization for Pages projects by adding a _headers file to your project. Refer to the documentation for more ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found