使用gitlab token登陸maven私服(sonatype nexus)

使用gitlab token登陸maven私服(sonatype nexus),這裏須要用到nexus-gitlab-token-auth-plugin。git

選擇nexus-gitlab-token-auth-plugin緣由:

  • 不一樣的人使用我的賬號,使得組件上傳可追溯(此前全部人共用賬號,沒法追溯組件上傳,也不安全)
  • 沒有相似LDAP的基礎設施,並且LDAP每一個用戶還需分配權限
  • nexus和gitlab都是爲開發者提供服務的平臺,使用者相同,能夠打通賬號體系
  • nexus-gitlab-token-auth-plugin插件只需一次配置就會對全部認證的帳戶授予deploy權限,省去給每一個賬號受權的煩惱

nexus-gitlab-token-auth-plugin in github:github

https://github.com/jdamick/nexus-gitlab-token-auth-plugin安全

 

nexus-gitlab-token-auth-plugin使用步驟以下所示:

構建插件:

插件編譯構建命令 (須要本身手動構建插件 ):maven

  1. mvn generate-sources
  2. mvn clean install -DskipTests=true

編譯註意事項:maven的版本[3.0.4,3.1.0)gitlab

 

插件安裝:

  1. 解壓bundle(target/nexus-gitlab-token-auth-plugin-0.3.0-bundle.zip)到sonatype-work/nexus/plugin-repository
  2. 拷貝&編輯sample/gitlab-plugin.xml 到 sonatype-work/nexus/conf/gitlab-plugin.xml(能夠根據須要選擇是否分配管理員角色,建議去掉)
  3. 啓動Nexus,Administration->Server,添加Gitlab Token Authentication Realm到Selected realms 

 

nexus設置:

nexus建立gitlab-plugin.xml設置的默認角色(能夠給默認角色deploy的權限)。
spa

生成gitlab token:

Gitlab→Settings→Access Tokens
插件

 

登陸nexus驗證賬號:

登陸nexus時,須要使用郵箱和token。
server

maven settings.xml設置認證信息:

maven settings.xml server節點的username和password分別配置成郵箱和gitlab tokenxml

到此,即可使用gitlab token來登陸maven私服並進行deploy操做。token

相關文章
相關標籤/搜索