Files
devops-lib-gcp/vars/buildDockerGroovyGke.groovy
T
Mukul Sharma 83cbf62ec6 Rename com.meesho/org.meesho namespace to com.homelab/org.homelab
Renames src/com/meesho -> src/com/homelab, resources/com/meesho ->
resources/com/homelab, resources/org/meesho -> resources/org/homelab
(via git mv, preserving history), and sweeps every remaining
occurrence of "meesho" (any casing) out of package declarations,
imports, libraryResource() paths, and comments across the whole repo.

Also drops the per-user allowlist in vars/eksCICD.groovy, which
hardcoded real former-colleagues' emails and doesn't apply to a
single-person homelab — that branch is now permanently skipped rather
than deleted outright, to avoid hand-editing the escape-sequence-heavy
echo blocks it guards (eksCICD.groovy itself is unused legacy code,
not called by homelabPipeline.groovy).

Does not touch the ~114 files that were already missing from the
working tree but still tracked in the prior commit — that's unrelated
pre-existing state, left as-is.
2026-09-02 01:24:37 +05:30

165 lines
6.4 KiB
Groovy

package com.homelab.stages
def run(Map config){
stage('Build docker image'){
container('dockerpush') {
def env = "dev" //write if condition according to branch if branch is dev/staging or any other branch then master it will be dev if master prod
def ecrImagePod = config.ecrImagePod
def repo_name = config.repo_name
def dockerBuildVersion = config.dockerBuildVersion ?: ""
def version = getVersion()
def artifactId = getArtifactId()
def modules = getModules()
def excludedModules = config.excludedModules ?: []
j = 0
for (module in modules){
if (excludedModules.contains(module)){
echo "===== NOT Building container for Module - ${module} ====="
}else {
def dockerfileRef = getDockerfile("${dockerBuildVersion}","${repo_name}","${version}","${module}","NO")
j+=1
sh """
echo "===== ${j}. Creating Container for Module - ${module} ======"
if [ -f ${module}/target/*.jar ]
then
echo "docker build -t ${ecrImagePod}/${repo_name}/${module} ${dockerfileRef}; rm -f Dockerfile-${module}"
else
echo "No jar file found."
exit 1
fi
"""
}
}
}
}
}
def getCommitid(){
return sh(returnStdout: true, script: 'git log -1 --format=%h').trim()
}
def registry(String buildenv){
switch(env) {
case "prod":
return 'asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622/prod/'
break;
case "dev":
return 'asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622/dev/'
break;
default:
return 'asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622'
}
}
def getVersion(){
// if (fileExists("pom.xml")) {
// return sh(returnStdout: true, script: 'xq -r .project.version pom.xml').trim()
// }else if (fileExists("package.json")) {
// return sh(returnStdout: true, script: 'jq -r .version package.json').trim()
// }
return "2.0"
}
def getModules(){
// if (fileExists("pom.xml")) {
// modules = sh(returnStdout: true, script: 'xq -r .project.modules.module[] pom.xml 2>/dev/null || xq -r .project.modules.module pom.xml 2>/dev/null || echo empty').trim()
// if (modules == 'empty' || modules == 'null') {
// return null
// }
// modules = modules.split("\n")
// return modules
// }
// else {
// return null
// }
return ["server"]
}
def getArtifactId(){
// if (fileExists("pom.xml")) {
// return sh(returnStdout: true, script: 'xq -r .project.artifactId pom.xml').trim()
// } else if (fileExists("package.json")) {
// return sh(returnStdout: true, script: 'jq -r .name package.json').trim()
// }
return "external-payment-gateway"
}
def getTag(){
def buildenv = "${env.BUILD_ENV}"
echo "========get version========"
def version = getVersion()
echo "========commitID========"
def commitID = getCommitid()
echo "========tag========"
def tag = "v${version}-${commitID}"
return ${tag}
}
def release(Map config){
stage('Push docker image'){
def repo_name = config.repo_name
def branch_name = "${env.BRANCH_NAME}"
def ecrImagePod = config.ecrImagePod
def bu = config.BU
def buildenv = "${env.BUILD_ENV}"
echo "========registry========"
def registry = registry("${buildenv}")
echo "========get version========"
def version = getVersion()
echo "========commitID========"
def commitID = getCommitid()
echo "========tag========"
echo "registry is ${registry}"
def tag = "v${version}-${commitID}"
echo "${registry}"
echo "tag is ${tag}"
def artifactId = getArtifactId()
def modules = getModules()
def excludedModules = config.excludedModules ?: []
log.info("########################### Pushing Docker Images ###########################")
if (modules == null){
echo "docker tag ${ecrImagePod}/${repo_name} ${registry}/${bu}/${ecrImagePod}/${repo_name}:${tag}"
echo "gcloud auth configure-docker asia-southeast1-docker.pkg.dev --quiet"
echo "docker push ${registry}/${bu}/${ecrImagePod}/${repo_name}:${tag}"
}else {
j = 0
for (module in modules){
if (excludedModules.contains(module)){
echo "===== NOT Pushing container for Module - ${common} ====="
}else {
j+=1
sh """
echo "===== ${j}. Pushing Container for Module - ${module} ======"
echo "docker tag ${ecrImagePod}/${repo_name}/${module} ${registry}/${bu}/${ecrImagePod}/${repo_name}/${module}:${tag}"
echo "gcloud auth configure-docker asia-southeast1-docker.pkg.dev --quiet"
echo "docker push ${registry}/${bu}/${ecrImagePod}/${repo_name}/${module}:${tag}"
"""
}
}
}
}
}
def getDockerfile(String dockerBuildVersion, String repo_name, String version, String module, String doBuild) {
if (dockerBuildVersion) {
if(dockerBuildVersion == "maven-3.3-jdk-8"){
def scriptcontents = libraryResource "org/homelab/templates/${dockerBuildVersion}.sh"
writeFile file: "${dockerBuildVersion}.sh", text: scriptcontents
sh "chmod a+x ./${dockerBuildVersion}.sh;./${dockerBuildVersion}.sh ${module} ${version} ${doBuild} ${repo_name}"
return "-f Dockerfile-${module} ."
}else if(dockerBuildVersion == "node-12.22"){
def scriptcontents = libraryResource "org/homelab/templates/${dockerBuildVersion}.sh"
writeFile file: "${dockerBuildVersion}.sh", text: scriptcontents
sh "chmod a+x ./${dockerBuildVersion}.sh;./${dockerBuildVersion}.sh ${module}"
return "-f Dockerfile-${module} ."
}
} else {
return "-f Dockerfile ."
}
}