2025-01-17 08:25:04 +00:00
|
|
|
#!groovy
|
|
|
|
|
|
|
|
|
|
import com.freeleaps.devops.EnvironmentVars
|
|
|
|
|
import com.freeleaps.devops.SourceFetcher
|
2025-01-21 09:01:31 +00:00
|
|
|
import com.freeleaps.devops.DependenciesResolver
|
|
|
|
|
import com.freeleaps.devops.enums.DependenciesManager
|
2025-01-17 08:25:04 +00:00
|
|
|
|
|
|
|
|
def call(Map configurations) {
|
|
|
|
|
def environmentVars = new EnvironmentVars(this)
|
|
|
|
|
|
|
|
|
|
pipeline {
|
|
|
|
|
agent any
|
|
|
|
|
options {
|
|
|
|
|
buildDiscarder(logRotator(numToKeepStr: '25'))
|
|
|
|
|
timeout(time: 30, unit: 'MINUTES')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stages {
|
|
|
|
|
|
|
|
|
|
stage("Source Codes Checkout") {
|
|
|
|
|
steps {
|
2025-01-20 02:12:26 +00:00
|
|
|
script {
|
2025-01-17 09:16:56 +00:00
|
|
|
def sourceFetcher = new SourceFetcher(this)
|
2025-01-17 08:25:04 +00:00
|
|
|
sourceFetcher.fetch(configurations)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage("Prepared Environment Variables") {
|
|
|
|
|
steps {
|
|
|
|
|
script {
|
|
|
|
|
environmentVars.injectVars(configurations)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage("Commit Linting If Enabled") {
|
|
|
|
|
steps {
|
2025-01-20 02:12:26 +00:00
|
|
|
script {
|
2025-01-21 09:01:31 +00:00
|
|
|
def enabled = configurations.COMMIT_MESSAGE_LINT_ENABLED
|
2025-01-17 08:25:04 +00:00
|
|
|
|
2025-01-21 09:01:31 +00:00
|
|
|
if (enabled != null && enabled == "true") {
|
2025-01-17 08:25:04 +00:00
|
|
|
print("Commit Linting is enabled")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-21 09:01:31 +00:00
|
|
|
stage("Build Agent Setup") {
|
|
|
|
|
steps {
|
|
|
|
|
script {
|
|
|
|
|
def buildAgentImage = configurations.BUILD_AGENT_IMAGE
|
|
|
|
|
if (buildAgentImage != null && !buildAgentImage.isEmpty()) {
|
|
|
|
|
echo "Not set BUILD_AGENT_IMAGE, using default build agent image"
|
|
|
|
|
|
|
|
|
|
def language = env.SERVICE_LANG
|
|
|
|
|
switch(language) {
|
|
|
|
|
case PYTHON:
|
|
|
|
|
buildAgentImage = "python:3.10-slim-buster"
|
|
|
|
|
case NODE:
|
|
|
|
|
buildAgentImage = "node:lts-alpine"
|
|
|
|
|
default:
|
|
|
|
|
error("Unknown service language")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
env.BUILD_AGENT_IMAGE = buildAgentImage
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage("Dependencies Resolving") {
|
|
|
|
|
agent {
|
|
|
|
|
docker {
|
|
|
|
|
image env.BUILD_AGENT_IMAGE
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
steps {
|
|
|
|
|
script {
|
|
|
|
|
def language = env.SERVICE_LANG
|
|
|
|
|
|
|
|
|
|
def depManager = DependenciesManager.parse(configurations.DEPENDENCIES_MANAGER)
|
|
|
|
|
if (depManager == DependenciesManager.UNKNOWN) {
|
|
|
|
|
error("Unknown dependencies manager")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def dependenciesResolver = new DependenciesResolver(this, language)
|
|
|
|
|
dependenciesResolver.useManager(depManager)
|
|
|
|
|
|
|
|
|
|
if (configurations.BUILD_CACHE_ENABLED == "true") {
|
|
|
|
|
dependenciesResolver.enableCachingSupport()
|
|
|
|
|
} else {
|
|
|
|
|
dependenciesResolver.disableCachingSupport()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dependenciesResolver.resolve(configurations)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-17 08:25:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|