2019-11-21 17:34:22 +02:00
|
|
|
import com.sap.piper.PiperGoUtils
|
2018-10-25 16:56:09 +02:00
|
|
|
import com.sap.piper.Utils
|
|
|
|
import groovy.transform.Field
|
|
|
|
|
2019-11-21 17:34:22 +02:00
|
|
|
import static com.sap.piper.Prerequisites.checkScript
|
2019-03-29 13:46:25 +02:00
|
|
|
|
2019-11-21 17:34:22 +02:00
|
|
|
@Field String STEP_NAME = getClass().getName()
|
|
|
|
@Field String METADATA_FILE = 'metadata/githubrelease.yaml'
|
2019-03-29 13:46:25 +02:00
|
|
|
|
2019-11-21 17:34:22 +02:00
|
|
|
//Metadata maintained in file project://resources/metadata/githubrelease.yaml
|
2018-10-25 16:56:09 +02:00
|
|
|
|
|
|
|
void call(Map parameters = [:]) {
|
|
|
|
handlePipelineStepErrors(stepName: STEP_NAME, stepParameters: parameters) {
|
|
|
|
|
2019-11-21 17:34:22 +02:00
|
|
|
def script = checkScript(this, parameters) ?: this
|
2018-10-25 16:56:09 +02:00
|
|
|
|
2019-11-21 17:34:22 +02:00
|
|
|
Map config
|
|
|
|
def utils = parameters.juStabUtils ?: new Utils()
|
|
|
|
parameters.juStabUtils = null
|
2018-10-25 16:56:09 +02:00
|
|
|
|
2019-11-21 17:34:22 +02:00
|
|
|
// telemetry reporting
|
|
|
|
utils.pushToSWA([step: STEP_NAME], config)
|
2018-10-25 16:56:09 +02:00
|
|
|
|
2019-11-21 17:34:22 +02:00
|
|
|
new PiperGoUtils(this, utils).unstashPiperBin()
|
|
|
|
utils.unstash('pipelineConfigAndTests')
|
2020-01-15 13:16:25 +02:00
|
|
|
script.commonPipelineEnvironment.writeToDisk(script)
|
2018-10-25 16:56:09 +02:00
|
|
|
|
2019-11-21 17:34:22 +02:00
|
|
|
writeFile(file: METADATA_FILE, text: libraryResource(METADATA_FILE))
|
2018-10-25 16:56:09 +02:00
|
|
|
|
2019-11-21 17:34:22 +02:00
|
|
|
withEnv([
|
|
|
|
"PIPER_parametersJSON=${groovy.json.JsonOutput.toJson(parameters)}",
|
|
|
|
]) {
|
|
|
|
// get context configuration
|
2019-11-25 09:58:16 +02:00
|
|
|
config = readJSON (text: sh(returnStdout: true, script: "./piper getConfig --contextConfig --stepMetadata '${METADATA_FILE}'"))
|
2018-10-25 16:56:09 +02:00
|
|
|
|
2019-11-21 17:34:22 +02:00
|
|
|
// execute step
|
|
|
|
withCredentials([string(credentialsId: config.githubTokenCredentialsId, variable: 'TOKEN')]) {
|
|
|
|
sh "./piper githubPublishRelease --token ${TOKEN}"
|
2018-10-25 16:56:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|