Deploy Artifact From Jenkins to Archiva with NAnt

2019-08-12 23:55发布

I'm admittedly new to the whole continuous integration idea. As such, I've been scouring the web to find a way to take my ASP.NET project, feed it through Jenkins for auto-build using NAnt and mono on a Linux box, and ultimately deploy the artifact into Apache Archiva to be retrieved later for installation, etc.

My problem is, I don't know how to integrate this hand-off of the artifact from Jenkins to Archiva.

So, here's what I understand:

  • Archiva can be used to store any type of artifact. .zip files (which is what I want to use), .jar files, etc.
  • Jenkins can build the source code using NAnt to call Mono to my .NET 4.0 project
  • Jenkins can also zip the files up into a suitable artifact

Here's what I don't understand:

  • How could I get the .zip file (artifact) from where it's stored when Jenkins builds it, to the Archiva repository?

Here's what I'm working with:

  • The Jenkins (1.502) server and Archiva (1.3.4) server are on the same Ubuntu 12.04 machine
  • NAnt (0.92) build script
  • Mono (2.10)

What I don't know anything about (but might help?):

  • Maven
  • Ivy

2条回答
神经病院院长
2楼-- · 2019-08-13 00:16

A possibility to ease deployment to Archiva from Jenkins for non maven build could write a plugin similar to https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+Plugin (NOTE: I can help you but no time ATM to do everything :-) ). I don't know NAnt a lot but for ant, we build some maven ant task to deploy artifacts see http://maven.apache.org/ant-tasks/

查看更多
太酷不给撩
3楼-- · 2019-08-13 00:18

Set up a separate Jenkins "task" that uses Maven to deploy.

Note: You don't need to know too much about Maven to make this work. You'll have to install it. You'll have to configure it as described on the page below and you'll need to call it from a command line using that information. (If you want to learn more, you can use the alternate suggesion.)

Set up the settings.xml using information from this page:

http://archiva.apache.org/docs/1.4-M2/userguide/deploy.html

That same page shows how to do it running Maven from a command line. To use this, you will create a Jenkins task that runs a shell script and deploys directly from where ever the build task creates it. Then you either run the deploy by hand or you make the Jenkins build task run the deploy task when it finishes without error.

One thing you might not be familiar with is Archiva/Maven's system of coordinates for each file.

Each artifact has a group, artifact id and version. There can be a classifier and such if you want.

  • The group is typically, the company's domain name backwards plus internal taxonomy indicators -- com.microsoft.phone.web for a web app created by the phone division at microsoft.
  • The artifact id is the name of a particular artifact.
  • The version is a normal form of version string - 1.0a or 2.0-asl or 3.2.1.
  • The classifier is used similar to the way we use file extensions - zip, jar.

This is the short version of this explained. Google is your friend here.

You can also use a Maven task to do this. The information on the Archiva page regarding the pom.xml file will be needed but you will have to Google "Maven deploy" and read how to do it for your particular case. The default case deploys when the artifacts are in the local Maven repo (on the build machine) and that repo has a specific file and folder structure that you need. That's the way Maven arranges artifacts when it creates and 'install's them.

查看更多
登录 后发表回答