chore(git): codes staging
Signed-off-by: 孙振宇 <>
This commit is contained in:
parent
3af74b7931
commit
ed959561db
@ -0,0 +1,38 @@
|
||||
package com.freeleaps.devops
|
||||
|
||||
import com.freeleaps.devops.enums.ServiceLanguage
|
||||
|
||||
class EnvironmentVars {
|
||||
def steps
|
||||
|
||||
EnvironmentVars(steps) {
|
||||
this.steps = steps
|
||||
}
|
||||
|
||||
def injectVars(Map configurations) {
|
||||
steps.env.SERVICE_NAME = "${configurations.SERVICE_NAME}"
|
||||
if (steps.env.SERVICE_NAME == null || steps.env.SERVICE_NAME.isEmpty()) {
|
||||
steps.error("SERVICE_NAME is required")
|
||||
}
|
||||
|
||||
steps.env.SERVICE_LANG = ServiceLanguage.parse("${configurations.SERVICE_LANG}")
|
||||
if (steps.env.SERVICE_LANG == ServiceLanguage.UNKNOWN) {
|
||||
steps.error("Unknown service language: ${configurations.SERVICE_LANG}")
|
||||
}
|
||||
|
||||
steps.env.SERVICE_GIT_REPO = "${configurations.SERVICE_GIT_REPO}"
|
||||
if (steps.env.SERVICE_GIT_REPO == null || steps.env.SERVICE_GIT_REPO.isEmpty()) {
|
||||
steps.error("SERVICE_GIT_REPO is required")
|
||||
}
|
||||
|
||||
steps.env.SERVICE_GIT_BRANCH = "${configurations.SERVICE_GIT_BRANCH}"
|
||||
if (steps.env.SERVICE_GIT_BRANCH == null || steps.env.SERVICE_GIT_BRANCH.isEmpty()) {
|
||||
steps.error("SERVICE_GIT_BRANCH is required")
|
||||
}
|
||||
|
||||
steps.env.ENVIRONMENT_SLUG = "${configurations.ENVIRONMENT_SLUG}"
|
||||
if (steps.env.ENVIRONMENT_SLUG == null || steps.env.ENVIRONMENT_SLUG.isEmpty()) {
|
||||
steps.error("ENVIRONMENT_SLUG is required")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.freeleaps.devops
|
||||
|
||||
class SourceFetcher {
|
||||
def steps
|
||||
|
||||
SourceFetcher(steps) {
|
||||
this.steps = steps
|
||||
}
|
||||
|
||||
def fetch(config) {
|
||||
// TODO: Implement me!
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.freeleaps.devops.enums
|
||||
|
||||
@CompileStatic
|
||||
enum ServiceLanguage {
|
||||
|
||||
PYTHON('Python'),
|
||||
NODE('Node (JS,TS)'),
|
||||
UNKNOWN('Unknown')
|
||||
|
||||
final String language
|
||||
|
||||
ServiceLanguage(String language) {
|
||||
this.language = language
|
||||
}
|
||||
|
||||
ServiceLanguage parse(String language) {
|
||||
switch (language) {
|
||||
case 'Python':
|
||||
return PYTHON
|
||||
case 'Node (JS,TS)':
|
||||
return NODE
|
||||
default:
|
||||
return Unknown
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
6
first-class-pipeline/tests/Jenkinsfile
vendored
Normal file
6
first-class-pipeline/tests/Jenkinsfile
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
#!groovy
|
||||
|
||||
library 'first-class-pipeline'
|
||||
def configurations = [:]
|
||||
|
||||
pipelineCall(configurations)
|
||||
51
first-class-pipeline/vars/pipelineCall.groovy
Normal file
51
first-class-pipeline/vars/pipelineCall.groovy
Normal file
@ -0,0 +1,51 @@
|
||||
#!groovy
|
||||
|
||||
import com.freeleaps.devops.EnvironmentVars
|
||||
import com.freeleaps.devops.SourceFetcher
|
||||
|
||||
def call(Map configurations) {
|
||||
def environmentVars = new EnvironmentVars(this)
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
options {
|
||||
buildDiscarder(logRotator(numToKeepStr: '25'))
|
||||
timeout(time: 30, unit: 'MINUTES')
|
||||
ansiColor('xterm')
|
||||
timestamps()
|
||||
}
|
||||
|
||||
stages {
|
||||
|
||||
stage("Source Codes Checkout") {
|
||||
steps {
|
||||
scripts {
|
||||
var sourceFetcher = new SourceFetcher(this)
|
||||
sourceFetcher.fetch(configurations)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage("Prepared Environment Variables") {
|
||||
steps {
|
||||
script {
|
||||
environmentVars.injectVars(configurations)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage("Commit Linting If Enabled") {
|
||||
steps {
|
||||
scripts {
|
||||
enabled = "${configurations.COMMIT_MESSAGE_LINT_ENABLED}"
|
||||
|
||||
if (enabled == "true") {
|
||||
print("Commit Linting is enabled")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user