Groovy web console

subscribe to the feed Subscribe
to this
site
msaas-v1.0-context-converter (via #groovywebconsole)
tweet this snippet Tweet
this
script

msaas-v1.0-context-converter

Published 2 months ago by Marcello de Sales with tags language converter
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
/**

  MSAAS Variables Converter 1.0

  * This script converts any existing MSAAS variables list to MSAAS-v1.0 variables

  1. Click on "Edit in console" button
  1. Copy-and-Paste all the variables and replace all the ones here to create the new msaas context variable
  2. Click on "Execute script"
  3. Copy the result and replace your current variables with the "context" variable in your code!
  
  Contact: mdesales

*/

// PASTE YOUR MSAAS VARIABLES HERE ############################


def l1 = 'services'
def l2 = 'config'
def serviceName = 'configuration-service'
def serviceAssetId = '1234567890'
def appName = "${l1}-${l2}-${serviceName}"
def deployable_branches = ["master"]
def argocd_server = new URL("https://example.int.com").getHost() + ":443"
def argocd_password = "argocd-${serviceName}"
def kson_compnt= "sample"
def ptNameVersion = "${serviceName}-${UUID.randomUUID().toString().toLowerCase()}"
def repo = "services/config/configuration-service/service"
def deploy_repo = "github.com/services/config-deployment.git"
def tag = ""
def registry = "docker.registry.com"
def image = "${repo}/${serviceName}"
def app_wait_timeout = 1200
def prd_diff_msg = ""
def stage_timeout = 20
def git_timeout = 2
def preprodOnly = true
def abortBuild = false
def nexusSnapshotCredId = "nexusSnapshotCredId"
def nexusReleaseCredId = "nexusReleaseCredId"

// ALL YOUR MSAAS VARIABLES ABOVE WILL BE CONVERTED ############################

println """

def context = [
  version: "1.0",
  devPortal: [
    serviceName: "${serviceName}",
    serviceAssetId: "${serviceAssetId}"
  ],
  argoCd: [
    server: "${argocd_server}", 
    appName: "${appName}",
    password: "${argocd_password}",
    ksonnet: [
      component: "${kson_compnt}"
    ],
    overallTimeout: ${stage_timeout},
    syncTimeout: ${app_wait_timeout}
  ],
  jenkinsPipeline: [
    deployableBranches: "${deployable_branches}",
    nodeName: "${ptNameVersion}",
  ],
  dockerRegistry: [
    host: "${registry}",
    repo: "${repo}",
    image: "${image}"
  ],
  gitOps: [
    deployRepo: "${deploy_repo}",
    pushTimeout: ${git_timeout}
  ],
  env: [

  ],
  abortBuild: false,
  nexus: [
    snapshotCredId: "${nexusSnapshotCredId}",
    nexusReleaseCredId: "${nexusReleaseCredId}"
  ]
]

"""