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

为什么80%的码农都做不了架构师?>>>   hot3.png

使用gitlab token登录maven私服(sonatype nexus),这里需要用到nexus-gitlab-token-auth-plugin。

选择nexus-gitlab-token-auth-plugin原因:

  • 不同的人使用个人帐号,使得组件上传可追溯(此前所有人共用帐号,无法追溯组件上传,也不安全)
  • 没有类似LDAP的基础设施,而且LDAP每个用户还需分配权限
  • nexus和gitlab都是为开发者提供服务的平台,使用者相同,可以打通帐号体系
  • nexus-gitlab-token-auth-plugin插件只需一次配置就会对所有认证的账户授予deploy权限,省去给每个帐号授权的烦恼

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

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

 

nexus-gitlab-token-auth-plugin使用步骤如下所示:

构建插件:

插件编译构建命令 (需要自己手动构建插件 ):

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

编译注意事项:maven的版本[3.0.4,3.1.0)

 

插件安装:

  1. 解压bundle(target/nexus-gitlab-token-auth-plugin-0.3.0-bundle.zip)到sonatype-work/nexus/plugin-repository
    使用gitlab token登录maven私服(sonatype nexus)_第1张图片
  2. 拷贝&编辑sample/gitlab-plugin.xml 到 sonatype-work/nexus/conf/gitlab-plugin.xml(可以根据需要选择是否分配管理员角色,建议去掉)使用gitlab token登录maven私服(sonatype nexus)_第2张图片
  3. 启动Nexus,Administration->Server,添加Gitlab Token Authentication Realm到Selected realms 
    使用gitlab token登录maven私服(sonatype nexus)_第3张图片

 

nexus设置:

nexus创建gitlab-plugin.xml设置的默认角色(可以给默认角色deploy的权限)。
使用gitlab token登录maven私服(sonatype nexus)_第4张图片

生成gitlab token:

Gitlab→Settings→Access Tokens
使用gitlab token登录maven私服(sonatype nexus)_第5张图片

 

登录nexus验证帐号:

登录nexus时,需要使用邮箱和token。
使用gitlab token登录maven私服(sonatype nexus)_第6张图片

maven settings.xml设置认证信息:

maven settings.xml server节点的username和password分别配置成邮箱和gitlab token

使用gitlab token登录maven私服(sonatype nexus)_第7张图片

到此,便可使用gitlab token来登录maven私服并进行deploy操作。

转载于:https://my.oschina.net/donhui/blog/1502438

你可能感兴趣的:(使用gitlab token登录maven私服(sonatype nexus))