mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
Merge pull request #44 from milkotodorov/master
Neo deploy - Add support for WAR file deployment/rolling-update
This commit is contained in:
commit
b9eedda38e
@ -2,36 +2,72 @@
|
||||
|
||||
## Description
|
||||
Deploys an Application to SAP Cloud Platform (SAP CP) using the SAP Cloud Platform Console Client (Neo Java Web SDK).
|
||||
|
||||
|
||||
## Prerequisites
|
||||
* **SAP CP account** - the account to where the application is deployed.
|
||||
* **SAP CP user for deployment** - a user with deployment permissions in the given account.
|
||||
* **Jenkins credentials for deployment** - must be configured in Jenkins credentials with a dedicated Id.
|
||||
|
||||
![Jenkins credentials configuration](../images/neo_credentials.png)
|
||||
|
||||
|
||||
* **Neo Java Web SDK** - can be downloaded from [Maven Central](http://central.maven.org/maven2/com/sap/cloud/neo-java-web-sdk/). The Neo Java Web SDK
|
||||
needs to be extracted into the folder provided by `neoHome`. In case this parameters is not provided and there is no NEO_HOME parameter in the environment
|
||||
`<neoRoot>/tools` needs to be in the `PATH`.
|
||||
|
||||
* **Java 8 or higher** - needed by the *Neo-Java-Web-SDK*
|
||||
|
||||
## Parameters
|
||||
| parameter | mandatory | default | possible values |
|
||||
| -------------------|-----------|----------------------------------------------------------------------------------------------|-----------------|
|
||||
| `script` | yes | | |
|
||||
| `archivePath` | yes | | |
|
||||
| `deployHost` | no | `'DEPLOY_HOST'` from `commonPipelineEnvironment` | |
|
||||
| `deployAccount` | no | `'CI_DEPLOY_ACCOUNT'` from `commonPipelineEnvironment` | |
|
||||
| `neoCredentialsId` | no | `'CI_CREDENTIALS_ID'` | |
|
||||
| `neoHome` | no | Environment is checked for `NEO_HOME`, <br>otherwise the neo toolset is expected in the path | |
|
||||
## Parameters when using MTA deployment method (default - MTA)
|
||||
| parameter | mandatory | default | possible values |
|
||||
| -------------------|-----------|----------------------------------------------------------------------------------------------|-------------------------------------------------|
|
||||
| `deployMode` | yes | `'MTA'` | `'MTA'`, `'WAR_PARAMS'`, `'WAR_PROPERTIESFILE'` |
|
||||
| `script` | yes | | |
|
||||
| `archivePath` | yes | | |
|
||||
| `deployHost` | no | `'DEPLOY_HOST'` from `commonPipelineEnvironment` | |
|
||||
| `deployAccount` | no | `'CI_DEPLOY_ACCOUNT'` from `commonPipelineEnvironment` | |
|
||||
| `neoCredentialsId` | no | `'CI_CREDENTIALS_ID'` | |
|
||||
| `neoHome` | no | Environment is checked for `NEO_HOME`, <br>otherwise the neo toolset is expected in the path | |
|
||||
|
||||
## Parameters when using WAR file deployment method with .properties file (WAR_PROPERTIESFILE)
|
||||
| parameter | mandatory | default | possible values |
|
||||
| -------------------|-----------|----------------------------------------------------------------------------------------------|-------------------------------------------------|
|
||||
| `deployMode` | yes | `'MTA'` | `'MTA'`, `'WAR_PARAMS'`, `'WAR_PROPERTIESFILE'` |
|
||||
| `warAction` | yes | `'deploy'` | `'deploy'`, `'rolling-update'` |
|
||||
| `script` | yes | | |
|
||||
| `archivePath` | yes | | |
|
||||
| `neoCredentialsId` | no | `'CI_CREDENTIALS_ID'` | |
|
||||
| `neoHome` | no | Environment is checked for `NEO_HOME`, <br>otherwise the neo toolset is expected in the path | |
|
||||
| `propertiesFile` | yes | | |
|
||||
|
||||
## Parameters when using WAR file deployment method witout .properties file - with parameters (WAR_PARAMS)
|
||||
| parameter | mandatory | default | possible values |
|
||||
| -------------------|-----------|----------------------------------------------------------------------------------------------|-------------------------------------------------|
|
||||
| `deployMode` | yes | `'MTA'` | `'MTA'`, `'WAR_PARAMS'`, `'WAR_PROPERTIESFILE'` |
|
||||
| `warAction` | yes | `'deploy'` | `'deploy'`, `'rolling-update'` |
|
||||
| `script` | yes | | |
|
||||
| `archivePath` | yes | | |
|
||||
| `deployHost` | no | `'DEPLOY_HOST'` from `commonPipelineEnvironment` | |
|
||||
| `deployAccount` | no | `'CI_DEPLOY_ACCOUNT'` from `commonPipelineEnvironment` | |
|
||||
| `neoCredentialsId` | no | `'CI_CREDENTIALS_ID'` | |
|
||||
| `neoHome` | no | Environment is checked for `NEO_HOME`, <br>otherwise the neo toolset is expected in the path | |
|
||||
| `applicationName` | yes | | |
|
||||
| `runtime` | yes | | |
|
||||
| `runtime-version` | yes | | |
|
||||
| `size` | no | `'lite'` | `'lite'`, `'pro'`, `'prem'`, `'prem-plus'` |
|
||||
|
||||
|
||||
* `deployMode` - The deployment mode which should be used. Available options are `'MTA'` (default), `'WAR_PARAMS'` (deploying WAR file and passing all the deployment parameters via the function call) and `'WAR_PROPERTIESFILE'` (deploying WAR file and putting all the deployment parameters in a .properties file)
|
||||
* `script` - The common script environment of the Jenkinsfile run. Typically `this` is passed to this parameter. This allows the function to access the [`commonPipelineEnvironment`](commonPipelineEnvironment.md) for retrieving e.g. configuration parameters.
|
||||
* `archivePath`- The path to the archive for deployment to SAP CP.
|
||||
* `deployHost` - The SAP Cloud Platform host to deploy to.
|
||||
* `deployAccount` - The SAP Cloud Platform account to deploy to.
|
||||
* `credentialsId` - The Jenkins credentials containing user and password used for SAP CP deployment.
|
||||
* `neoHome` - The path to the `neo-java-web-sdk` tool used for SAP CP deployment. If no parameter is provided, the path is retrieved from the Jenkins environment variables using `env.NEO_HOME`. If this Jenkins environment variable is not set it is assumed that the tool is available in the `PATH`.
|
||||
* `propertiesFile` - The path to the .properties file in which all necessary deployment properties for the application are defined.
|
||||
* `warAction` - Action mode when using WAR file mode. Available options are `deploy` (default) and `rolling-update` which performs update of an application without downtime in one go.
|
||||
* `applicationName` - Name of the application you want to manage, configure, or deploy
|
||||
* `runtime` - Name of SAP Cloud Platform application runtime
|
||||
* `runtime-version` - Version of SAP Cloud Platform application runtime
|
||||
* `size` - Compute unit (VM) size. Acceptable values: lite, pro, prem, prem-plus.
|
||||
|
||||
## Return value
|
||||
none
|
||||
@ -42,6 +78,10 @@ none
|
||||
## Exceptions
|
||||
* `Exception`:
|
||||
* If `archivePath` is not provided.
|
||||
* If `propertiesFile` is not provided (when using `'WAR_PROPERTIESFILE'` deployment mode).
|
||||
* If `applicationName` is not provided (when using `'WAR_PARAMS'` deployment mode).
|
||||
* If `runtime` is not provided (when using `'WAR_PARAMS'` deployment mode).
|
||||
* If `runtime-version` is not provided (when using `'WAR_PARAMS'` deployment mode).
|
||||
* `AbortException`:
|
||||
* If neo-java-web-sdk is not installed, or `neoHome`is wrong.
|
||||
* If `deployHost` is wrong.
|
||||
|
@ -19,6 +19,8 @@ class NeoDeploymentTest extends PiperTestBase {
|
||||
public TemporaryFolder tmp = new TemporaryFolder()
|
||||
|
||||
def archivePath
|
||||
def warArchivePath
|
||||
def propertiesFilePath
|
||||
|
||||
@Before
|
||||
void setUp() {
|
||||
@ -26,6 +28,8 @@ class NeoDeploymentTest extends PiperTestBase {
|
||||
super.setUp()
|
||||
|
||||
archivePath = "${tmp.newFolder("workspace").toURI().getPath()}archiveName.mtar"
|
||||
warArchivePath = "${tmp.getRoot().toURI().getPath()}workspace/warArchive.war"
|
||||
propertiesFilePath = "${tmp.getRoot().toURI().getPath()}workspace/config.properties"
|
||||
|
||||
helper.registerAllowedMethod('error', [String], { s -> throw new AbortException(s) })
|
||||
helper.registerAllowedMethod('usernamePassword', [Map], { m -> return m })
|
||||
@ -60,7 +64,7 @@ class NeoDeploymentTest extends PiperTestBase {
|
||||
|
||||
withPipeline(defaultPipeline()).execute(archivePath, 'myCredentialsId')
|
||||
|
||||
assert shellCalls[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy-mta --user 'anonymous' --host 'test\.deploy\.host\.com' --source ".*" --account 'trialuser123' --password '\*\*\*\*\*\*\*\*' --synchronous/
|
||||
assert shellCalls[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy-mta --user 'anonymous' --password '\*\*\*\*\*\*\*\*' --source ".*" --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous/
|
||||
|
||||
assert messages[1] == "[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment."
|
||||
|
||||
@ -90,7 +94,7 @@ class NeoDeploymentTest extends PiperTestBase {
|
||||
|
||||
withPipeline(noCredentialsIdPipeline()).execute(archivePath)
|
||||
|
||||
assert shellCalls[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy-mta --user 'defaultUser' --host 'test\.deploy\.host\.com' --source ".*" --account 'trialuser123' --password '\*\*\*\*\*\*\*\*' --synchronous/
|
||||
assert shellCalls[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy-mta --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*" --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous/
|
||||
|
||||
assert messages[1] == "[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment."
|
||||
}
|
||||
@ -103,7 +107,7 @@ class NeoDeploymentTest extends PiperTestBase {
|
||||
|
||||
withPipeline(noCredentialsIdPipeline()).execute(archivePath)
|
||||
|
||||
assert shellCalls[0] =~ /#!\/bin\/bash "neo" deploy-mta --user 'defaultUser' --host 'test\.deploy\.host\.com' --source ".*" --account 'trialuser123' --password '\*\*\*\*\*\*\*\*' --synchronous/
|
||||
assert shellCalls[0] =~ /#!\/bin\/bash "neo" deploy-mta --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*" --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous/
|
||||
|
||||
assert messages[1] == "Using Neo executable from PATH."
|
||||
}
|
||||
@ -116,7 +120,7 @@ class NeoDeploymentTest extends PiperTestBase {
|
||||
|
||||
withPipeline(neoHomeParameterPipeline()).execute(archivePath, 'myCredentialsId')
|
||||
|
||||
assert shellCalls[0] =~ /#!\/bin\/bash "\/etc\/neo\/tools\/neo\.sh" deploy-mta --user 'anonymous' --host 'test\.deploy\.host\.com' --source ".*" --account 'trialuser123' --password '\*\*\*\*\*\*\*\*' --synchronous.*/
|
||||
assert shellCalls[0] =~ /#!\/bin\/bash "\/etc\/neo\/tools\/neo\.sh" deploy-mta --user 'anonymous' --password '\*\*\*\*\*\*\*\*' --source ".*" --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous.*/
|
||||
|
||||
assert messages[1] == "[neoDeploy] Neo executable \"/etc/neo/tools/neo.sh\" retrieved from parameters."
|
||||
|
||||
@ -157,6 +161,122 @@ class NeoDeploymentTest extends PiperTestBase {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void mtaDeployModeTest() {
|
||||
binding.getVariable('env')['NEO_HOME'] = '/opt/neo'
|
||||
new File(archivePath) << "dummy archive"
|
||||
|
||||
withPipeline(mtaDeployModePipeline()).execute(archivePath, 'mta')
|
||||
|
||||
assert shellCalls[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy-mta --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*" --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous.*/
|
||||
assert messages[1] == "[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment."
|
||||
}
|
||||
|
||||
@Test
|
||||
void warFileParamsDeployModeTest() {
|
||||
binding.getVariable('env')['NEO_HOME'] = '/opt/neo'
|
||||
new File(warArchivePath) << "dummy war archive"
|
||||
|
||||
withPipeline(warParamsDeployModePipeline()).execute(warArchivePath, 'warParams', 'lite', 'deploy')
|
||||
|
||||
assert shellCalls[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*\.war" --host 'test\.deploy\.host\.com' --account 'trialuser123' --application 'testApp' --runtime 'neo-javaee6-wp' --runtime-version '2\.125' --size 'lite'/
|
||||
assert messages[1] == "[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment."
|
||||
}
|
||||
|
||||
@Test
|
||||
void warFileParamsDeployModeRollingUpdateTest() {
|
||||
binding.getVariable('env')['NEO_HOME'] = '/opt/neo'
|
||||
new File(warArchivePath) << "dummy war archive"
|
||||
|
||||
withPipeline(warParamsDeployModePipeline()).execute(warArchivePath, 'warParams', 'lite', 'rolling-update')
|
||||
|
||||
assert shellCalls[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" rolling-update --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*\.war" --host 'test\.deploy\.host\.com' --account 'trialuser123' --application 'testApp' --runtime 'neo-javaee6-wp' --runtime-version '2\.125' --size 'lite'/
|
||||
assert messages[1] == "[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment."
|
||||
}
|
||||
|
||||
@Test
|
||||
void warPropertiesFileDeployModeTest() {
|
||||
binding.getVariable('env')['NEO_HOME'] = '/opt/neo'
|
||||
new File(warArchivePath) << "dummy war archive"
|
||||
new File(propertiesFilePath) << "dummy properties file"
|
||||
|
||||
withPipeline(warPropertiesFileDeployModePipeline()).execute(warArchivePath, propertiesFilePath, 'warPropertiesFile', 'deploy')
|
||||
|
||||
assert shellCalls[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*\.war" .*\.properties/
|
||||
assert messages[1] == "[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment."
|
||||
}
|
||||
|
||||
@Test
|
||||
void warPropertiesFileDeployModeRollingUpdateTest() {
|
||||
binding.getVariable('env')['NEO_HOME'] = '/opt/neo'
|
||||
new File(warArchivePath) << "dummy war archive"
|
||||
new File(propertiesFilePath) << "dummy properties file"
|
||||
|
||||
withPipeline(warPropertiesFileDeployModePipeline()).execute(warArchivePath, propertiesFilePath, 'warPropertiesFile', 'rolling-update')
|
||||
|
||||
assert shellCalls[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" rolling-update --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*\.war" .*\.properties/
|
||||
assert messages[1] == "[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment."
|
||||
}
|
||||
|
||||
@Test
|
||||
void applicationNameNotProvidedTest() {
|
||||
new File(warArchivePath) << "dummy war archive"
|
||||
|
||||
thrown.expect(Exception)
|
||||
thrown.expectMessage('ERROR - NO VALUE AVAILABLE FOR applicationName')
|
||||
|
||||
withPipeline(noApplicationNamePipeline()).execute(warArchivePath, 'warParams')
|
||||
}
|
||||
|
||||
@Test
|
||||
void runtimeNotProvidedTest() {
|
||||
new File(warArchivePath) << "dummy war archive"
|
||||
|
||||
thrown.expect(Exception)
|
||||
thrown.expectMessage('ERROR - NO VALUE AVAILABLE FOR runtime')
|
||||
|
||||
withPipeline(noRuntimePipeline()).execute(warArchivePath, 'warParams')
|
||||
}
|
||||
|
||||
@Test
|
||||
void runtimeVersionNotProvidedTest() {
|
||||
new File(warArchivePath) << "dummy war archive"
|
||||
|
||||
thrown.expect(Exception)
|
||||
thrown.expectMessage('ERROR - NO VALUE AVAILABLE FOR runtimeVersion')
|
||||
|
||||
withPipeline(noRuntimeVersionPipeline()).execute(warArchivePath, 'warParams')
|
||||
}
|
||||
|
||||
@Test
|
||||
void illegalDeployModeTest() {
|
||||
new File(warArchivePath) << "dummy war archive"
|
||||
|
||||
thrown.expect(Exception)
|
||||
thrown.expectMessage("[neoDeploy] Invalid deployMode = 'illegalMode'. Valid 'deployMode' values are: 'mta', 'warParams' and 'warPropertiesFile'")
|
||||
|
||||
withPipeline(warParamsDeployModePipeline()).execute(warArchivePath, 'illegalMode', 'lite', 'deploy')
|
||||
}
|
||||
|
||||
@Test
|
||||
void illegalVMSizeTest() {
|
||||
new File(warArchivePath) << "dummy war archive"
|
||||
|
||||
thrown.expect(Exception)
|
||||
thrown.expectMessage("[neoDeploy] Invalid vmSize = 'illegalVM'. Valid 'vmSize' values are: 'lite', 'pro', 'prem' and 'prem-plus'.")
|
||||
|
||||
withPipeline(warParamsDeployModePipeline()).execute(warArchivePath, 'warParams', 'illegalVM', 'deploy')
|
||||
}
|
||||
|
||||
@Test
|
||||
void illegalWARActionTest() {
|
||||
new File(warArchivePath) << "dummy war archive"
|
||||
|
||||
thrown.expect(Exception)
|
||||
thrown.expectMessage("[neoDeploy] Invalid warAction = 'illegalWARAction'. Valid 'warAction' values are: 'deploy' and 'rolling-update'.")
|
||||
|
||||
withPipeline(warParamsDeployModePipeline()).execute(warArchivePath, 'warParams', 'lite', 'illegalWARAction')
|
||||
}
|
||||
|
||||
private defaultPipeline(){
|
||||
return """
|
||||
@ -250,4 +370,126 @@ class NeoDeploymentTest extends PiperTestBase {
|
||||
"""
|
||||
}
|
||||
|
||||
private noApplicationNamePipeline() {
|
||||
return """
|
||||
@Library('piper-library-os')
|
||||
|
||||
execute(warArchivePath, deployMode) {
|
||||
|
||||
commonPipelineEnvironment.setConfigProperty('DEPLOY_HOST', 'test.deploy.host.com')
|
||||
commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'trialuser123')
|
||||
def runtime = 'neo-javaee6-wp'
|
||||
def runtimeVersion = '2.125'
|
||||
|
||||
node() {
|
||||
neoDeploy script: this, archivePath: warArchivePath, deployMode: deployMode, runtime: runtime, runtimeVersion: runtimeVersion
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return this
|
||||
"""
|
||||
}
|
||||
|
||||
private noRuntimePipeline() {
|
||||
return """
|
||||
@Library('piper-library-os')
|
||||
|
||||
execute(warArchivePath, deployMode) {
|
||||
|
||||
commonPipelineEnvironment.setConfigProperty('DEPLOY_HOST', 'test.deploy.host.com')
|
||||
commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'trialuser123')
|
||||
def appName = 'testApp'
|
||||
def runtime = 'neo-javaee6-wp'
|
||||
def runtimeVersion = '2.125'
|
||||
|
||||
node() {
|
||||
neoDeploy script: this, archivePath: warArchivePath, deployMode: deployMode, applicationName: appName, runtimeVersion: runtimeVersion
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return this
|
||||
"""
|
||||
}
|
||||
|
||||
private noRuntimeVersionPipeline() {
|
||||
return """
|
||||
@Library('piper-library-os')
|
||||
|
||||
execute(warArchivePath, deployMode) {
|
||||
|
||||
commonPipelineEnvironment.setConfigProperty('DEPLOY_HOST', 'test.deploy.host.com')
|
||||
commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'trialuser123')
|
||||
def appName = 'testApp'
|
||||
def runtime = 'neo-javaee6-wp'
|
||||
def runtimeVersion = '2.125'
|
||||
|
||||
node() {
|
||||
neoDeploy script: this, archivePath: warArchivePath, deployMode: deployMode, applicationName: appName, runtime: runtime
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return this
|
||||
"""
|
||||
}
|
||||
|
||||
private warPropertiesFileDeployModePipeline() {
|
||||
return """
|
||||
@Library('piper-library-os')
|
||||
|
||||
execute(warArchivePath, propertiesFilePath, deployMode, warAction) {
|
||||
|
||||
node() {
|
||||
neoDeploy script: this, deployMode: deployMode, archivePath: warArchivePath, propertiesFile: propertiesFilePath, warAction: warAction
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return this
|
||||
"""
|
||||
}
|
||||
|
||||
private warParamsDeployModePipeline() {
|
||||
return """
|
||||
@Library('piper-library-os')
|
||||
|
||||
execute(warArchivePath, deployMode, vmSize, warAction) {
|
||||
|
||||
commonPipelineEnvironment.setConfigProperty('DEPLOY_HOST', 'test.deploy.host.com')
|
||||
commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'trialuser123')
|
||||
def appName = 'testApp'
|
||||
def runtime = 'neo-javaee6-wp'
|
||||
def runtimeVersion = '2.125'
|
||||
|
||||
node() {
|
||||
neoDeploy script: this, archivePath: warArchivePath, deployMode: deployMode, applicationName: appName, runtime: runtime, runtimeVersion: runtimeVersion, warAction: warAction, vmSize: vmSize
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return this
|
||||
"""
|
||||
}
|
||||
|
||||
private mtaDeployModePipeline() {
|
||||
return """
|
||||
@Library('piper-library-os')
|
||||
|
||||
execute(archivePath, deployMode) {
|
||||
|
||||
commonPipelineEnvironment.setConfigProperty('DEPLOY_HOST', 'test.deploy.host.com')
|
||||
commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'trialuser123')
|
||||
|
||||
node() {
|
||||
neoDeploy script: this, archivePath: archivePath, deployMode: deployMode
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return this
|
||||
"""
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,44 @@ def call(parameters = [:]) {
|
||||
error "Archive cannot be found with parameter archivePath: '${archivePath}'."
|
||||
}
|
||||
|
||||
def deployMode = utils.getMandatoryParameter(parameters, 'deployMode', 'mta')
|
||||
|
||||
if (deployMode != 'mta' && deployMode != 'warParams' && deployMode != 'warPropertiesFile') {
|
||||
throw new Exception("[neoDeploy] Invalid deployMode = '${deployMode}'. Valid 'deployMode' values are: 'mta', 'warParams' and 'warPropertiesFile'")
|
||||
}
|
||||
|
||||
def propertiesFile
|
||||
def warAction
|
||||
if (deployMode == 'warPropertiesFile' || deployMode == 'warParams') {
|
||||
warAction = utils.getMandatoryParameter(parameters, 'warAction', 'deploy')
|
||||
if (warAction != 'deploy' && warAction != 'rolling-update') {
|
||||
throw new Exception("[neoDeploy] Invalid warAction = '${warAction}'. Valid 'warAction' values are: 'deploy' and 'rolling-update'.")
|
||||
}
|
||||
}
|
||||
if (deployMode == 'warPropertiesFile') {
|
||||
propertiesFile = new File(utils.getMandatoryParameter(parameters, 'propertiesFile', null))
|
||||
if (!propertiesFile.isAbsolute()) {
|
||||
propertiesFile = new File(pwd(), propertiesFile.getPath())
|
||||
}
|
||||
if (!propertiesFile.exists()){
|
||||
error "Properties file cannot be found with parameter propertiesFile: '${propertiesFile}'."
|
||||
}
|
||||
}
|
||||
|
||||
def applicationName
|
||||
def runtime
|
||||
def runtimeVersion
|
||||
def vmSize
|
||||
if (deployMode == 'warParams') {
|
||||
applicationName = utils.getMandatoryParameter(parameters, 'applicationName', null)
|
||||
runtime = utils.getMandatoryParameter(parameters, 'runtime', null)
|
||||
runtimeVersion = utils.getMandatoryParameter(parameters, 'runtimeVersion', null)
|
||||
vmSize = utils.getMandatoryParameter(parameters, 'vmSize', 'lite')
|
||||
if (vmSize != 'lite' && vmSize !='pro' && vmSize != 'prem' && vmSize != 'prem-plus') {
|
||||
throw new Exception("[neoDeploy] Invalid vmSize = '${vmSize}'. Valid 'vmSize' values are: 'lite', 'pro', 'prem' and 'prem-plus'.")
|
||||
}
|
||||
}
|
||||
|
||||
def defaultDeployHost = script.commonPipelineEnvironment.getConfigProperty('DEPLOY_HOST')
|
||||
def defaultDeployAccount = script.commonPipelineEnvironment.getConfigProperty('CI_DEPLOY_ACCOUNT')
|
||||
def defaultCredentialsId = script.commonPipelineEnvironment.getConfigProperty('neoCredentialsId')
|
||||
@ -26,26 +64,59 @@ def call(parameters = [:]) {
|
||||
defaultCredentialsId = 'CI_CREDENTIALS_ID'
|
||||
}
|
||||
|
||||
def deployHost = utils.getMandatoryParameter(parameters, 'deployHost', defaultDeployHost)
|
||||
def deployAccount = utils.getMandatoryParameter(parameters, 'deployAccount', defaultDeployAccount)
|
||||
def deployHost
|
||||
def deployAccount
|
||||
|
||||
if (deployMode.equals('mta') || deployMode.equals('warParams')) {
|
||||
deployHost = utils.getMandatoryParameter(parameters, 'deployHost', defaultDeployHost)
|
||||
deployAccount = utils.getMandatoryParameter(parameters, 'deployAccount', defaultDeployAccount)
|
||||
}
|
||||
|
||||
def credentialsId = parameters.get('neoCredentialsId', defaultCredentialsId)
|
||||
|
||||
def neoExecutable = getNeoExecutable(parameters)
|
||||
|
||||
withCredentials([usernamePassword(
|
||||
credentialsId: credentialsId,
|
||||
passwordVariable: 'password',
|
||||
usernameVariable: 'username'
|
||||
)]) {
|
||||
sh """#!/bin/bash
|
||||
"${neoExecutable}" deploy-mta \
|
||||
--user '${username}' \
|
||||
credentialsId: credentialsId,
|
||||
passwordVariable: 'password',
|
||||
usernameVariable: 'username')]) {
|
||||
|
||||
def commonDeployParams =
|
||||
"""--user '${username}' \
|
||||
--password '${password}' \
|
||||
--source "${archivePath.getAbsolutePath()}" \
|
||||
"""
|
||||
|
||||
if (deployMode == 'mta') {
|
||||
sh """#!/bin/bash
|
||||
"${neoExecutable}" deploy-mta \
|
||||
${commonDeployParams} \
|
||||
--host '${deployHost}' \
|
||||
--source "${archivePath.getAbsolutePath()}" \
|
||||
--account '${deployAccount}' \
|
||||
--password '${password}' \
|
||||
--synchronous
|
||||
"""
|
||||
"""
|
||||
}
|
||||
|
||||
if (deployMode == 'warParams') {
|
||||
sh """#!/bin/bash
|
||||
"${neoExecutable}" ${warAction} \
|
||||
${commonDeployParams} \
|
||||
--host '${deployHost}' \
|
||||
--account '${deployAccount}' \
|
||||
--application '${applicationName}' \
|
||||
--runtime '${runtime}' \
|
||||
--runtime-version '${runtimeVersion}' \
|
||||
--size '${vmSize}'
|
||||
"""
|
||||
}
|
||||
|
||||
if (deployMode == 'warPropertiesFile') {
|
||||
sh """#!/bin/bash
|
||||
"${neoExecutable}" ${warAction} \
|
||||
${commonDeployParams} \
|
||||
${propertiesFile.getAbsolutePath()}
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user