mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-30 05:59:39 +02:00
Merge pull request #917 from SAP/fix-non-serializable
Exchange non serializable template engine with GStringTemplateEngine
This commit is contained in:
commit
f92bd31114
@ -2,7 +2,7 @@ package com.sap.piper
|
||||
|
||||
import com.cloudbees.groovy.cps.NonCPS
|
||||
import com.sap.piper.analytics.Telemetry
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.text.GStringTemplateEngine
|
||||
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.security.MessageDigest
|
||||
@ -109,7 +109,7 @@ void pushToSWA(Map parameters, Map config) {
|
||||
|
||||
@NonCPS
|
||||
static String fillTemplate(String templateText, Map binding) {
|
||||
def engine = new SimpleTemplateEngine()
|
||||
def engine = new GStringTemplateEngine()
|
||||
String result = engine.createTemplate(templateText).make(binding)
|
||||
return result
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import com.sap.piper.Utils
|
||||
import com.sap.piper.versioning.ArtifactVersioning
|
||||
|
||||
import groovy.transform.Field
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.text.GStringTemplateEngine
|
||||
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@Field Map CONFIG_KEY_COMPATIBILITY = [gitSshKeyCredentialsId: 'gitCredentialsId']
|
||||
@ -144,7 +144,7 @@ void call(Map parameters = [:], Closure body = null) {
|
||||
newVersion = currentVersion
|
||||
} else {
|
||||
def binding = [version: currentVersion, timestamp: config.timestamp, commitId: config.gitCommitId]
|
||||
newVersion = new SimpleTemplateEngine().createTemplate(config.versioningTemplate).make(binding).toString()
|
||||
newVersion = new GStringTemplateEngine().createTemplate(config.versioningTemplate).make(binding).toString()
|
||||
}
|
||||
|
||||
artifactVersioning.setVersion(newVersion)
|
||||
|
@ -5,7 +5,7 @@ import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.GitUtils
|
||||
import com.sap.piper.Utils
|
||||
import com.sap.piper.analytics.InfluxData
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.text.GStringTemplateEngine
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@ -82,7 +82,7 @@ void call(Map parameters = [:]) {
|
||||
//resolve commonPipelineEnvironment references in envVars
|
||||
config.envVarList = []
|
||||
config.envVars.each {e ->
|
||||
def envValue = SimpleTemplateEngine.newInstance().createTemplate(e.getValue()).make(commonPipelineEnvironment: script.commonPipelineEnvironment).toString()
|
||||
def envValue = GStringTemplateEngine.newInstance().createTemplate(e.getValue()).make(commonPipelineEnvironment: script.commonPipelineEnvironment).toString()
|
||||
config.envVarList.add("${e.getKey()}=${envValue}")
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ import com.sap.piper.GenerateDocumentation
|
||||
import com.sap.piper.Utils
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.text.GStringTemplateEngine
|
||||
import groovy.transform.Field
|
||||
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
@ -5,7 +5,7 @@ import com.sap.piper.Utils
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.GitUtils
|
||||
import com.sap.piper.analytics.InfluxData
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.text.GStringTemplateEngine
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
|
@ -5,7 +5,7 @@ import com.sap.piper.GenerateDocumentation
|
||||
import com.sap.piper.GitUtils
|
||||
import com.sap.piper.Utils
|
||||
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.text.GStringTemplateEngine
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
|
@ -3,7 +3,7 @@ import static com.sap.piper.Prerequisites.checkScript
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.GenerateDocumentation
|
||||
import com.sap.piper.Utils
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.text.GStringTemplateEngine
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@ -111,7 +111,7 @@ void call(Map parameters = [:]) {
|
||||
subject += ' is back to normal'
|
||||
}
|
||||
if(mailTemplate){
|
||||
def mailContent = SimpleTemplateEngine.newInstance().createTemplate(libraryResource(mailTemplate)).make([env: env, log: log]).toString()
|
||||
def mailContent = GStringTemplateEngine.newInstance().createTemplate(libraryResource(mailTemplate)).make([env: env, log: log]).toString()
|
||||
def recipientList = ''
|
||||
if(config.notifyCulprits){
|
||||
if (!config.gitUrl) {
|
||||
|
@ -4,7 +4,7 @@ import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.GenerateDocumentation
|
||||
import com.sap.piper.GitUtils
|
||||
import com.sap.piper.Utils
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.text.GStringTemplateEngine
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@ -109,7 +109,7 @@ void call(Map parameters = [:]) {
|
||||
for(String collection : collectionList){
|
||||
def collectionDisplayName = collection.toString().replace(File.separatorChar,(char)'_').tokenize('.').first()
|
||||
// resolve templates
|
||||
def command = SimpleTemplateEngine.newInstance()
|
||||
def command = GStringTemplateEngine.newInstance()
|
||||
.createTemplate(config.newmanRunCommand)
|
||||
.make([
|
||||
config: config.plus([newmanCollection: collection]),
|
||||
|
@ -6,7 +6,7 @@ import com.sap.piper.GitUtils
|
||||
import com.sap.piper.Utils
|
||||
import com.sap.piper.k8s.ContainerMap
|
||||
import groovy.transform.Field
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.text.GStringTemplateEngine
|
||||
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
|
||||
|
@ -4,7 +4,7 @@ import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.GenerateDocumentation
|
||||
import com.sap.piper.Utils
|
||||
import groovy.transform.Field
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.text.GStringTemplateEngine
|
||||
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
|
||||
@ -65,13 +65,13 @@ void call(Map parameters = [:]) {
|
||||
|
||||
def buildStatus = script.currentBuild.result
|
||||
// resolve templates
|
||||
config.color = SimpleTemplateEngine.newInstance().createTemplate(config.color).make([buildStatus: buildStatus]).toString()
|
||||
config.color = GStringTemplateEngine.newInstance().createTemplate(config.color).make([buildStatus: buildStatus]).toString()
|
||||
if (!config?.message){
|
||||
if (!buildStatus) {
|
||||
echo "[${STEP_NAME}] currentBuild.result is not set. Skipping Slack notification"
|
||||
return
|
||||
}
|
||||
config.message = SimpleTemplateEngine.newInstance().createTemplate(config.defaultMessage).make([buildStatus: buildStatus, env: env]).toString()
|
||||
config.message = GStringTemplateEngine.newInstance().createTemplate(config.defaultMessage).make([buildStatus: buildStatus, env: env]).toString()
|
||||
}
|
||||
Map options = [:]
|
||||
if(config.credentialsId)
|
||||
|
@ -5,7 +5,7 @@ import com.sap.piper.Utils
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import groovy.transform.Field
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.text.GStringTemplateEngine
|
||||
|
||||
import java.nio.charset.StandardCharsets
|
||||
|
||||
|
@ -3,7 +3,7 @@ import com.sap.piper.GenerateDocumentation
|
||||
import com.sap.piper.GitUtils
|
||||
import com.sap.piper.Utils
|
||||
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.text.GStringTemplateEngine
|
||||
import groovy.transform.Field
|
||||
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
@ -107,8 +107,8 @@ void call(Map parameters = [:]) {
|
||||
], config)
|
||||
|
||||
config.stashContent = config.testRepository ? [GitUtils.handleTestRepository(this, config)] : utils.unstashAll(config.stashContent)
|
||||
config.installCommand = SimpleTemplateEngine.newInstance().createTemplate(config.installCommand).make([config: config]).toString()
|
||||
config.runCommand = SimpleTemplateEngine.newInstance().createTemplate(config.runCommand).make([config: config]).toString()
|
||||
config.installCommand = GStringTemplateEngine.newInstance().createTemplate(config.installCommand).make([config: config]).toString()
|
||||
config.runCommand = GStringTemplateEngine.newInstance().createTemplate(config.runCommand).make([config: config]).toString()
|
||||
config.dockerEnvVars.TARGET_SERVER_URL = config.dockerEnvVars.TARGET_SERVER_URL ?: config.testServerUrl
|
||||
|
||||
seleniumExecuteTests(
|
||||
|
@ -9,7 +9,7 @@ import com.sap.piper.WhitesourceConfigurationHelper
|
||||
import com.sap.piper.mta.MtaMultiplexer
|
||||
import groovy.text.GStringTemplateEngine
|
||||
import groovy.transform.Field
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.text.GStringTemplateEngine
|
||||
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
@ -588,7 +588,7 @@ def getReportHtml(config, vulnerabilityList, numSevereVulns) {
|
||||
}
|
||||
}
|
||||
|
||||
return SimpleTemplateEngine.newInstance().createTemplate(libraryResource('com.sap.piper/templates/whitesourceVulnerabilities.html')).make(
|
||||
return GStringTemplateEngine.newInstance().createTemplate(libraryResource('com.sap.piper/templates/whitesourceVulnerabilities.html')).make(
|
||||
[
|
||||
now : now,
|
||||
reportTitle : config.whitesource.vulnerabilityReportTitle,
|
||||
|
Loading…
x
Reference in New Issue
Block a user