anchor.diff:  }
   
   job(type: Maven) {
  -  name "${project_name}/fb-build"
  -  description("<p>This job builds feature branch code, run unit tests and triggered job with functional tests. Source code: <code>${git_url}</code></p>")
  -  jdk("/usr/lib/jvm/java/")
  -  configure { project ->
  -    project << globalSettings(class:'org.jenkinsci.plugins.configfiles.maven.job.MvnGlobalSettingsProvider', plugin:'config-file-provider@<%= @plugins['config-file-provider'] %>') {
  -      settingsConfigId('<%= @settings_id %>')
  -    }
  +  name "${project_name}/fb-build-review"
  +  description("<p>This job builds code and run unit tests. Triggered by Gerrit review action. Source code: <code>${git_url}</code></p>")
  +  jdk('/usr/lib/jvm/java/')
  +  parameters {
  +    stringParam("GERRIT_PROJECT", "${project_name}", "Gerrit project name")
  +    stringParam("GERRIT_BRANCH", "fb-*", "Gerrit branch")
  +    stringParam("GERRIT_REFSPEC", "refs/heads/fb-*", "Gerrit refspec")
  +  }
  +  configure { project ->
  +    project << globalSettings(
  +      class:'org.jenkinsci.plugins.configfiles.maven.job.MvnGlobalSettingsProvider',
  +      plugin:'config-file-provider@<%= @plugins['config-file-provider'] %>') {
  +        settingsConfigId('<%= @settings_id %>')
  +      }
     }
     scm {
       git {
         remote {
           name('origin')
           url(git_url)
  -      }
  -      branch('*/fb-*')
  +        refspec('\${GERRIT_REFSPEC}')
  +      }
  +      branch('*/\${GERRIT_BRANCH}')
       }
     }
     triggers {
       gerrit {
         events {
  -        RefUpdated
  +        patchsetCreated()
  +        draftPublished()
  +      }
  +      project("plain:${project_name}", 'ant:fb-*')
  +    }
  +  }
  +  logRotator(30, 50, -1, -1)
  +  concurrentBuild(true)
  +  goals('-e')
  +  goals('clean')
  +  goals('install')
  +  mavenInstallation(maven_installation)
  +  localRepository(LocalToWorkspace)
  +  postBuildSteps {
  +    maven {
  +      goals('pmd:pmd')
  +      goals('pmd:cpd')
  +      goals('checkstyle:checkstyle')
  +      goals('findbugs:findbugs')
  +      mavenInstallation(maven_installation)
  +      localRepository(LocalToWorkspace)
  +      configure { project ->
  +        project << globalSettings(
  +          class:'org.jenkinsci.plugins.configfiles.maven.job.MvnGlobalSettingsProvider',
  +          plugin:'config-file-provider@<%= @plugins['config-file-provider'] %>') {
  +            settingsConfigId('<%= @settings_id %>')
  +          }
  +      }
  +    }
  +  }
  +  publishers{
  +    pmd('**/pmd.xml') {
  +        shouldDetectModules true
  +    }
  +    checkstyle('**/checkstyle-result.xml') {
  +        shouldDetectModules true
  +    }
  +    findbugs('**/findbugsXml.xml', true)
  +    dry('**/cpd.xml')
  +    mailer("", false, true)
  +  }
  +  configure { project ->
  +    project / publishers << "hudson.plugins.jira.JiraIssueUpdater"(plugin:"jira@<%= @plugins['jira'] %>")
  +  }
  +  perModuleEmail(false)
  +}
  +
  +job(type: Maven) {
  +  name "${project_name}/fb-build"
  +  description("<p>This job builds feature branch code, run unit tests and triggered job with functional tests. Source code: <code>${git_url}</code></p>")
  +  jdk("/usr/lib/jvm/java/")
  +  configure { project ->
  +    project << globalSettings(class:'org.jenkinsci.plugins.configfiles.maven.job.MvnGlobalSettingsProvider', plugin:'config-file-provider@<%= @plugins['config-file-provider'] %>') {
  +      settingsConfigId('<%= @settings_id %>')
  +    }
  +  }
  +  scm {
  +    git {
  +      remote {
  +        name('origin')
  +        url(git_url)
  +      }
  +      branch('*/fb-*')
  +    }
  +  }
  +  triggers {
  +    gerrit {
  +      events {
  +        refUpdated()
         }
         project("${project_name}", "ant:fb-*")
       }
  
positive.code:   triggers {
      gerrit {
        events {
          PatchsetCreated
          DraftPublished
        }
        project("${project_name}", "dev")
      }
  
negative.code: def env_vars = System.getenv()
  def workspace_path = env_vars.WORKSPACE
  
  def qubellOutputFile = new File("\${workspace_path}/qubell_output.json")
  def userJson = new JsonSlurper().parseText(qubellOutputFile.text)
  def webapp_endpoint = userJson.returnValues.'output.webapp_endpoint'
  
  new File("petclinic_url.properties").withWriter{ it << "PETCLINIC_URL=\${webapp_endpoint}"}
  """
          }
          groovyName("Groovy-default")
  