[DO-1378] add_new_pod (#49)
add couple pod templates and one method for jenkins class Co-authored-by: Rustam Tagaev <rustam.tagaev@avroid.tech> Reviewed-on: https://git.avroid.tech/DevOps/jenkins-shared-lib/pulls/49 Reviewed-by: Stanislav Gabenov <stanislav.gabenov@avroid.team> Reviewed-by: Denis Patrakeev <denis.patrakeev@avroid.team> Co-authored-by: Rustam Tagaev <rustam.tagaev@avroid.team> Co-committed-by: Rustam Tagaev <rustam.tagaev@avroid.team>
This commit is contained in:
committed by
Denis Patrakeev
parent
b2e5b5e12f
commit
79a8b725ce
@@ -31,4 +31,13 @@ class Jenkins implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current username who run build
|
||||||
|
* @param script Script - jenkins context
|
||||||
|
* @return String - username
|
||||||
|
*/
|
||||||
|
static String GetCurrentBuildUser(Map args = [:]){
|
||||||
|
return args.script.currentBuild.getBuildCauses()[0].userId
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,4 +159,71 @@ class PodTemplates implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void helm(imageVersion='3.16.3', body) {
|
||||||
|
this.script.podTemplate(
|
||||||
|
serviceAccount: 'jenkins-deploy',
|
||||||
|
containers: [
|
||||||
|
this.script.containerTemplate(
|
||||||
|
alwaysPullImage: true,
|
||||||
|
name: 'helm',
|
||||||
|
image: "${registry}/docker-hub-proxy/alpine/helm:${imageVersion}",
|
||||||
|
envVars: [
|
||||||
|
this.script.containerEnvVar(key: 'HOME', value: '/home/jenkins'),
|
||||||
|
],
|
||||||
|
ttyEnabled: true,
|
||||||
|
command: "cat",
|
||||||
|
resourceRequestCpu: '100m',
|
||||||
|
resourceLimitCpu: '100m',
|
||||||
|
resourceRequestMemory: '256Mi',
|
||||||
|
resourceLimitMemory: '256Mi',
|
||||||
|
workingDir: '/jenkins',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
instanceCap: 1,
|
||||||
|
showRawYaml: false,
|
||||||
|
volumes: [
|
||||||
|
this.script.emptyDirVolume(memory: false, mountPath: '/tmp'),
|
||||||
|
],
|
||||||
|
workspaceVolume: this.script.emptyDirWorkspaceVolume(false),
|
||||||
|
)
|
||||||
|
|
||||||
|
{
|
||||||
|
body.call()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void kubectl(imageVersion='1.31.3', body) {
|
||||||
|
this.script.podTemplate(
|
||||||
|
serviceAccount: 'jenkins-deploy',
|
||||||
|
runAsUser: "0",
|
||||||
|
containers: [
|
||||||
|
this.script.containerTemplate(
|
||||||
|
alwaysPullImage: true,
|
||||||
|
name: 'kubectl',
|
||||||
|
image: "${registry}/docker-hub-proxy/bitnami/kubectl:${imageVersion}",
|
||||||
|
envVars: [
|
||||||
|
this.script.containerEnvVar(key: 'HOME', value: '/home/jenkins'),
|
||||||
|
],
|
||||||
|
ttyEnabled: true,
|
||||||
|
command: "cat",
|
||||||
|
resourceRequestCpu: '100m',
|
||||||
|
resourceLimitCpu: '100m',
|
||||||
|
resourceRequestMemory: '256Mi',
|
||||||
|
resourceLimitMemory: '256Mi',
|
||||||
|
workingDir: '/jenkins',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
instanceCap: 1,
|
||||||
|
showRawYaml: false,
|
||||||
|
volumes: [
|
||||||
|
this.script.emptyDirVolume(memory: false, mountPath: '/tmp'),
|
||||||
|
],
|
||||||
|
workspaceVolume: this.script.emptyDirWorkspaceVolume(false),
|
||||||
|
)
|
||||||
|
|
||||||
|
{
|
||||||
|
body.call()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user