Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
626 views
in Technique[技术] by (71.8m points)

Uploading war file to Nexus using jenkins job

I have a zip file which contains version like this xxx_1.2.3.zip now i created one jenkins job which will run and upload the zip in nexus using build.xml.

My question is i want to unzip and find the war file and want to upload zip and war file to nexus.i am able to do using below code but it is not storing the war file with its original name artifact id and group id.Zip contains yyy.war.when i stores to nexus it should upload like yyy_1.2.3.war.But is is storing as xxx-jenkins build number.war.

Please help .Thanks in advance.

 unzip ${xxx_ReleaseVersion}
 echo "<project> <modelVersion>4.0.0</modelVersion><groupId>zzz</groupId> <artifactId>xxx</artifactId> <version>${BUILD_NUMBER}  </version>       <packaging>pom</packaging> </project>" > pom.xml
 echo "<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
 <project basedir="." name="xxx" default="deploy"    xmlns:artifact="antlib:org.apache.maven.artifact.ant">
 <artifact:pom id="mypom" file="pom.xml" />
 <target name="deploy">       
 <artifact:deploy file="pom.xml">
 <remoteRepository url="https://URL/nexus/content/repositories/xxx">
    <authentication username="xxxx" password="1234" />
 </remoteRepository>
 <pom refid="mypom"/> 
 <attach file="${xxx_ReleaseVersion}" type="zip"/> " > build.xml
 find . -type f -name "*.war" -exec echo "<attach file="{}"type="war"/> "   >> build.xml ;
 echo "</artifact:deploy>
 </target>
 </project>  " >> build.xml

  pwd
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Use Nexus-Artifact-Uploader plugin in Jenkins

This plugin goal is to upload artifacts generated from non-maven projects to Nexus. This plugin now supports Nexus-2.x & Nexus-3.x.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...