Currently I using Jenkins version [Jenkins 2.387.2].
I have one scrpted pipeline which is working fine in us environment but getting below ouput in eu environment
Logs
Running on test-env-start-stop-9-q50t7-xd26t-0dfbm in /home/jenkins/agent/workspace/test_env_start_stop
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Update deployment)
[Pipeline] container
[Pipeline] {
[Pipeline] script
[Pipeline] {
[Pipeline] parallel
No branches to run
[Pipeline] // parallel
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // container
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
Finished: SUCCESS
envstartstop.jenkinsfile
@Library('orbs')
import ai.alto_platform.ServiceSelect
orb = new ServiceSelect()
def generateParametersList() {
def parametersList = [
choice(choices: orb.getDeploymentsList(env.ENVIRONMENT), description: 'Where to deploy to', name: 'DEPLOYMENT'),
choice(choices: ['---', 'start', 'stop'], description: 'Start or stop deployment', name: 'TYPE'),
string(defaultValue: '', description: 'How many pods do you want', name: 'SERVICES_REPLICAS', trim: true),
]
return parametersList
}
def checkAction(isDynamic, replicas, baseReplicas) {
if (isDynamic) { return true }
if (!isDynamic && replicas < baseReplicas ) { return false }
return true
}
properties([
parameters(generateParametersList()),
pipelineTriggers([
parameterizedCron('''
H 17 * * * %TYPE=stop;
''')
])
])
podTemplate(yaml: """
apiVersion: v1
kind: Pod
spec:
containers:
- name: go-apps
image: 412645720149.dkr.ecr.us-east-1.amazonaws.com/alto/go-applications:latest
command: ['cat']
env:
- name: AWS_DEFAULT_REGION
value: "${env.AWS_REGION}"
tty: true
serviceAccountName: jenkins-sa
"""
) {
node(POD_LABEL) {
stage('Update deployment') {
container('go-apps') {
script {
def deployments = orb.getStartStopDeployments(env.ENVIRONMENT, env.AWS_REGION, env.DEPLOYMENT)
def job = [:]
if (TYPE == "start" || TYPE == "stop") {
deployments.each {
String DEPLOYMENT_NAME = it.key
boolean IS_DYNAMIC = it.value["stop"]
int BASE_REPLICAS = it.value["replicas"]
int REPLICAS_COUNT = it.value["replicas"]
if ((env.DEPLOYMENT && env.DEPLOYMENT != "---") && env.SERVICES_REPLICAS ) {
REPLICAS_COUNT = Integer.parseInt(env.SERVICES_REPLICAS);
}
if (TYPE == "stop") {
REPLICAS_COUNT = 0
}
if (checkAction(IS_DYNAMIC, REPLICAS_COUNT, BASE_REPLICAS)) {
job["${DEPLOYMENT_NAME}"] = {
stage(DEPLOYMENT_NAME) {
sh """
export CONFIG=/tmp/config.yml
export NAMESPACE=${DEPLOYMENT_NAME}
export REPLICAS=${REPLICAS_COUNT}
gomplate --left-delim '<<' --right-delim '>>' -f /app/gomplate-templates/config.tmpl -o \${CONFIG}
environment-start-stop
"""
}
}
}
}
} else {
println "Nothing to do"
}
parallel job
}
}
}
}
}
ServiceSelect.groovy
package ai.alto_platform
public class ServiceSelect {
def serviceList = [
qa: [
"---": [repo: "---", image: "---", has_db: false, chart_repo: "", valid_deployments: ["---"]],
"graphql": [repo: "alto-portal", image: "alto/graphql", has_db: false, chart_repo: "alto_private", valid_deployments: ["qa-1", "qa-2", "qa-3", "demo", "e2e"]],
"portal": [repo: "alto-portal", image: "alto/portal", has_db: false, chart_repo: "alto_private", valid_deployments: ["qa-1", "qa-2", "qa-3", "demo", "e2e"]],
"gateway": [repo: "alto-ai", image: "alto/gateway", has_db: false, chart_repo: "alto_private", valid_deployments: ["qa-1", "qa-2", "qa-3", "demo", "e2e"]],
"service-management": [repo: "alto-ai", image: "alto/service-management", has_db: false, chart_repo: "alto_private", valid_deployments: ["qa-1", "qa-2", "qa-3", "demo", "e2e"]],
"user-management": [repo: "alto-ai", image: "alto/user-management", has_db: false, chart_repo: "alto_private", valid_deployments: ["qa-1", "qa-2", "qa-3", "demo", "e2e"]],
"semantic-data": [repo: "alto-ai", image: "alto/semantic-data", has_db: false, chart_repo: "alto_private", valid_deployments: ["qa-1", "qa-2", "qa-3", "demo", "e2e"]],
"ar-model-data": [repo: "alto-ai", image: "alto/ar-model-data", has_db: false, chart_repo: "alto_private", valid_deployments: ["qa-1", "qa-2", "qa-3", "demo", "e2e"]],
"semantic-index": [repo: "semantic-index", image: "alto/semantic-index", has_db: false, chart_repo: "alto_private", valid_deployments: ["qa-1", "qa-2", "qa-3", "demo", "e2e"]],
"semantic-search": [repo: "semantic-search", image: "alto/semantic-search", has_db: false, chart_repo: "alto_private", valid_deployments: ["qa-1", "qa-2", "qa-3", "demo", "e2e"]],
"auth": [repo: "alto-keycloak", image: "alto/keycloak", has_db: false, chart_repo: "codecentric", valid_deployments: ["qa-1", "qa-2", "qa-3", "demo", "e2e"]],
"intelligent-search": [repo: "intelligent-search", image: "alto/intelligent-search", has_db: false, chart_repo: "alto_private", valid_deployments: ["qa-1", "qa-2", "qa-3", "demo", "e2e"]],
"audit-log": [repo: "alto-ai", image: "alto/audit-log", has_db: false, chart_repo: "alto_private", valid_deployments: ["qa-1", "qa-2", "qa-3", "demo", "e2e"]],
"search-manager": [repo: "alto-ai", image: "alto/search-manager", has_db: false, chart_repo: "alto_private", valid_deployments: ["qa-1", "qa-2", "qa-3", "demo", "e2e"]],
"image-recognition": [repo: "image-recognition", image: "alto/image-recognition", has_db: false, chart_repo: "alto_private", valid_deployments: ["qa-1", "qa-2", "qa-3", "demo", "e2e"]],
"image-recognition-worker": [repo: "image-recognition", image: "alto/image-recognition", has_db: false, chart_repo: "alto_private", valid_deployments: ["qa-1", "qa-2", "qa-3", "demo", "e2e"]],
],
prod: [
"---": [repo: "---", image: "---", has_db: false, chart_repo: "", valid_deployments: ["---"]],
"graphql": [repo: "alto-portal", image: "alto/graphql", has_db: false, chart_repo: "alto_private", valid_deployments: ["prod"]],
"portal": [repo: "alto-portal", image: "alto/portal", has_db: false, chart_repo: "alto_private", valid_deployments: ["prod"]],
"gateway": [repo: "alto-ai", image: "alto/gateway", has_db: false, chart_repo: "alto_private", valid_deployments: ["prod"]],
"service-management": [repo: "alto-ai", image: "alto/service-management", has_db: false, chart_repo: "alto_private", valid_deployments: ["prod"]],
"user-management": [repo: "alto-ai", image: "alto/user-management", has_db: false, chart_repo: "alto_private", valid_deployments: ["prod"]],
"semantic-data": [repo: "alto-ai", image: "alto/semantic-data", has_db: false, chart_repo: "alto_private", valid_deployments: ["prod"]],
"ar-model-data": [repo: "alto-ai", image: "alto/ar-model-data", has_db: false, chart_repo: "alto_private", valid_deployments: ["prod"]],
"semantic-index": [repo: "semantic-index", image: "alto/semantic-index", has_db: false, chart_repo: "alto_private", valid_deployments: ["prod"]],
"semantic-search": [repo: "semantic-search", image: "alto/semantic-search", has_db: false, chart_repo: "alto_private", valid_deployments: ["prod"]],
"auth": [repo: "alto-keycloak", image: "alto/keycloak", has_db: false, chart_repo: "codecentric", valid_deployments: ["prod"]],
"intelligent-search": [repo: "intelligent-search", image: "alto/intelligent-search", has_db: false, chart_repo: "alto_private", valid_deployments: ["prod"]],
"audit-log": [repo: "alto-ai", image: "alto/audit-log", has_db: false, chart_repo: "alto_private", valid_deployments: ["prod"]],
"search-manager": [repo: "alto-ai", image: "alto/search-manager", has_db: false, chart_repo: "alto_private", valid_deployments: ["prod"]],
"image-recognition": [repo: "image-recognition", image: "alto/image-recognition", has_db: false, chart_repo: "alto_private", valid_deployments: ["prod"]],
"image-recognition-worker": [repo: "image-recognition", image: "alto/image-recognition", has_db: false, chart_repo: "alto_private", valid_deployments: ["prod"]],
],
]
def apiTests = [
qa: [
"us-east-1": [ testCase: [ "qa-1", "qa-2", "qa-3", "demo", "e2e" ], baseDomain: "qa.ai.carear.app", defaultTestDeployment: "demo",],
"ca-central-1": [ testCase: [ "ca" ], baseDomain: "ca.qa.ai.carear.app", defaultTestDeployment: "demo",],
"eu-central-1": [ testCase: [ "eu" ], baseDomain: "eu.qa.ai.carear.app", defaultTestDeployment: "demo",],
],
prod: [
"us-east-1": [ testCase: [ "prod" ], baseDomain: "ai.carear.app", defaultTestDeployment: "prod",],
],
]
def databricksInstance = [
qa: [
"us-east-1": "dbc-b7cca391-cb19.cloud.databricks.com",
"ca-central-1": "dbc-161ede5b-db60.cloud.databricks.com",
"eu-central-1": "dbc-789a765f-e5a1.cloud.databricks.com",
],
prod: [
"us-east-1": "dbc-9f2c4bee-e531.cloud.databricks.com",
"ca-central-1": "dbc-373eb745-84d7.cloud.databricks.com",
"eu-central-1": "dbc-1df5c58d-e6ed.cloud.databricks.com",
],
]
def envStartStop = [
qa: [
"us-east-1": [
"qa-1": [ stop: false, replicas: 1 ],
"qa-2": [ stop: true, replicas: 1 ],
"qa-3": [ stop: true, replicas: 1 ],
"demo": [ stop: false, replicas: 2 ],
"e2e": [ stop: true, replicas: 1 ],
],
"ca-central-1": [
"demo": [ stop: true, replicas: 2 ],
],
"eu-central-1": [
"demo": [ stop: false, replicas: 2 ],
],
]
]
def getServicesList(environment) {
def services = []
serviceList[environment].each{
key, value -> services.add(key)
}
return services
}
def getDeploymentsList(environment) {
def deployments = []
serviceList[environment].each{
key, value -> deployments.addAll(value.valid_deployments)
}
return deployments.unique()
}
def getServiceRepository(environment, service) {
return serviceList[environment][service]["repo"]
}
def getServiceImage(environment, service) {
return serviceList[environment][service]["image"]
}
def getChartRepo(environment, service) {
return serviceList[environment][service]["chart_repo"]
}
def getImageRepo(environment, service) {
return serviceList[environment][service]["image"]
}
def getTestCase(environment, region) {
return apiTests[environment][region]["testCase"].unique()
}
def getBaseDomain(environment, region) {
return apiTests[environment][region]["baseDomain"]
}
def getDefaultTestDeployment(environment, region) {
return apiTests[environment][region]["defaultTestDeployment"]
}
def getDatabricksInstance(environment, region) {
return databricksInstance[environment][region]
}
def getStartStopDeployments(environment, region, deployment = null) {
if (deployment == "---") {
return envStartStop[environment][region]
} else if (deployment){
return [(deployment): envStartStop[environment][region][deployment]]
}
else {
return envStartStop[environment][region]
}
}
Can you suggest I want to make my deployment replica to 0 while stop and make to one or more while start