问题
I am currently setting up Jenkins to work with SVN repository. Currently it works fine for the trunk. Now I want to set up Jenkins to take care of newly created branches. I don't want to create a new project manually for every new branch in SVN.
- Is there already a solution which allowes to use SVN and to create jobs/tasks in Jenkins automatically for every brach created in SVN?
- How do you use Jenkins with SVN tags/branches?
回答1:
Also check my extend answer if you are not very familiar with jenkins.
It provides a step by step solution with screenshots.
The subversion plugin is installed by default in recent versions(as for Sep 2015).
Then you should configure your project as following:
- check "This build is parameterized"
- choose "List subverion tags (and more)"
- in the name field, set a varaiable name which can be referenced later in the svn url. I choose svnbranch here.
- in the Repository URL field, give it your project URL (which needs to contain trunk, branches, and tags)
- fill other field as your needs
- in source code management, reference the variable defined before in your repository url.
check following screenshots:
回答2:
The Subversion plugin should include a drop-down build parameter option. You can include your base repository and then select either the branches, tags, or trunk.
Check this out: How to configure a single Jenkins job to make the release process from trunk or branches?
And more info here: https://issues.jenkins-ci.org/browse/JENKINS-10678
回答3:
We have a job for each branch and truck. If we have 30 projects, we have 30 trunk projects, and 30 projects for each branch we are currently using. That can be over a 150 jobs, but we use views to help separate them out. Very simple to use a branch (or even a tag) in Subversion: Simply use the URL that contains the branch.
I copy my jobs manually whenever we create a new branch. I usually abhor a manual process (manual process => making a mistake => majorly messing up => getting fired => working in Walmart), but there's really only two changes that must be made in my job. I have to change the Subversion URL, and the description. Everything else is set to use Jenkin's defaults. No wacky working directory, no funky copying of build artifacts (we store those in Jenkins). We have about 30 or so jobs, and I can duplicate all of them in less than a half hour.
I've simply had problems with the automation, and if I have to go through all the jobs anyway to make sure everything is fine, I might as well do it manually.
You could parameterize your builds. That is, have the user enter the branch's name (or select it from a drop down list. This means creating a single job for all of your branches. However, that defeats the continuous build aspect of Jenkins since you have to manually trigger each job.
Some sites have scripts that can mass produce a new branch. You simply need to copy the config.xml
(and a few other files) from under one job and modify it. Some sites have created template jobs that make this a bit easier. The template jobs are disabled, and thanks to the REST API, it's easy to enable jobs via wget
. They simply duplicate their template jobs, modify a few parameters, and then reenable all of those jobs.
There's a JobCopy builder Plugin that allows you to define template build projects, and then replace strings in the template to create actual jobs.
There's also an Ant script on the Jenkins Wiki that duplicates jobs for you.
来源:https://stackoverflow.com/questions/17146202/configure-jenkins-to-work-with-svn-branches