We are moving our projects from dev to qa and production. It is kind of painful to redo all jobs in jenkins or copy them individually. So using the scripting capabilities of Jenkins (groovy) we can copy the jobs with a new name and move them if you want to another view.

import hudson.model.*

def viewName = "product-build-dev"
def search = "-dev"
def replace = "-prod"

def view = Hudson.instance.getView(viewName)

/* now you copy all jobs of the view copy all projects of a view */
for(item in view.getItems()) {

  /* create the new project name */
  newName = item.getName().replace(search , replace)

  /* now copy the job */
  def job = Hudson.instance.copy(item, newName)

Categories: General

Rodrigo Asensio

Apasionado por la tecnología

Leave a Reply

Your email address will not be published. Required fields are marked *