Nexus 制品库管理实践03 raw类型的仓库

网友投稿 1442 2022-09-27

Nexus 制品库管理实践03 raw类型的仓库

Nexus 制品库管理实践03 raw类型的仓库

raw可以理解为本地文件存储类型,就相对于一块存储,可以往里面传入任何的包,制品和依赖是不同的,依赖是要被其他包所引用的,如maven。制品是要发布的包,这个就不需要依赖了。所以制品可以放到raw类型仓库就行了。

本地仓库类型有很多,这里可以选择,raw是最普通的格式了,可以理解为文件存储格式。

创建raw类型的仓库,这就是一个文件存储,所有的包都传到这上面来。如果是maven类型的制品,直接用引入。maven类型是依赖,是制品传上去之后需要被依赖。

如果只是将制品发布,作为服务,不需要被其他人引用,可以做为raw类型的

新建raw类型的仓库

上传制品

curl -u admin:admin123 如果Nexus开启了认证需要配置认证信息才能正常访问。

curl -X POST "\-H "accept: application/json" \-H "Content-Type: multipart/form-data" \-F "raw.directory=/acmp/acmp-myapp-service/1.1.1" \-F "raw.asset1=@target/demo-0.0.1-SNAPSHOT.jar;type=application/java-archive" \-F "raw.asset1.filename=acmp-myapp-service-1.1.1.jar" \-u admin:admin123

现在规范化一些,传到固定的仓库:devops-repo,这个仓库存放的是每个组的包

/acmp/acmp-myapp-service/1.1.1/acmp-myapp-service-1.1.1.jar

如果是前端服务:

/acmp/acmp-myapp-web/1.1.1/acmp-myapp-web-1.1.1.zip

stage('PushArtifacts'){ steps{ script{ repository = "devops-repo" version = "1.1.2" project = "${env.JOB_NAME}".split("-")[0] directory = "${project}/${env.JOB_NAME}/${version}" pkg = sh returnStdout: true, script: """ ls target/ | grep -E "jar\$" """ asset = pkg - "\n" filename = "${env.JOB_NAME}-${version}.jar" println(filename) sh "mv target/${asset} target/${filename} && ls target/" script{ withCredentials([usernamePassword(credentialsId: 'ff93f4bf-9d8c-4fc2-bccd-3e614f10d643', passwordVariable: 'passwd', usernameVariable: 'user')]) { nexus.PushRawArtifactsByApi(repository,directory,filename,user,passwd) } } } } }

def PushRawArtifactsByApi(repository,directory,filename,user,passwd){ sh """ curl -X POST "\ -H "accept: application/json" \ -H "Content-Type: multipart/form-data" \ -F "raw.directory=${directory}" \ -F "raw.asset1=@target/${filename};type=application/java-archive" \ -F "raw.asset1.filename=${filename}" \ -u "${user}":"${passwd}""""}

[Pipeline] { (PushArtifacts)[Pipeline] script[Pipeline] {[Pipeline] sh+ ls target/+ grep -E 'jar$'[Pipeline] echoacmp-myapp-service-1.1.2.jar[Pipeline] sh+ mv target/demo-0.0.1-SNAPSHOT.jar target/acmp-myapp-service-1.1.2.jar+ ls target/acmp-myapp-service-1.1.2.jarclassesdemo-0.0.1-SNAPSHOT.jar.originalgenerated-sourcesgenerated-test-sourcesmaven-archivermaven-statussurefire-reportstest-classes[Pipeline] script[Pipeline] {[Pipeline] withCredentialsMasking supported pattern matches of $passwd[Pipeline] {[Pipeline] shWarning: A secret was passed to "sh" using Groovy String interpolation, which is insecure. Affected argument(s) used the following variable(s): [passwd] See for details.+ curl -X POST '-H 'accept: application/json' -H 'Content-Type: multipart/form-data' -F raw.directory=/acmp-myapp-service/1.1.2 -F 'raw.asset1=@target/acmp-myapp-service-1.1.2.jar;type=application/java-archive' -F raw.asset1.filename=acmp-myapp-service-1.1.2.jar -u admin:****

可以看到一个项目acmp下面有很多的服务acmp-myapp-service等等......,每个服务下面有不同版本的包。

如果是静态项目,就是创建静态的压缩包

[root@jenkins-agent devops-web-service]# cd dist/[root@jenkins-agent dist]# tar zcf dist.tar.gz *[root@jenkins-agent dist]# lsdist.tar.gz index.html static curl -X POST "\ -H "accept: application/json" \ -H "Content-Type: multipart/form-data" \ -F "raw.directory=/devops/devops-web-service" \ -F "raw.asset1=@dist/dist.tar.gz;type=application/x-gzip" \ -F "raw.asset1.filename=devops-web-service-1.1.1.tar.gz" \ -u admin:admin123

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

上一篇:详解MybatisPlus中@TableLogic注解的使用
下一篇:何为企业数字化?探讨数字化APP和企业永续经营
相关文章

 发表评论

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