Question

For now I have a batch file with commands for update projects using svn and calling maven 'clean install'. How to create some job in Jenkins for similar actions? Should I write it to ant file (sorry if it's stupid idea, I've just heard about it but I don't know what is it exactly and what can I do with this) or there is other way?

Thanks

Was it helpful?

Solution

Like arghtype suggested, you need to be using Jenkin's own Source Code Management by configuring SVN as SCM source and supplying credentials as part of Maven build job.

If you have to use your own local working copy, you are organizing it wrong, you will lose on all the benefits of having Jenkins manage SVN changes, and in the end, this organization will give you more unsolvable problems in the future. Think about the advice people are giving here and come with up a reason why you need to have a local workspace outside of Jenkins management on a Jenkins build machine. My only guess is: your Jenkins and Development machine are the same. That again is not how it should be organized. Jenkins is a CI-server, not a personal build "automator".

Regardless, if you still want to do what you say.

What you think you want

  • Create a new Freestyle job
  • Under Build Steps, click Add build step
  • Select Execute Windows batch command
  • Write your batch execute command in there. Your working directory will be Jenkins's $WORKSPACE, so change your path accordingly to where you want to run it.

But with the above configuration, you might have as well put the batch file under windows scheduler... You are not really using Jenkins with the above.

What you should do instead

  • Create a new maven2/3 build job
  • Under Source Code Management, select Subversion
  • Under Repository URL enter the remote SVN repo (i.e. http://your.svnsever.com/path/to/project)
  • Under Build, enter your Root POM location (this will be relative to the location of your SVN checkout, so if your POM is under http://your.svnserver.com/path/to/project/maven/pom.xml, then enter maven/pom.xml.
  • Under Goals and options, enter clean install
  • Click Save

The Source Code Management section will take care of setting up a local workspace and checkout the repository into that workspace. By default, every time a new build is triggered, it will run svn update on that workspace for you.

The Maven Build step will take care of running your Maven, however note that it is configured to use default ~/.m2/repository location. If your local maven repo needs to be different, change this under Jenkins Global Configuration

OTHER TIPS

  1. Create a new job.
  2. In Source Management choose Subversion, specify your repo and credentials.
  3. Add a new build step - maven build, specify your maven goals ('clean install').

Jenkins is a CI(contiounus integration) server. It can be used to generate scheduled builds of ant or maven based projects. It can also start building projects by some triggering event such as a commit to SCM (git, svn, mercurial,...)connected to it. You really have to read its documentation to get a better understanding. It has nice tutorials.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top