使用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使用步骤如下所示:
构建插件:
插件编译构建命令 (需要自己手动构建插件 ):
- mvn generate-sources
- mvn clean install -DskipTests=true
编译注意事项:maven的版本[3.0.4,3.1.0)
插件安装:
- 解压bundle(target/nexus-gitlab-token-auth-plugin-0.3.0-bundle.zip)到sonatype-work/nexus/plugin-repository
- 拷贝&编辑sample/gitlab-plugin.xml 到 sonatype-work/nexus/conf/gitlab-plugin.xml(可以根据需要选择是否分配管理员角色,建议去掉)
- 启动Nexus,Administration->Server,添加Gitlab Token Authentication Realm到Selected realms
nexus设置:
nexus创建gitlab-plugin.xml设置的默认角色(可以给默认角色deploy的权限)。
生成gitlab token:
Gitlab→Settings→Access Tokens
登录nexus验证帐号:
登录nexus时,需要使用邮箱和token。
maven settings.xml设置认证信息:
maven settings.xml server节点的username和password分别配置成邮箱和gitlab token
到此,便可使用gitlab token来登录maven私服并进行deploy操作。
(adsbygoogle = window.adsbygoogle || []).push({});