简体   繁体   中英

Github authentication: how to use Github as Maven repo when repo is private

I'm trying to store some of our private artifacts on Github and would like to access them as if they were part of a Maven repo. There are lots of pages that explain how to create a public Maven repo on Github: you just put the artifacts in the proper directory structure in your project, and then access them using a "raw" URL:

<repositories>
  <repository>
    <id>myrepo.myname.github.com</id>
    <url>https://github.com/myname/myproject/raw/master/repositories/releases/</url>
  </repository>
</repositories>   

So far, so good. Now the trouble is that I can't figure out how to access the repo if it's private. I've added a username and password to my settings.xml, but it doesn't work:

<servers>
    <server>
      <id>myrepo.myname.github.com</id>
      <username>myusername</username>
      <password>mypassword</password>
    </server>
 </servers>

What's the trick?

The question is now moot. Github has eliminated downloads. They don't host binaries any more. Probably because of exactly the kind of abuse I've proposed...

I've never done this either. But github allows ssh/key authentication, that may work?

<servers>
    <server>
        <username/>
        <password/>
        <privateKey/>
        <passphrase/>
        <filePermissions/>
        <directoryPermissions/>
        <configuration/>
        <id/>
    </server>
</servers>

On GitHub you can add the key (at least it looks like if it is possible) to that repository (Repository -> Admin -> Deploy Keys): https://help.github.com/articles/managing-deploy-keys

I've used ssh to deploy artifacts on a linux server a few years ago before we installed a repository proxy. That was a bit tricky to setup on the client (trusted keys and so on) but it worked nicely. I remember you needed to execute a mvn deploy manually for the first time to add the server key/fingerprint locally before this could be done automatically by a script or CI server.

您可以使用以下URL从Maven pom.xml访问私有存储库: https ://api.github.com/users/username/repos?login =username &token = anothertoken&repositoryname =reameame

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM