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

deployToCloudFoundry - patch mta blue-green deployment (#457)

mta deploy plugin has flag:
` --no-confirm` which is described as _"Do not require confirmation for deleting the previously deployed MTA apps"_

This flag is essentials for performing fully automated blue-green deployments.
This commit is contained in:
Oliver Nocon 2019-01-22 16:13:59 +01:00 committed by GitHub
parent 6224d2aece
commit 27c3891685
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 2 deletions

View File

@ -32,7 +32,7 @@ Deployment can be done
| keepOldInstance | no | false | true, false |
| dockerImage | no | s4sdk/docker-cf-cli | |
| dockerWorkspace | no | /home/piper | |
| mtaDeployParameters | | -f | |
| mtaDeployParameters | | for _deployType:standard_ `-f`<br />for _deployType:blue-green_ `-f --no-confirm` | |
| mtaExtensionDescriptor | no | '' | |
| mtaPath | no | '' | |
| smokeTestScript | no | blueGreenCheckScript.sh (provided by library). <br />Can be overwritten using config property 'smokeTestScript' | |

View File

@ -16,6 +16,7 @@ import util.JenkinsWriteFileRule
import util.JenkinsReadYamlRule
import util.Rules
import static org.hamcrest.Matchers.stringContainsInOrder
import static org.junit.Assert.assertThat
import static org.hamcrest.Matchers.hasItem
@ -398,6 +399,24 @@ class CloudFoundryDeployTest extends BasePiperTest {
assertThat(jscr.shell, hasItem(containsString('cf logout')))
}
@Test
void testMtaBlueGreen() {
jsr.step.cloudFoundryDeploy([
script: nullScript,
juStabUtils: utils,
jenkinsUtilsStub: new JenkinsUtilsMock(),
cfOrg: 'testOrg',
cfSpace: 'testSpace',
cfCredentialsId: 'test_cfCredentialsId',
deployTool: 'mtaDeployPlugin',
deployType: 'blue-green',
mtaPath: 'target/test.mtar'
])
assertThat(jscr.shell, hasItem(stringContainsInOrder(["cf login -u test_cf", 'cf bg-deploy', '-f', '--no-confirm'])))
}
@Test
void testInfluxReporting() {
jryr.registerYaml('test.yml', "applications: [[name: 'manifestAppName']]")

View File

@ -209,8 +209,12 @@ def deployMta (config) {
if (!config.mtaExtensionDescriptor.isEmpty() && !config.mtaExtensionDescriptor.startsWith('-e ')) config.mtaExtensionDescriptor = "-e ${config.mtaExtensionDescriptor}"
def deployCommand = 'deploy'
if (config.deployType == 'blue-green')
if (config.deployType == 'blue-green') {
deployCommand = 'bg-deploy'
if (config.mtaDeployParameters.indexOf('--no-confirm') < 0) {
config.mtaDeployParameters += ' --no-confirm'
}
}
withCredentials([usernamePassword(
credentialsId: config.cloudFoundry.credentialsId,