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

Merge branch 'master' into pr/allCPEsCanBeUsed2

This commit is contained in:
Thorsten Duda 2019-11-12 12:16:33 +01:00 committed by GitHub
commit 7a9c5c9445
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 23 deletions

View File

@ -0,0 +1,37 @@
# ${docGenStepName}
## ${docGenDescription}
## ${docGenParameters}
## ${docGenConfiguration}
## ${docJenkinsPluginDependencies}
## Example
The following Example will create the services specified in a file `manifest-create-service.yml` in cloud foundry org `cfOrg` of Cloud Foundry installation accessed via `https://test.server.com` in space `cfSpace` by using the username & password stored in `cfCredentialsId`.
```groovy
cloudFoundryCreateService(
script: this,
cloudFoundry: [apiEndpoint: 'https://test.server.com',
credentialsId: 'cfCredentialsId',
serviceManifest: 'manifest-create-service.yml',
org: 'cfOrg',
space: 'cfSpace'])
```
The following example additionally to above also makes use of a variable substitution file `mainfest-variable-substitution.yml`.
```groovy
cloudFoundryCreateService(
script: this,
cloudFoundry: [apiEndpoint: 'https://test.server.com',
credentialsId: 'cfCredentialsId',
serviceManifest: 'manifest-create-service.yml',
manifestVariablesFiles: ['mainfest-variable-substitution.yml'],
org: 'cfOrg',
space: 'cfSpace'])
```

View File

@ -187,6 +187,8 @@ steps:
serviceManifest: 'service-manifest.yml'
dockerImage: 'ppiper/cf-cli'
dockerWorkspace: '/home/piper'
stashContent:
- 'deployDescriptor'
detectExecuteScan:
detect:
projectVersion: '1'

View File

@ -139,7 +139,7 @@ class CloudFoundryCreateServiceTest extends BasePiperTest {
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerImage', 'ppiper/cf-cli'))
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
assertThat(shellRule.shell, hasItem(containsString("cf login -u 'test_cf' -p '********' -a https://api.cf.eu10.hana.ondemand.com -o 'testOrg' -s 'testSpace'")))
assertThat(shellRule.shell, hasItem(containsString(" cf create-service-push --no-push -f 'test.yml'")))
assertThat(shellRule.shell, hasItem(containsString(" cf create-service-push --no-push --service-manifest 'test.yml'")))
assertThat(shellRule.shell, hasItem(containsString("cf logout")))
}
@ -165,7 +165,7 @@ class CloudFoundryCreateServiceTest extends BasePiperTest {
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerImage', 'ppiper/cf-cli'))
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
assertThat(shellRule.shell, hasItem(containsString("cf login -u 'test_cf' -p '********' -a https://api.cf.eu10.hana.ondemand.com -o 'testOrg' -s 'testSpace'")))
assertThat(shellRule.shell, hasItem(containsString("cf create-service-push --no-push -f 'test.yml' --var appName='testApplicationFromVarsList' --vars-file 'vars.yml'")))
assertThat(shellRule.shell, hasItem(containsString("cf create-service-push --no-push --service-manifest 'test.yml' --var appName='testApplicationFromVarsList' --vars-file 'vars.yml'")))
assertThat(shellRule.shell, hasItem(containsString("cf logout")))
}
@ -233,7 +233,7 @@ class CloudFoundryCreateServiceTest extends BasePiperTest {
cfManifestVariables: varsList
])
assertThat(shellRule.shell, hasItem(containsString("""cf create-service-push --no-push -f 'test.yml' --var appName='testApplicationFromVarsListWith'"'"''""")))
assertThat(shellRule.shell, hasItem(containsString("""cf create-service-push --no-push --service-manifest 'test.yml' --var appName='testApplicationFromVarsListWith'"'"''""")))
}
@Test
@ -253,7 +253,7 @@ class CloudFoundryCreateServiceTest extends BasePiperTest {
cfManifestVariablesFiles: [varsFileName]
])
assertThat(shellRule.shell, hasItem(containsString("""cf create-service-push --no-push -f 'test.yml' --vars-file 'varsWith'"'"'.yml'""")))
assertThat(shellRule.shell, hasItem(containsString("""cf create-service-push --no-push --service-manifest 'test.yml' --vars-file 'varsWith'"'"'.yml'""")))
}
@Test
@ -278,7 +278,7 @@ class CloudFoundryCreateServiceTest extends BasePiperTest {
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerImage', 'ppiper/cf-cli'))
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
assertThat(shellRule.shell, hasItem(containsString("cf login -u 'test_cf' -p '********' -a https://api.cf.eu10.hana.ondemand.com -o 'testOrg' -s 'testSpace'")))
assertThat(shellRule.shell, hasItem(containsString(" cf create-service-push --no-push -f 'test.yml'")))
assertThat(shellRule.shell, hasItem(containsString(" cf create-service-push --no-push --service-manifest 'test.yml'")))
assertThat(shellRule.shell, hasItem(containsString("cf logout")))
}
}

View File

@ -79,9 +79,10 @@ import static com.sap.piper.Prerequisites.checkScript
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
/**
* Uses the Create-Service-Push plugin to create services in a Cloud Foundry space.
* Step that uses the CF Create-Service-Push plugin to create services in a Cloud Foundry space. The information about the services is provided in a yaml file as infrastructure as code.
* It is possible to use variable substitution inside of the yaml file like in a CF-push manifest yaml.
*
* For details how to specify the services see the [github page of the plugin](https://github.com/dawu415/CF-CLI-Create-Service-Push-Plugin).
* For more details how to specify the services in the yaml see the [github page of the plugin](https://github.com/dawu415/CF-CLI-Create-Service-Push-Plugin).
*
* The `--no-push` options is always used with the plugin. To deploy the application make use of the cloudFoundryDeploy step!
*/
@ -130,7 +131,7 @@ private def executeCreateServicePush(script, Map config) {
set -e
export HOME=${config.dockerWorkspace}
cf login -u ${BashUtils.quoteAndEscape(CF_USERNAME)} -p ${BashUtils.quoteAndEscape(CF_PASSWORD)} -a ${config.cloudFoundry.apiEndpoint} -o ${BashUtils.quoteAndEscape(config.cloudFoundry.org)} -s ${BashUtils.quoteAndEscape(config.cloudFoundry.space)};
cf create-service-push --no-push -f ${BashUtils.quoteAndEscape(config.cloudFoundry.serviceManifest)}${varPart}${varFilePart}
cf create-service-push --no-push --service-manifest ${BashUtils.quoteAndEscape(config.cloudFoundry.serviceManifest)}${varPart}${varFilePart}
"""
sh "cf logout"
if (returnCode!=0) {