1 // inspired/copied from https://github.com/liejuntao001/jenkins-k8sagent-lib
3 import org.wamblee.jenkins.pipelinelib.MyYaml
5 // containers: comma-separated list of containers to include. The order of the containers i
6 // important. Each container in the list corresponds to a yaml file in the podtemplates resource
8 // repo: docker repo, default is the repo configured in the CONTAINER_REGISTRY environment variable
9 // version: version to use, defaults to BRANCH_NAME
10 // label: label to use for the agent. Defaults to the stage name if the agent is configured within a stage,
11 // otherwise the job name is used.
13 // All of the arguments specified in the call to agentsetup are passed without change to the
14 // pod template files and can be accessed in the yaml file as ${name} where name is the
18 version: env.BRANCH_NAME,
19 repo: env.CONTAINER_REGISTRY,
20 label: env.STAGE_NAME ? env.STAGE_NAME: env.JOB_NAME,
25 args.label = env.JOB_NAME
27 args.label = args.label + "-" + env.STAGE_NAME
29 args = defaults << args
31 // combine the configured application templates
32 args.label = args.label.toLowerCase().replaceAll("[^a-zA-Z0-9]", "-").replaceAll("-+", "-")
38 files="$( find . -name '*.template' )"
41 base="$( dirname "$file")/$( basename "$file" .template )"
44 for (key in args.keySet()) {
45 command += """ | sed 's|\\\$${key}|${args[key]}|g' """
48 command += ''' > "$file.tmp"
49 mv "$file.tmp" "$base"
53 println "processresources: ${args}"
54 println "processresources: $command"