Skip to content

Commit 565f3da

Browse files
create a palace template from groovy (cloudbees#59)
1 parent 46390b7 commit 565f3da

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

create-palace-template.groovy

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
@Author: Kuisathaverat
3+
@Description: Create a Palace template from a groovy script.
4+
**/
5+
6+
def config = [
7+
templateName:"custom-palace-template",
8+
imageName:"maven",
9+
dockerRepo:"registry.hub.docker.com/library",
10+
tag:"3.3-jdk-8"]
11+
12+
def templateName = "${config.templateName}"
13+
def instance = jenkins.model.Jenkins.getInstance().createProject(com.cloudbees.tiger.plugins.palace.templates.DockerSlaveTemplate.class, templateName)
14+
instance.setDisplayName(templateName)
15+
instance.setLabelString(templateName)
16+
instance.setCpus(config["cpus"] ? config["cpus"] : 0.1)
17+
instance.setMemory(config["memory"] ? config["memory"] : 512)
18+
instance.setJvmMemory(config["jvmMemory"] ? config["jvmMemory"] : 256)
19+
instance.setJvmArgs('')
20+
instance.setRemoteFS("/jenkins")
21+
instance.setImage("${config["dockerRepo"]}/${config["imageName"]}:${config["tag"]}")
22+
def containerPropertiesList = []
23+
// containerPropertiesList.add(new com.cloudbees.tiger.plugins.palace.model.URISpec("https://s3.amazonaws.com/S3BUCKET/docker.tar.gz",false,true))
24+
containerPropertiesList.add(new com.cloudbees.tiger.plugins.palace.model.EnvironmentVariableContainerProperty("TZ","America/New_York"))
25+
instance.setContainerProperties(containerPropertiesList)
26+
instance.save()

0 commit comments

Comments
 (0)