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:
commit
7a9c5c9445
37
documentation/docs/steps/cloudFoundryCreateService.md
Normal file
37
documentation/docs/steps/cloudFoundryCreateService.md
Normal 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'])
|
||||
|
||||
```
|
@ -187,6 +187,8 @@ steps:
|
||||
serviceManifest: 'service-manifest.yml'
|
||||
dockerImage: 'ppiper/cf-cli'
|
||||
dockerWorkspace: '/home/piper'
|
||||
stashContent:
|
||||
- 'deployDescriptor'
|
||||
detectExecuteScan:
|
||||
detect:
|
||||
projectVersion: '1'
|
||||
|
@ -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")))
|
||||
}
|
||||
|
||||
@ -156,16 +156,16 @@ class CloudFoundryCreateServiceTest extends BasePiperTest {
|
||||
deployTool: 'cf_native',
|
||||
cfOrg: 'testOrg',
|
||||
cfSpace: 'testSpace',
|
||||
cfCredentialsId: 'test_cfCredentialsId',
|
||||
cfCredentialsId: 'test_cfCredentialsId',
|
||||
cfServiceManifest: 'test.yml',
|
||||
cfManifestVariablesFiles: [varsFileName],
|
||||
cfManifestVariables: varsList
|
||||
])
|
||||
])
|
||||
|
||||
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")))
|
||||
}
|
||||
|
||||
@ -180,9 +180,9 @@ class CloudFoundryCreateServiceTest extends BasePiperTest {
|
||||
deployTool: 'cf_native',
|
||||
cfOrg: 'testOrg',
|
||||
cfSpace: 'testSpace',
|
||||
cfCredentialsId: 'escape_cfCredentialsId',
|
||||
cfCredentialsId: 'escape_cfCredentialsId',
|
||||
cfServiceManifest: 'test.yml'
|
||||
])
|
||||
])
|
||||
|
||||
assertThat(shellRule.shell, hasItem(containsString("""cf login -u 'aUserWithA'"'"'' -p 'passHasA'"'"'' -a https://api.cf.eu10.hana.ondemand.com -o 'testOrg' -s 'testSpace'""")))
|
||||
}
|
||||
@ -196,9 +196,9 @@ class CloudFoundryCreateServiceTest extends BasePiperTest {
|
||||
deployTool: 'cf_native',
|
||||
cfOrg: 'testOrg',
|
||||
cfSpace: "testSpaceWith'",
|
||||
cfCredentialsId: 'test_cfCredentialsId',
|
||||
cfCredentialsId: 'test_cfCredentialsId',
|
||||
cfServiceManifest: 'test.yml'
|
||||
])
|
||||
])
|
||||
assertThat(shellRule.shell, hasItem(containsString("""cf login -u 'test_cf' -p '********' -a https://api.cf.eu10.hana.ondemand.com -o 'testOrg' -s 'testSpaceWith'"'"''""")))
|
||||
}
|
||||
|
||||
@ -211,9 +211,9 @@ class CloudFoundryCreateServiceTest extends BasePiperTest {
|
||||
deployTool: 'cf_native',
|
||||
cfOrg: "testOrgWith'",
|
||||
cfSpace: "testSpace",
|
||||
cfCredentialsId: 'test_cfCredentialsId',
|
||||
cfCredentialsId: 'test_cfCredentialsId',
|
||||
cfServiceManifest: 'test.yml'
|
||||
])
|
||||
])
|
||||
assertThat(shellRule.shell, hasItem(containsString("""cf login -u 'test_cf' -p '********' -a https://api.cf.eu10.hana.ondemand.com -o 'testOrgWith'"'"'' -s 'testSpace'""")))
|
||||
}
|
||||
|
||||
@ -228,12 +228,12 @@ class CloudFoundryCreateServiceTest extends BasePiperTest {
|
||||
deployTool: 'cf_native',
|
||||
cfOrg: 'testOrg',
|
||||
cfSpace: 'testSpace',
|
||||
cfCredentialsId: 'test_cfCredentialsId',
|
||||
cfCredentialsId: 'test_cfCredentialsId',
|
||||
cfServiceManifest: 'test.yml',
|
||||
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
|
||||
@ -248,12 +248,12 @@ class CloudFoundryCreateServiceTest extends BasePiperTest {
|
||||
deployTool: 'cf_native',
|
||||
cfOrg: 'testOrg',
|
||||
cfSpace: 'testSpace',
|
||||
cfCredentialsId: 'test_cfCredentialsId',
|
||||
cfCredentialsId: 'test_cfCredentialsId',
|
||||
cfServiceManifest: 'test.yml',
|
||||
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
|
||||
@ -271,14 +271,14 @@ class CloudFoundryCreateServiceTest extends BasePiperTest {
|
||||
deployTool: 'cf_native',
|
||||
cfOrg: 'testOrg',
|
||||
cfSpace: 'testSpace',
|
||||
cfCredentialsId: 'test_cfCredentialsId',
|
||||
cfCredentialsId: 'test_cfCredentialsId',
|
||||
cfServiceManifest: 'test.yml'
|
||||
])
|
||||
])
|
||||
|
||||
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerImage', 'ppiper/cf-cli'))
|
||||
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
|
||||
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")))
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user