0

I am using ANT to build artifacts(finally all artifacts will be zipped in one zip file) and jenkins plugin 'Nexus Artifact Uploader' to upload artifact to nexus repository.

I want to download the artifact(zip file) from nexus repository using ANT OR jenkins plugin only. I am not supposed to use maven for this task. Also, unix commands like 'wget' or 'curl' are not allowed in my deployment environment. It fails with permission denied error. So, I want solution using either ANT or jenkins plugin only.

Can anyone please help.

Ranjeet
  • 151
  • 6
  • 18
  • try to check this thread - https://stackoverflow.com/questions/11848406/jenkins-how-to-check-out-artifact-from-nexus-and-deploy-on-tomcat – BigGinDaHouse Apr 03 '18 at 10:23
  • I am sorry, I forgot to mention that unix commands like 'wget' or 'curl' are not allowed in my deployment environment. It fails with permission denied error. So, I want solution using either ANT or jenkins plugin. – Ranjeet Apr 03 '18 at 10:36
  • are you using jenkins pipelines or old fashion jenkins jobs ? – BigGinDaHouse Apr 03 '18 at 10:37
  • I am using old fashion jenkins job as it is not that complex project. I have a job to build and upload artifacts to nexus. And this second job will download these artifacts and upload to target runtime. But there is almost no possibility of executing deployment job after completing build job. Deployment job will be executed less frequently compared to build job. So there won't be any pipeline here. – Ranjeet Apr 03 '18 at 11:52
  • I see, if you can use jenkins2.0 Jenkinsfiles (aka pipelines) it will give you possibility to download from nexus via clean Groovy code, which will make your life easier. – BigGinDaHouse Apr 04 '18 at 07:14
  • Can you use external ant tasks? https://maven.apache.org/resolver-archives/resolver-ant-tasks-LATEST/index.html – rseddon Apr 05 '18 at 13:43
  • @rseddon I am already using ant contrib tasks. But I think I have to configure Maven for the tasks you mentioned in your comment. Deployment environment will ONLY have Apache Ant, Java and Jenkins.Nothing else is allowed to be installed/configured there. – Ranjeet Apr 09 '18 at 13:49
  • Apache Ant Get task looks promising... I tried to implement it as below: – Ranjeet Apr 10 '18 at 10:55
  • Apache Ant -> Get task looks promising... I tried to implement it as below: ''.. but it throws FileNotFound Exception. Can anyone please help. – Ranjeet Apr 10 '18 at 12:04

1 Answers1

1

You can use below ant project snippet to download artifacts from nexus

<project name="testdown" default="dependencies" basedir=".">
 <target name="dependencies">
<mkdir dir="libraries" />
<get src="http://10.135.155.72:8081/repository/maven-central/log4j/log4j/1.2.9/log4j-1.2.9.jar" dest="liblibraries/log4j-1.2.9.jar" usetimestamp="true" />
</target>
</project>
Adnan Khan
  • 861
  • 5
  • 5
  • Can you please let me know how can I upload the artifact to nexus using ANT. Right now I am using Jenkins plugin. – Ranjeet Apr 17 '18 at 05:14
  • you can use nexus artifact uploader plug in available for jenkins. https://wiki.jenkins.io/display/JENKINS/Nexus+Artifact+Uploader – Adnan Khan Apr 17 '18 at 09:10
  • I am already using this plugin. In our project, jenkins admin is a very busy person :P. So, I don't want to wait for his availability. My ant script should upload artifact i.e. zip file to nexus repository. – Ranjeet Apr 24 '18 at 12:57