<commit_before>/**

  JENKINS WORKFLOW FOR CAPISTRANO-TYPO3

  author: <NAME>

  This script is written with only capistrano-typo3 compatibility in
  mind. It can be modified for other purposes.

  Based on the excellent example script by <NAME> locate here
  https://github.com/satrun77/workflow-script

  Workflow steps in normal order:
  1. stepBootStrap
  2. stepSyncAndDeployCI
  3. stepTestCI
  4. stepDeployProduction
  5. stepTestProduction

  TODO
  - implement submitter for more security
*/
import hudson.model.User
import groovy.json.JsonSlurper
import hudson.tasks.Mailer


//+---------------- End of pre-conditions

jenkinsConfig = {}

deployers = {}
branchName = 'master'
StageNameCI = 'ci'
StageNameProduction = 'production'
watirGitUrl = ''
def emailTo = ''
rvmCommand = '/var/lib/jenkins/.rvm/bin/rvm ruby-2.1.5 exec'

interactive = true

//+---------------- End of configurations

def getBuildUserMailAddress() {
  def item = hudson.model.Hudson.instance.getItem(env.JOB_NAME)
  def build = item.getLastBuild()
  def cause = build.getCause(hudson.model.Cause.UserIdCause.class)
  def id = cause.getUserId()
  User u = User.get(id)
  def umail = u.getProperty(Mailer.UserProperty.class)
  return umail.getAddress()
}

def getUserId() {
  def item = hudson.model.Hudson.instance.getItem(env.JOB_NAME)
  def build = item.getLastBuild()
  def cause = build.getCause(hudson.model.Cause.UserIdCause.class)
  return cause.getUserId()
}

def stepBootStrap() {

  node {
    sh "mkdir -p cap"
    sh "mkdir -p src"

    dir('cap') {

      git url: capGitUrl

      sh "../yml2json.rb jenkins.yml jenkins.json"

      def str = readFile('jenkins.json')
      jenkinsConfig = new JsonSlurper().parseText(str)

      testers = jenkinsConfig['testers']
      developers = jenkinsConfig['developers']
      deployers = jenkinsConfig['deployers']

      emailTo = getBuildUserMailAddress()

      StageNameCI = jenkinsConfig['stage_name_ci']
      StageNameProduction = jenkinsConfig['stage_name_production']
      watirGitUrl = jenkinsConfig['watir_git_url']
      branchName = 'master'
    }
  }

  if(interactive) {

    def params = []
    def moveOptions = ''
    moveOptions += 'Run full deployment workflow\n'
    moveOptions += 'Single run stepSyncAndDeployCI\n'
    moveOptions += 'Start at stepTestCI\n'
    moveOptions += 'Start at stepDeployProduction\n'
    moveOptions += 'Start at stepTestProduction\n'

    def stepAction = askQuestion('stepBootStrap',params,moveOptions)

    if (stepAction['Move to'] == 'Single run stepSyncAndDeployCI') {
      stepSyncAndDeployCI()
      interactive = false
    }
    else if(stepAction['Move to'] == 'Start at stepTestCI') {
      stepTestCI()
    }
    else if(stepAction['Move to'] == 'Start at stepDeployProduction') {
      stepDeployProduction()
    }
    else if(stepAction['Move to'] == 'Start at stepTestProduction') {
      stepTestProduction()
    }
    else if(stepAction['Move to'] == 'Run full deployment workflow') {
      stepSyncAndDeployCI()
    }
  }
  else {
    stepSyncAndDeployCI()
  }
}

def stepSyncAndDeployCI() {

  stage 'stepSyncAndDeployCI'
  stageAction = true
<commit_msg>updates to improve performance<commit_after>/**

  JENKINS WORKFLOW FOR CAPISTRANO-TYPO3

  author: <NAME>

  This script is written with only capistrano-typo3 compatibility in
  mind. It can be modified for other purposes.

  Based on the excellent example script by <NAME> locate here
  https://github.com/satrun77/workflow-script

  Workflow steps in normal order:
  1. stepBootStrap
  2. stepSyncAndDeployCI
  3. stepTestCI
  4. stepDeployProduction
  5. stepTestProduction

  TODO
  - implement submitter for more security
*/
import hudson.model.User
import groovy.json.JsonSlurper
import hudson.tasks.Mailer


//+---------------- End of pre-conditions

jenkinsConfig = {}

deployers = {}
branchName = 'master'
StageNameCI = 'ci'
StageNameProduction = 'production'
watirGitUrl = ''
def emailTo = ''
rvmCommand = '/var/lib/jenkins/.rvm/bin/rvm ruby-2.1.5 exec'

interactive = true

//+---------------- End of configurations

def getBuildUserMailAddress() {
  def item = hudson.model.Hudson.instance.getItem(env.JOB_NAME)
  def build = item.getLastBuild()
  def cause = build.getCause(hudson.model.Cause.UserIdCause.class)
  def id = cause.getUserId()
  User u = User.get(id)
  def umail = u.getProperty(Mailer.UserProperty.class)
  return umail.getAddress()
}

def getUserId() {
  def item = hudson.model.Hudson.instance.getItem(env.JOB_NAME)
  def build = item.getLastBuild()
  def cause = build.getCause(hudson.model.Cause.UserIdCause.class)
  return cause.getUserId()
}

def stepBootStrap() {

  if(interactive) {

    def params = []
      def moveOptions = ''
      moveOptions += 'Run full deployment workflow\n'
      moveOptions += 'Single run stepSyncAndDeployCI\n'
      moveOptions += 'Start at stepTestCI\n'
      moveOptions += 'Start at stepDeployProduction\n'
      moveOptions += 'Start at stepTestProduction\n'

      def stepAction = askQuestion('stepBootStrap',params,moveOptions)
  }

  node {
    sh "mkdir -p cap"
    sh "mkdir -p src"

    dir('cap') {

      git url: capGitUrl

      sh "../yml2json.rb jenkins.yml jenkins.json"

      def str = readFile('jenkins.json')
      jenkinsConfig = new JsonSlurper().parseText(str)

      testers = jenkinsConfig['testers']
      developers = jenkinsConfig['developers']
      deployers = jenkinsConfig['deployers']

      emailTo = getBuildUserMailAddress()

      StageNameCI = jenkinsConfig['stage_name_ci']
      StageNameProduction = jenkinsConfig['stage_name_production']
      watirGitUrl = jenkinsConfig['watir_git_url']
      branchName = 'master'
    }
  }

  if(interactive) {

    if (stepAction['Move to'] == 'Single run stepSyncAndDeployCI') {
      stepSyncAndDeployCI()
        interactive = false
    }
    else if(stepAction['Move to'] == 'Start at stepTestCI') {
      stepTestCI()
    }
    else if(stepAction['Move to'] == 'Start at stepDeployProduction') {
      stepDeployProduction()
    }
    else if(stepAction['Move to'] == 'Start at stepTestProduction') {
      stepTestProduction()
    }
    else if(stepAction['Move to'] == 'Run full deployment workflow') {
      stepSyncAndDeployCI()
    }
  }
  else {
    stepSyncAndDeployCI()
  }
}

def stepSyncAndDeployCI() {

  stage 'stepSyncAndDeployCI'
  stageAction = true

{'fraction_non_alphanumeric': 0.118734335839599, 'fraction_numerical': 0.004072681704260651, 'mean_word_length': 3.325880758807588, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '176377', 'n_tokens_mistral': 2159, 'n_tokens_neox': 2057, 'n_words': 476}