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.
156 lines
6.1 KiB
Groovy
156 lines
6.1 KiB
Groovy
import com.homelab.stages.hotFix
|
|
import com.homelab.stages.checkOut
|
|
import com.homelab.stages.buildObjHelper
|
|
import com.homelab.stages.notify
|
|
import com.homelab.utilities.getYamlParameter
|
|
import com.homelab.utilities.constructParam
|
|
import java.time.ZonedDateTime
|
|
import java.time.format.DateTimeFormatterBuilder
|
|
|
|
def call(Map repo) {
|
|
ansiColor('xterm') {
|
|
def userId = null
|
|
|
|
try {
|
|
def cause = currentBuild.rawBuild.getCause(hudson.model.Cause.UserIdCause)
|
|
if (cause) {
|
|
userId = cause.getUserId()
|
|
}
|
|
} catch (Exception e) {
|
|
log.error("Failed to get user ID: ${e.message}")
|
|
}
|
|
|
|
// Per-user allowlist removed — it hardcoded real people's emails
|
|
// from the original org and doesn't apply to a solo homelab.
|
|
// This whole eksCICD path is unused legacy code anyway (nothing
|
|
// in homelabPipeline.groovy calls it); the branch below is now
|
|
// permanently skipped rather than deleted, to avoid hand-editing
|
|
// the escape-sequence-heavy echo blocks it guards.
|
|
if (false) {
|
|
echo "\u001B[1;31m========================================\n[ERROR] Build triggered by unauthorized user: ${userId}\n\nPlease use Ringmaster to trigger builds and deployments: https://ringmaster.homelabgcp.in/applications/cicd/home\n========================================\u001B[0m"
|
|
error("Build triggered by unauthorized user: ${userId}.")
|
|
} else if (!userId) {
|
|
echo "\u001B[1;31m========================================\n[ERROR] Could not determine the user who triggered the build\n\nThis might be a scheduled or system-triggered build.\n========================================\u001B[0m"
|
|
error("Could not determine the user who triggered the build")
|
|
} else {
|
|
echo "Starting the build....."
|
|
}
|
|
}
|
|
|
|
env.STARTTIME = getDateTime()
|
|
env.FAILURE = 'FAILURE'
|
|
echo "CLOUD_PROVIDER : ${env.CLOUD_PROVIDER}"
|
|
echo "INFRA_ENV : ${env.INFRA_ENV}"
|
|
switch (env.CLOUD_PROVIDER) {
|
|
case 'GCP':
|
|
echo 'Running on GCP'
|
|
gcpInfra(repo)
|
|
break
|
|
case 'AWS':
|
|
echo 'Running on AWS'
|
|
awsInfra(repo)
|
|
break
|
|
default:
|
|
log.error('Not running on AWS or GCP')
|
|
currentBuild.result = env.FAILURE
|
|
def msg = 'Job Failed. Error: Not running on AWS or GCP'
|
|
notify.run(msg)
|
|
}
|
|
}
|
|
|
|
def gcpInfra (Map repo) {
|
|
def isSidecarNeeded = repo.get('useSidecar', false)
|
|
def yamlName = isSidecarNeeded ? "${env.INFRA_ENV}-sidecar-pod.yaml" : "${env.INFRA_ENV}-pod.yaml"
|
|
def podyaml = "org/homelab/${yamlName}"
|
|
echo "Architecture Check: useSidecar=${isSidecarNeeded}. Loading ${podyaml}"
|
|
podTemplate(yaml: libraryResource(podyaml)) {
|
|
node(POD_LABEL) {
|
|
container('devops-tools') {
|
|
commonCICDFlow(repo)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
def awsInfra (Map repo) {
|
|
node('EKS') {
|
|
commonCICDFlow(repo)
|
|
}
|
|
}
|
|
|
|
def commonCICDFlow (Map repo) {
|
|
def constructParam = new constructParam()
|
|
def ymlObj = new getYamlParameter()
|
|
def checkObj = new checkOut()
|
|
def buildObjHelper = new buildObjHelper()
|
|
def hotFixObj = new hotFix()
|
|
def notify = new notify()
|
|
def param = [:]
|
|
def msg = 'Job Passed'
|
|
env.msg = msg
|
|
env.error_msg_to_db = ''
|
|
|
|
timestamps {
|
|
ansiColor('xterm') {
|
|
try {
|
|
env.deploymentStartTime = new Date().format('yyyy-MM-dd HH:mm:ss')
|
|
checkObj.run(repo)
|
|
param = ymlObj.getParam(repo.repo_name)
|
|
def maintainer = param.maintainer ?: 'jenkins-user'
|
|
def buildObj = buildObjHelper.run(param.build_tool)
|
|
constructParam.run(param)
|
|
param['skip_notify'] = env.skip_notify
|
|
log.info(param)
|
|
hotFixObj.run(param.repo_name)
|
|
// Pre-build hooks: user scripts declared under
|
|
// environment.<env>.hooks.pre_build in the repo's config.yaml.
|
|
// constructParam has merged the resolved env block into param,
|
|
// so param.hooks holds the current environment's hooks. A
|
|
// blocking hook failure fails the build before the docker build.
|
|
runHooks(param, 'pre_build')
|
|
buildObj.run(param)
|
|
// Post-build hooks: run after a successful build.
|
|
runHooks(param, 'post_build')
|
|
// Auto-trigger the standalone ai-blitz-jobs (coverage-only) job
|
|
// once the per-repo CI has succeeded. Internally gated on
|
|
// PR / hot-fix / toolchain / mainline-branch (see helper), and
|
|
// fire-and-forget — coverage observability must never block
|
|
// or fail this build. Repos opt out via skip_coverage_trigger
|
|
// in config.yaml.
|
|
triggerCoverageOnly(param)
|
|
}
|
|
catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {
|
|
currentBuild.result = 'ABORTED'
|
|
log.info(currentBuild.result)
|
|
env.msg = 'Job Aborted'
|
|
env.error_msg_to_db = 'Job ABORTED by the User'
|
|
}
|
|
catch (Exception e) {
|
|
if (env.msg == msg) {
|
|
log.error(e.toString())
|
|
currentBuild.result = env.FAILURE
|
|
env.msg = 'Job Failed. Error: ' + e.toString()
|
|
}
|
|
}
|
|
finally {
|
|
env.deploymentEndTime = new Date().format('yyyy-MM-dd HH:mm:ss')
|
|
notify.run(param)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@NonCPS
|
|
def getDateTime() {
|
|
// Get the current date and time in IST
|
|
def currentDateTime = ZonedDateTime.now()
|
|
// Create a formatter for the desired pattern
|
|
def formatter = new DateTimeFormatterBuilder()
|
|
.appendPattern("yyyy-MM-dd'T'HH:mm:ss")
|
|
.appendOffset('+HH:mm', '+00:00')
|
|
.toFormatter()
|
|
// Format the current date and time using the formatter
|
|
def formattedDateTime = currentDateTime.format(formatter)
|
|
return formattedDateTime
|
|
}
|