Groovy web console

subscribe to the feed Subscribe
to this
indexer problem on context (via #groovywebconsole)
tweet this snippet Tweet

indexer problem on context

Published 1 month ago by Marcello de Sales with tags indexing indexer emoji
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
  def msaasJenkinsParamters = ["🚀 Full CI/CD Pipeline", "🐳 CI Build Only", "📦 CD Deploy Revision",  "🔄 CD Re-deploy Environment", "🔬 CD Trigger TEP Tests"]
  def msaasOptionsKey = "MsaasCICD"
  def steps = [
    params: [:]
  steps.params[msaasOptionsKey] = null
  def defaultIndexParam = steps.params[msaasOptionsKey] ? makeParamIndexerKey(steps.params[msaasOptionsKey]) : makeParamIndexerKey("🚀 Full CI/CD Pipeline")

  def context = [
    jenkinsPipeline: [:]
  context.jenkinsPipeline.indexedParams = [:]

  def makeParamIndexerKey(name) {
    return name.substring(2).replace(" ", "")

  println "Current index is for ${steps.params[msaasOptionsKey]} with value ${defaultIndexParam}"

  // Default values
  msaasJenkinsParamters.each{ uiParam ->
    // Get the name without the emoji, no spaces to all for an index key
    def featureKeyValue = makeParamIndexerKey(uiParam)

    // Verify which argument was set based on the steps value
    // When the params are not set, then use the full build as usual
    context.jenkinsPipeline.indexedParams[featureKeyValue] = [
      ui: uiParam,
      enabled: false

  context.jenkinsPipeline.indexedParams[defaultIndexParam].enabled = true

println groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(context))