title: Using branches in Jenkins
body: <p>We are using a Perforce server as SCM tool and we use scipts (build step-->execute script) for all the SCM configuration (checking in, checking out, syncing etc) .i.e we do not intend to use any perforce plugin.</p>
  
  <p>Now we do have quartely releases, so every four months or so, the jobs running on jenkins need to be switched to different branch. Job Configuration remains more or less same between different branches, only the url changes(and it could be accomplished using a simple variable like $branch). We used a parametrized build where we defined a choiced parameter for selecting a branch.
  This works fine but we require some fine refinements in this.</p>
  
  <p>Following are the issues:-</p>
  
  <ul>
  <li>the build history of a job gets clogged with builds that have run on different branches. Although we have a post build groovy script which appends branch number to build number of jobs yet we would love to have a build history panel showing  jobs clubbed by branches.
  Somewhat like this:-</li>
  </ul>
  
  <hr>
  
  <h1>branch_name</h1>
  
  <ul>
  <li>#jobNo.</li>
  </ul>
  
  <hr>
  
  <ul>
  <li>the choice parameterized build by default take the top most parameter as default value and uses that in periodic build, so we end up having builds done only on one branch.</li>
  </ul>
  
  <p>We also thought of the following approach:-</p>
  
  <p>Dynamically creating new sets of jobs for each branch every time a branch comes into being. But that would lead to a large number of jobs (#branches * jobs_per_branch), and provided there is minimal configuration change between jobs over branches(i.e only the branch uri changes), this does not seems fruitful, although it presents a nice structured view for jobs. So we went for the parameterized build but the above two issues popped up.</p>