mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-20 05:19:40 +02:00
Swich for switching off cm integration
This commit is contained in:
parent
87aafb3cde
commit
2d779233cc
@ -11,6 +11,7 @@ import com.sap.piper.cm.ChangeManagementException
|
||||
import hudson.AbortException
|
||||
import util.BasePiperTest
|
||||
import util.JenkinsCredentialsRule
|
||||
import util.JenkinsLoggingRule
|
||||
import util.JenkinsReadYamlRule
|
||||
import util.JenkinsStepRule
|
||||
import util.Rules
|
||||
@ -19,6 +20,7 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
|
||||
|
||||
private ExpectedException thrown = ExpectedException.none()
|
||||
private JenkinsStepRule jsr = new JenkinsStepRule(this)
|
||||
private JenkinsLoggingRule jlr = new JenkinsLoggingRule(this)
|
||||
|
||||
@Rule
|
||||
public RuleChain ruleChain = Rules
|
||||
@ -26,6 +28,7 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
|
||||
.around(new JenkinsReadYamlRule(this))
|
||||
.around(thrown)
|
||||
.around(jsr)
|
||||
.around(jlr)
|
||||
.around(new JenkinsCredentialsRule(this)
|
||||
.withCredentials('CM', 'anonymous', '********'))
|
||||
|
||||
@ -150,6 +153,16 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
|
||||
changeManagement: [endpoint: 'https://example.org/cm'])
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cmIntegrationSwichtedOffTest() {
|
||||
|
||||
jlr.expect('[INFO] Change management integration intentionally switched off.')
|
||||
|
||||
jsr.step.checkChangeInDevelopment(
|
||||
changeManagement: [type: 'NONE'])
|
||||
|
||||
}
|
||||
|
||||
private ChangeManagement getChangeManagementUtils(boolean inDevelopment, String changeDocumentId = '001') {
|
||||
|
||||
return new ChangeManagement(nullScript, null) {
|
||||
|
@ -186,4 +186,12 @@ public class TransportRequestCreateTest extends BasePiperTest {
|
||||
assert jlr.log.contains("[INFO] Transport Request '001' has been successfully created.")
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cmIntegrationSwichtedOffTest() {
|
||||
|
||||
jlr.expect('[INFO] Change management integration intentionally switched off.')
|
||||
|
||||
jsr.step.call(
|
||||
changeManagement: [type: 'NONE'])
|
||||
}
|
||||
}
|
||||
|
@ -138,4 +138,13 @@ public class TransportRequestReleaseTest extends BasePiperTest {
|
||||
credentialsId: 'CM',
|
||||
clientOpts: '']
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cmIntegrationSwichtedOffTest() {
|
||||
|
||||
jlr.expect('[INFO] Change management integration intentionally switched off.')
|
||||
|
||||
jsr.step.call(
|
||||
changeManagement: [type: 'NONE'])
|
||||
}
|
||||
}
|
||||
|
@ -367,4 +367,13 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cmIntegrationSwichtedOffTest() {
|
||||
|
||||
jlr.expect('[INFO] Change management integration intentionally switched off.')
|
||||
|
||||
jsr.step.call(
|
||||
changeManagement: [type: 'NONE'])
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import hudson.AbortException
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.ConfigurationMerger
|
||||
import com.sap.piper.cm.BackendType
|
||||
import com.sap.piper.cm.ChangeManagement
|
||||
import com.sap.piper.cm.ChangeManagementException
|
||||
|
||||
@ -35,6 +36,30 @@ def call(parameters = [:]) {
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
|
||||
.mixin(parameters, parameterKeys)
|
||||
|
||||
Map configuration = configHelper.use()
|
||||
|
||||
BackendType backendType
|
||||
|
||||
try {
|
||||
backendType = configuration.changeManagement.type as BackendType
|
||||
} catch(IllegalArgumentException e) {
|
||||
error "Invalid backend type: '${configuration.changeManagement.type}'. " +
|
||||
"Valid values: [${BackendType.values().join(', ')}]. " +
|
||||
"Configuration: 'changeManagement/type'."
|
||||
}
|
||||
|
||||
if (backendType == BackendType.NONE) {
|
||||
echo "[INFO] Change management integration intentionally switched off. " +
|
||||
"In order to enable it provide 'changeManagement/type with one of " +
|
||||
"[${BackendType.values().minus(BackendType.NONE).join(', ')}] and maintain " +
|
||||
"maintain other required properties like 'endpoint', 'credentialsId'."
|
||||
return
|
||||
}
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
|
||||
configHelper
|
||||
// for the following parameters we expect defaults
|
||||
.withMandatoryProperty('changeManagement/changeDocumentLabel')
|
||||
.withMandatoryProperty('changeManagement/clientOpts')
|
||||
@ -47,10 +72,6 @@ def call(parameters = [:]) {
|
||||
.withMandatoryProperty('changeManagement/endpoint')
|
||||
|
||||
|
||||
Map configuration = configHelper.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
|
||||
def changeId = configuration.changeDocumentId
|
||||
|
||||
if(changeId?.trim()) {
|
||||
|
@ -39,17 +39,10 @@ def call(parameters = [:]) {
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
|
||||
.mixin(parameters, parameterKeys)
|
||||
.withMandatoryProperty('changeManagement/clientOpts')
|
||||
.withMandatoryProperty('changeManagement/credentialsId')
|
||||
.withMandatoryProperty('changeManagement/endpoint')
|
||||
.withMandatoryProperty('changeManagement/git/from')
|
||||
.withMandatoryProperty('changeManagement/git/to')
|
||||
.withMandatoryProperty('changeManagement/git/format')
|
||||
|
||||
|
||||
Map configuration = configHelper.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
|
||||
BackendType backendType
|
||||
|
||||
try {
|
||||
@ -60,9 +53,26 @@ def call(parameters = [:]) {
|
||||
"Configuration: 'changeManagement/type'."
|
||||
}
|
||||
|
||||
configHelper.withMandatoryProperty('transportType', null, { backendType == BackendType.CTS})
|
||||
configHelper.withMandatoryProperty('targetSystem', null, { backendType == BackendType.CTS})
|
||||
configHelper.withMandatoryProperty('description', null, { backendType == BackendType.CTS})
|
||||
if (backendType == BackendType.NONE) {
|
||||
echo "[INFO] Change management integration intentionally switched off. " +
|
||||
"In order to enable it provide 'changeManagement/type with one of " +
|
||||
"[${BackendType.values().minus(BackendType.NONE).join(', ')}] and maintain " +
|
||||
"maintain other required properties like 'endpoint', 'credentialsId'."
|
||||
return
|
||||
}
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
|
||||
configHelper
|
||||
.withMandatoryProperty('changeManagement/clientOpts')
|
||||
.withMandatoryProperty('changeManagement/credentialsId')
|
||||
.withMandatoryProperty('changeManagement/endpoint')
|
||||
.withMandatoryProperty('changeManagement/git/from')
|
||||
.withMandatoryProperty('changeManagement/git/to')
|
||||
.withMandatoryProperty('changeManagement/git/format')
|
||||
.withMandatoryProperty('transportType', null, { backendType == BackendType.CTS})
|
||||
.withMandatoryProperty('targetSystem', null, { backendType == BackendType.CTS})
|
||||
.withMandatoryProperty('description', null, { backendType == BackendType.CTS})
|
||||
|
||||
def changeDocumentId = null
|
||||
|
||||
|
@ -38,17 +38,10 @@ def call(parameters = [:]) {
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
|
||||
.mixin(parameters, parameterKeys)
|
||||
.withMandatoryProperty('changeManagement/clientOpts')
|
||||
.withMandatoryProperty('changeManagement/credentialsId')
|
||||
.withMandatoryProperty('changeManagement/endpoint')
|
||||
.withMandatoryProperty('changeManagement/git/to')
|
||||
.withMandatoryProperty('changeManagement/git/from')
|
||||
.withMandatoryProperty('changeManagement/git/format')
|
||||
|
||||
|
||||
Map configuration = configHelper.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
|
||||
BackendType backendType
|
||||
|
||||
try {
|
||||
@ -59,6 +52,24 @@ def call(parameters = [:]) {
|
||||
"Configuration: 'changeManagement/type'."
|
||||
}
|
||||
|
||||
if (backendType == BackendType.NONE) {
|
||||
echo "[INFO] Change management integration intentionally switched off. " +
|
||||
"In order to enable it provide 'changeManagement/type with one of " +
|
||||
"[${BackendType.values().minus(BackendType.NONE).join(', ')}] and maintain " +
|
||||
"maintain other required properties like 'endpoint', 'credentialsId'."
|
||||
return
|
||||
}
|
||||
|
||||
configHelper
|
||||
.withMandatoryProperty('changeManagement/clientOpts')
|
||||
.withMandatoryProperty('changeManagement/credentialsId')
|
||||
.withMandatoryProperty('changeManagement/endpoint')
|
||||
.withMandatoryProperty('changeManagement/git/to')
|
||||
.withMandatoryProperty('changeManagement/git/from')
|
||||
.withMandatoryProperty('changeManagement/git/format')
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
|
||||
def transportRequestId = configuration.transportRequestId
|
||||
|
||||
if(transportRequestId?.trim()) {
|
||||
|
@ -40,20 +40,9 @@ def call(parameters = [:]) {
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
|
||||
.mixin(parameters, parameterKeys)
|
||||
.addIfEmpty('filePath', script.commonPipelineEnvironment.getMtarFilePath())
|
||||
.withMandatoryProperty('changeManagement/changeDocumentLabel')
|
||||
.withMandatoryProperty('changeManagement/clientOpts')
|
||||
.withMandatoryProperty('changeManagement/credentialsId')
|
||||
.withMandatoryProperty('changeManagement/endpoint')
|
||||
.withMandatoryProperty('changeManagement/type')
|
||||
.withMandatoryProperty('changeManagement/git/from')
|
||||
.withMandatoryProperty('changeManagement/git/to')
|
||||
.withMandatoryProperty('changeManagement/git/format')
|
||||
.withMandatoryProperty('filePath')
|
||||
|
||||
Map configuration = configHelper.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME, stepParam1: configuration.changeManagement.type], configuration)
|
||||
|
||||
BackendType backendType
|
||||
|
||||
try {
|
||||
@ -64,6 +53,27 @@ def call(parameters = [:]) {
|
||||
"Configuration: 'changeManagement/type'."
|
||||
}
|
||||
|
||||
if (backendType == BackendType.NONE) {
|
||||
echo "[INFO] Change management integration intentionally switched off. " +
|
||||
"In order to enable it provide 'changeManagement/type with one of " +
|
||||
"[${BackendType.values().minus(BackendType.NONE).join(', ')}] and maintain " +
|
||||
"maintain other required properties like 'endpoint', 'credentialsId'."
|
||||
return
|
||||
}
|
||||
|
||||
configHelper
|
||||
.withMandatoryProperty('changeManagement/changeDocumentLabel')
|
||||
.withMandatoryProperty('changeManagement/clientOpts')
|
||||
.withMandatoryProperty('changeManagement/credentialsId')
|
||||
.withMandatoryProperty('changeManagement/endpoint')
|
||||
.withMandatoryProperty('changeManagement/type')
|
||||
.withMandatoryProperty('changeManagement/git/from')
|
||||
.withMandatoryProperty('changeManagement/git/to')
|
||||
.withMandatoryProperty('changeManagement/git/format')
|
||||
.withMandatoryProperty('filePath')
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME, stepParam1: configuration.changeManagement.type], configuration)
|
||||
|
||||
def changeDocumentId = null
|
||||
|
||||
if(backendType == BackendType.SOLMAN) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user