3

We store gradle files on http server with HTTP Auth. I thought I can apply these files by

apply from: "https://username:password@host.com/file.gradle

but it still returns 401. Looks like java.net.URL doesn't support it out of box

How can I specify username/password for apply scripts?

Community
  • 1
  • 1
fedor.belov
  • 22,343
  • 26
  • 89
  • 134
  • To solve it you can do following: 1. Add host.com to /etc/hosts 2. start nginx which will proxy host.com request to real server and add Authorization header – fedor.belov Sep 15 '15 at 11:40

1 Answers1

1

I ran into the same problem and ultimately I made the shared scripts available without requiring a login via https. I also considered putting them on a file server available from the network but that does not work to great across platforms.

Another possibility is to write a plugin and putting it on a (maven) artifact repository for which you can specify credentials. However if you want to specify your artifact URL in the common script, fetching the artifact from that repo does not work so great. Here is a example of such a script discovering scripts from the classpath.

You could consider exposing only this plugin and restricting access to the actual script with credentials stored in the project properties or local gradle installation.

real_paul
  • 574
  • 2
  • 22