CI流水线中制品库集成 maven编译过后包上传

网友投稿 264 2022-11-02


CI流水线中制品库集成 maven编译过后包上传

使用本地仓库

现在去配置仓库的认证信息才能去上传,这个认证信息在maven里面去配置的

我们需要在nexus中创建一个新的仓库maven-hostd,同时我们需要在maven的配置文件settings.xml中配置maven-hostd认证。如下:

[root@jenkins-master ~]# vim /usr/local/apache-maven-3.8.1/conf/settings.xml maven-hosted admin admin123

注意使用mvn deploy 发布时,server.id == respository.id。

mvn deploy:deploy-file-DgroupId=xxxxxx pom中的groupId-DartifactId=xxxxxx pom中的artifactId-Dversion=xxxxxx pom中的版本号version-Dpackaging=xxxxxx pom中打包方式-Dfile=xxxxxx 本地文件-Durl=xxxxxx 仓库url-DrepositoryId=xxxxxx 对应的是setting.xml(认证)

直接读取pom文件(方便),获取pom文件里面的信息上传

mvn deploy:deploy-file \-DgeneratePom=false \-DrepositoryId=maven-hosted \-Durl=\-DpomFile=pom.xml \-Dfile=target/demo-0.0.1-SNAPSHOT.jar

[INFO] ------------------------------------------------------------------------[INFO] BUILD FAILURE[INFO] ------------------------------------------------------------------------[INFO] Total time: 1.987 s[INFO] Finished at: 2021-06-16T17:33:52+08:00[INFO] ------------------------------------------------------------------------[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file (default-cli) on project demo: Failed to deploy artifacts: Could not transfer artifact com.example:demo:jar:0.0.1-20210616.093352-1 from/to maven-hosted (transfer failed for status: 400 Repository version policy: RELEASE does not allow version: 0.0.1-20210616.093352-1 -> [Help 1][ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.[ERROR] Re-run Maven using the -X switch to enable full debug logging.[ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles:[ERROR] [Help 1] devops-maven-service-master]# vim pom.xml 0.0.1-SNAPSHOT将snapshit版本修改为release版本 0.0.1

[root@jenkins-master devops-maven-service-master]# mvn deploy:deploy-file \> -DgeneratePom=false \> -DrepositoryId=maven-hosted \> -Durl=\> -DpomFile=pom.xml \> -Dfile=target/demo-0.0.1-SNAPSHOT.jarvim pom.xml ^C[root@jenkins-master devops-maven-service-master]# ^C[root@jenkins-master devops-maven-service-master]# ^C[root@jenkins-master devops-maven-service-master]# vim pom.xml [root@jenkins-master devops-maven-service-master]# mvn deploy:deploy-file \> -DgeneratePom=false \> -DrepositoryId=maven-hosted \> -Durl=\> -DpomFile=pom.xml \> -Dfile=target/demo-0.0.1-SNAPSHOT.jar[INFO] Scanning for projects...[INFO] [INFO] --------------------------< com.example:demo >--------------------------[INFO] Building demo 0.0.1[INFO] --------------------------------[ jar ]---------------------------------[INFO] [INFO] --- maven-deploy-plugin:2.8.2:deploy-file (default-cli) @ demo ---Uploading to maven-hosted: to maven-hosted: (17 MB at 439 kB/s)Uploading to maven-hosted: to maven-hosted: (1.2 kB at 5.9 kB/s)Downloading from maven-hosted: to maven-hosted: to maven-hosted: (295 B at 3.0 kB/s)[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 40.967 s[INFO] Finished at: 2021-06-16T17:39:16+08:00[INFO] ------------------------------------------------------------------------

自定义pom信息(灵活)

mvn deploy:deploy-file -Dmaven.test.skip=true \-Dfile=target/demo-0.0.1-SNAPSHOT.jar \-DgroupId=com.example \-DartifactId=demo \-Dversion=1.1.1 \-Dpackaging=jar \-DrepositoryId=maven-hosted \-Durl=http://139.198.170.122:8081/repository/maven-hosted/

这就是包的上传方式,比如你有npm,gradle这些。


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:@PathVariable注解,让spring支持参数带值功能的案例
下一篇:Nexus 05 第二种方式 使用Jenkins Nexus插件上传制品
相关文章

 发表评论

暂时没有评论,来抢沙发吧~