1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-30 05:59:39 +02:00

Merge pull request #372 from marcusholl/pr/neoDeployDeprecatedOldConfigFramework

neoDeploy deprecated old config framework
This commit is contained in:
Marcus Holl 2018-11-12 15:48:24 +01:00 committed by GitHub
commit 9c27fbadf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 78 additions and 4 deletions

View File

@ -1,3 +1,4 @@
import com.sap.piper.Utils
import hudson.AbortException
import org.junit.rules.TemporaryFolder
@ -6,6 +7,8 @@ import org.junit.BeforeClass
import org.junit.ClassRule
import org.junit.Ignore
import java.util.Map
import org.hamcrest.BaseMatcher
import org.hamcrest.Description
import org.jenkinsci.plugins.credentialsbinding.impl.CredentialNotFoundException
@ -81,13 +84,25 @@ class NeoDeployTest extends BasePiperTest {
@Test
void straightForwardTestConfigViaConfigProperties() {
boolean buildStatusHasBeenSet = false
boolean notifyOldConfigFrameworkUsed = false
nullScript.commonPipelineEnvironment.setConfigProperty('DEPLOY_HOST', 'test.deploy.host.com')
nullScript.commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'trialuser123')
nullScript.commonPipelineEnvironment.configuration = [:]
nullScript.currentBuild = [setResult: {buildStatusHasBeenSet = true}]
def utils = new Utils() {
void pushToSWA(Map parameters, Map config) {
notifyOldConfigFrameworkUsed = parameters.stepParam4
}
}
jsr.step.neoDeploy(script: nullScript,
archivePath: archiveName,
neoCredentialsId: 'myCredentialsId'
neoCredentialsId: 'myCredentialsId',
utils: utils
)
Assert.assertThat(jscr.shell,
@ -98,14 +113,53 @@ class NeoDeployTest extends BasePiperTest {
.hasSingleQuotedOption('user', 'anonymous')
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
.hasDoubleQuotedOption('source', '.*'))
assert !buildStatusHasBeenSet
assert notifyOldConfigFrameworkUsed
}
@Test
void testConfigViaConfigPropertiesSetsBuildToUnstable() {
def buildStatus = 'SUCCESS'
nullScript.commonPipelineEnvironment.setConfigProperty('DEPLOY_HOST', 'test.deploy.host.com')
nullScript.commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'trialuser123')
nullScript.commonPipelineEnvironment.configuration = [:]
nullScript.currentBuild = [setResult: { r -> buildStatus = r}]
System.setProperty('com.sap.piper.featureFlag.buildUnstableWhenOldConfigFrameworkIsUsedByNeoDeploy',
Boolean.TRUE.toString())
try {
jsr.step.neoDeploy(script: nullScript,
archivePath: archiveName,
neoCredentialsId: 'myCredentialsId',
utils: utils
)
} finally {
System.clearProperty('com.sap.piper.featureFlag.buildUnstableWhenOldConfigFrameworkIsUsedByNeoDeploy')
}
assert buildStatus == 'UNSTABLE'
}
@Test
void straightForwardTestConfigViaConfiguration() {
boolean notifyOldConfigFrameworkUsed = true
def utils = new Utils() {
void pushToSWA(Map parameters, Map config) {
notifyOldConfigFrameworkUsed = parameters.stepParam4
}
}
jsr.step.neoDeploy(script: nullScript,
archivePath: archiveName,
neoCredentialsId: 'myCredentialsId'
neoCredentialsId: 'myCredentialsId',
utils: utils,
)
Assert.assertThat(jscr.shell,
@ -116,6 +170,8 @@ class NeoDeployTest extends BasePiperTest {
.hasSingleQuotedOption('user', 'anonymous')
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
.hasDoubleQuotedOption('source', '.*'))
assert !notifyOldConfigFrameworkUsed
}
@Test

View File

@ -36,7 +36,7 @@ void call(parameters = [:]) {
def script = checkScript(this, parameters) ?: this
def utils = new Utils()
def utils = parameters.utils ?: new Utils()
prepareDefaultValues script: script
@ -72,6 +72,23 @@ void call(parameters = [:]) {
echo "[WARNING][${STEP_NAME}] Deprecated parameter 'neoCredentialsId' from old configuration framework is used. This will not work anymore in future versions."
parameters.put('neoCredentialsId', credId)
}
if(! stepCompatibilityConfiguration.isEmpty()) {
echo "[WARNING][$STEP_NAME] You are using a deprecated configuration framework. This will be removed in " +
'futureVersions.\nAdd snippet below to \'./pipeline/config.yml\' and remove ' +
'file \'.pipeline/configuration.properties\'.\n' +
"""|steps:
| neoDeploy:
| host: ${stepCompatibilityConfiguration.get('host', '<Add host here>')}
| account: ${stepCompatibilityConfiguration.get('account', '<Add account here>')}
""".stripMargin()
if(Boolean.getBoolean('com.sap.piper.featureFlag.buildUnstableWhenOldConfigFrameworkIsUsedByNeoDeploy')) {
script.currentBuild.setResult('UNSTABLE')
echo "[WARNING][$STEP_NAME] Build has been set to unstable since old config framework is used."
}
}
// Backward compatibility end
// load default & individual configuration
@ -89,7 +106,8 @@ void call(parameters = [:]) {
step: STEP_NAME,
stepParam1: configuration.deployMode == 'mta'?'mta':'war', // ['mta', 'warParams', 'warPropertiesFile']
stepParam2: configuration.warAction == 'rolling-update'?'blue-green':'standard', // ['deploy', 'deploy-mta', 'rolling-update']
stepParam3: parameters?.script == null
stepParam3: parameters?.script == null,
stepParam4: ! stepCompatibilityConfiguration.isEmpty(),
], configuration)
def archivePath = configuration.archivePath