0

We have a maven project for which we have set up jenkins for build. The reporsitory has a large tools folder which i didn't want Jenkins to download.

I just want jenkins to download src folder and pom.xml file. I added two reporsitory locations in Jenkins - only to learn that Single file checkouts are not possible

This forced me to use shell script option provided by Jenkins for checking out pom .xml . PFB the script outline.

svn checkout $pomUrl . --depth empty
svn update pom.xml

I did not find an option in my scm plugin of Jenkins to do an empty checkout

Checkout one file from Subversion

But POLL SCM of jenkins is only polling the src folder and builds are not triggered if i make some changes to pom.xml. Is there a way to ensure Polling of my pom.xml as well?

Workspace of Jenkins

Community
  • 1
  • 1
  • That's not checking out your pom.xml, that's checking out an empty folder, then selectively updating it... very different. It will always be a hack and is not how subversion or jenkins was designed to be used – Cole9350 Aug 05 '14 at 14:29
  • thanks @Cole9350 but why do you call it a "hack" - isn't it the best option if you want sparse checkouts? – searchingforPerfection Aug 07 '14 at 20:55
  • No. Because you don't get the .svn folder. And you don't have a working copy. You can't take advantage of Jenkins scm polling or pull commit messages on your build file. The simple thing to do is put the things you don't need to pull into the build in a seperate folder – Cole9350 Aug 08 '14 at 03:20

1 Answers1

2

No. Jenkins will poll what it knows.

In your scenario:

  • Jenkins doesn't know about your pom.xml.
  • Jenkins doesn't work in single file checkouts anyways.

You will have to rearrange your structure, either move the tools folder outside of the main checkout (if it's so large that it's prohibitive, why do you have it in the root location?), or move the pom.xml into the src folder.

Edit:
Here is an idea. Haven't tried so don't know if that will work.

  • Keep your manual checkout and update of that pom like you currently do.
  • Setup another SVN Add module....
  • Enter the root location of SVN where your pom is, give it a non-conflicting folder name
  • Configure Repository depth for that module as Empty (if you don't see this option, you may need to upgrade your SVN plugin and/or Jenkins).
  • Click Advanced... section.
  • Configure Included Regions with the path to your src folder, and the pom only.
  • Something like: /trunk/myapp/src/.* /trunk/myapp/pom.xml
Slav
  • 27,057
  • 11
  • 80
  • 104
  • default maven project structure. see the maven super pom http://maven.apache.org/guides/introduction/introduction-to-the-pom.html – searchingforPerfection Jul 31 '14 at 19:28
  • Nowhere does it say you should dump the tools folder into the root – Slav Jul 31 '14 at 19:56
  • I cannot demand a change a project stucture- _The goal should be acheived by sparse checkouts_- i.e Just checkout what i want and build. I did not understand, what you meant by **"Jenkins doesn't know about your pom.xml"** - My Jenkins build is working fine- Only Poll SCM operation for triggering my Job is what that is not working. Jenkins has a feature to execute shell scripts before and after build-Which was used to checkout pom.xml - I did not do it from "outside". Am i making sense ?? – searchingforPerfection Aug 04 '14 at 12:17
  • Some thing like this - But POLL SCM is a must-http://stackoverflow.com/questions/10319173/exclude-directory-during-jenkins-checkout – searchingforPerfection Aug 04 '14 at 12:29
  • @user3159518. You **are** doing it "outside" of Jenkins SCM. When it comes to SCM and Jenkins, only the `SCM step` is the one that matters. When you run a script with an `svn` command in it (be it a shell script, or ant, or anything), you are doing it "outside of Jenkins", and Jenkins doesn't know about it. When you tell it to build the pom, it knows from the build perspective, but from SCM perspective it doesn't know about it. I have an idea, I will append the answer – Slav Aug 05 '14 at 13:16
  • Edit added. But in all honesty, just let Jenkins checkout that one tools folder once, and be done with it. Subsequent updates will be quick unless you are wiping out the workspace often – Slav Aug 05 '14 at 13:26
  • Your answer probably is near.... Unfortunately i can't try it right now because my Jenkins does not have that option to set depth of checkout- our project practice is to "always take a fresh checkout" this is ruining time + the server is always running out of capacity – searchingforPerfection Aug 07 '14 at 20:19