mirror of
https://github.com/SAP/jenkins-library.git
synced 2026-06-19 22:58:55 +02:00
Merge remote-tracking branch 'github/master' into HEAD
This commit is contained in:
commit
c9572d187b
16 files changed
+236
-44
No files matched your search
@@ -14,12 +14,20 @@ Creates a Transport Request for a Change Document on the Solution Manager.
|
||||
| `credentialsId` | yes | | |
|
||||
| `endpoint` | yes | | |
|
||||
| `clientOpts` | no | | |
|
||||
| `gitFrom` | no | `origin/master` | |
|
||||
| `gitTo` | no | `HEAD` | |
|
||||
| `gitChangeDocumentLabel` | no | `ChangeDocument\s?:` | regex pattern |
|
||||
| `gitFormat` | no | `%b` | see `git log --help` |
|
||||
|
||||
* `script` - The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with the `this` parameter, as in `script: this`. This allows the function to access the [`commonPipelineEnvironment`](commonPipelineEnvironment.md) for retrieving, for example, configuration parameters.
|
||||
* `changeDocumentId` - The id of the change document to transport.
|
||||
* `credentialsId` - The credentials to connect to the Solution Manager.
|
||||
* `endpoint` - The address of the Solution Manager.
|
||||
* `clientOpts`- Options forwarded to JVM used by the CM client, like `JAVA_OPTS`
|
||||
* `gitFrom` - The starting point for retrieving the change document id
|
||||
* `gitTo` - The end point for retrieving the change document id
|
||||
* `gitChangeDocumentLabel` - A pattern used for identifying lines holding the change document id.
|
||||
* `gitFormat` - Specifies what part of the commit is scanned. By default the body of the commit message is scanned.
|
||||
|
||||
## Step configuration
|
||||
The following parameters can also be specified as step parameters using the global configuration file:
|
||||
|
||||
@@ -8,12 +8,15 @@ steps:
|
||||
timestampTemplate: '%Y%m%d%H%M%S'
|
||||
tagPrefix: 'build_'
|
||||
commitVersion: true
|
||||
maven:
|
||||
filePath: 'pom.xml'
|
||||
versioningTemplate: '${version}-${timestamp}${commitId?"_"+commitId:""}'
|
||||
docker:
|
||||
filePath: 'Dockerfile'
|
||||
versioningTemplate: '${version}-${timestamp}${commitId?"_"+commitId:""}'
|
||||
maven:
|
||||
filePath: 'pom.xml'
|
||||
versioningTemplate: '${version}-${timestamp}${commitId?"_"+commitId:""}'
|
||||
mta:
|
||||
filePath: 'mta.yaml'
|
||||
versioningTemplate: '${version}-${timestamp}${commitId?"+"+commitId:""}'
|
||||
checksPublishResults:
|
||||
aggregation:
|
||||
active: true
|
||||
@@ -92,7 +95,7 @@ steps:
|
||||
newmanCollection: '**/*.postman_collection.json'
|
||||
newmanEnvironment: ''
|
||||
newmanGlobals: ''
|
||||
newmanRunCommand: "run ${config.newmanCollection} --environment '${config.newmanEnvironment}' --globals '${config.newmanGlobals}' --reporters junit,html --reporter-junit-export target/newman/TEST-${config.newmanCollection.toString().replaceAll('/','_').tokenize('.').first()}.xml --reporter-html-export target/newman/TEST-${config.newmanCollection.toString().replaceAll('/','_').tokenize('.').first()}.html"
|
||||
newmanRunCommand: "run ${config.newmanCollection} --environment '${config.newmanEnvironment}' --globals '${config.newmanGlobals}' --reporters junit,html --reporter-junit-export target/newman/TEST-${config.newmanCollection.toString().replace(File.separatorChar,(char)'_').tokenize('.').first()}.xml --reporter-html-export target/newman/TEST-${config.newmanCollection.toString().replace(File.separatorChar,(char)'_').tokenize('.').first()}.html"
|
||||
pipelineStashFilesAfterBuild:
|
||||
runOpaTests: false
|
||||
stashIncludes:
|
||||
|
||||
@@ -42,13 +42,13 @@ public class ChangeManagement implements Serializable {
|
||||
return changeIds.get(0)
|
||||
}
|
||||
|
||||
boolean isChangeInDevelopment(String changeId, String endpoint, String username, String password, String cmclientOpts = '') {
|
||||
boolean isChangeInDevelopment(String changeId, String endpoint, String username, String password, String clientOpts = '') {
|
||||
|
||||
int rc = script.sh(returnStatus: true,
|
||||
script: getCMCommandLine(endpoint, username, password,
|
||||
'is-change-in-development', ['-cID', "'${changeId}'",
|
||||
'--return-code'],
|
||||
cmclientOpts))
|
||||
clientOpts))
|
||||
|
||||
if(rc == 0) {
|
||||
return true
|
||||
@@ -72,13 +72,14 @@ public class ChangeManagement implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
void uploadFileToTransportRequest(String changeId, String transportRequestId, String applicationId, String filePath, String endpoint, String username, String password) {
|
||||
void uploadFileToTransportRequest(String changeId, String transportRequestId, String applicationId, String filePath, String endpoint, String username, String password, String cmclientOpts = '') {
|
||||
|
||||
int rc = script.sh(returnStatus: true,
|
||||
script: getCMCommandLine(endpoint, username, password,
|
||||
'upload-file-to-transport', ['-cID', changeId,
|
||||
'-tID', transportRequestId,
|
||||
applicationId, filePath]))
|
||||
applicationId, filePath],
|
||||
cmclientOpts))
|
||||
|
||||
if(rc == 0) {
|
||||
return
|
||||
@@ -87,12 +88,13 @@ public class ChangeManagement implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
void releaseTransportRequest(String changeId, String transportRequestId, String endpoint, String username, String password) {
|
||||
void releaseTransportRequest(String changeId, String transportRequestId, String endpoint, String username, String password, String clientOpts = '') {
|
||||
|
||||
int rc = script.sh(returnStatus: true,
|
||||
script: getCMCommandLine(endpoint, username, password,
|
||||
'release-transport', ['-cID', changeId,
|
||||
'-tID', transportRequestId]))
|
||||
'-tID', transportRequestId],
|
||||
clientOpts))
|
||||
|
||||
if(rc == 0) {
|
||||
return
|
||||
@@ -106,11 +108,11 @@ public class ChangeManagement implements Serializable {
|
||||
String password,
|
||||
String command,
|
||||
List<String> args,
|
||||
String cmclientOpts = '') {
|
||||
String clientOpts = '') {
|
||||
String cmCommandLine = '#!/bin/bash'
|
||||
if(cmclientOpts) {
|
||||
if(clientOpts) {
|
||||
cmCommandLine += """
|
||||
export CMCLIENT_OPTS="${cmclientOpts}" """
|
||||
export CMCLIENT_OPTS="${clientOpts}" """
|
||||
}
|
||||
cmCommandLine += """
|
||||
cmclient -e '$endpoint' \
|
||||
|
||||
@@ -12,6 +12,8 @@ abstract class ArtifactVersioning implements Serializable {
|
||||
|
||||
public static getArtifactVersioning(buildTool, script, configuration) {
|
||||
switch (buildTool) {
|
||||
case 'mta':
|
||||
return new MtaArtifactVersioning(script, configuration)
|
||||
case 'maven':
|
||||
return new MavenArtifactVersioning(script, configuration)
|
||||
case 'docker':
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.sap.piper.versioning
|
||||
|
||||
class MtaArtifactVersioning extends ArtifactVersioning {
|
||||
|
||||
protected MtaArtifactVersioning (script, configuration) {
|
||||
super(script, configuration)
|
||||
}
|
||||
|
||||
@Override
|
||||
def getVersion() {
|
||||
def mtaYaml = script.readYaml file: configuration.filePath
|
||||
return mtaYaml.version
|
||||
}
|
||||
|
||||
@Override
|
||||
def setVersion(version) {
|
||||
def search = "version: ${getVersion()}"
|
||||
def replacement = "version: ${version}"
|
||||
script.sh "sed -i 's/${search}/${replacement}/g' ${configuration.filePath}"
|
||||
}
|
||||
}
|
||||
@@ -86,11 +86,11 @@ class NewmanExecuteTest extends BasePiperTest {
|
||||
void testExecuteNewmanWithFolder() throws Exception {
|
||||
jsr.step.newmanExecute(
|
||||
script: nullScript,
|
||||
newmanRunCommand: 'run ${config.newmanCollection} --iteration-data testDataFile --reporters junit,html --reporter-junit-export target/newman/TEST-${config.newmanCollection.toString().replaceAll(\'/\',\'_\').tokenize(\'.\').first()}.xml --reporter-html-export target/newman/TEST-${config.newmanCollection.toString().replaceAll(\'/\',\'_\').tokenize(\'.\').first()}.html'
|
||||
newmanRunCommand: 'run ${config.newmanCollection} --iteration-data testDataFile --reporters junit,html --reporter-junit-export target/newman/TEST-${config.newmanCollection.toString().replace(File.separatorChar,(char)\'_\').tokenize(\'.\').first()}.xml --reporter-html-export target/newman/TEST-${config.newmanCollection.toString().replace(File.separatorChar,(char)\'_\').tokenize(\'.\').first()}.html'
|
||||
)
|
||||
// asserts
|
||||
assertThat(jscr.shell, hasItem('newman run testCollectionsFolder/A.postman_collection.json --iteration-data testDataFile --reporters junit,html --reporter-junit-export target/newman/TEST-testCollectionsFolder_A.xml --reporter-html-export target/newman/TEST-testCollectionsFolder_A.html'))
|
||||
assertThat(jscr.shell, hasItem('newman run testCollectionsFolder/B.postman_collection.json --iteration-data testDataFile --reporters junit,html --reporter-junit-export target/newman/TEST-testCollectionsFolder_B.xml --reporter-html-export target/newman/TEST-testCollectionsFolder_B.html'))
|
||||
assertThat(jscr.shell, hasItem('newman run testCollectionsFolder'+File.separatorChar+'A.postman_collection.json --iteration-data testDataFile --reporters junit,html --reporter-junit-export target/newman/TEST-testCollectionsFolder_A.xml --reporter-html-export target/newman/TEST-testCollectionsFolder_A.html'))
|
||||
assertThat(jscr.shell, hasItem('newman run testCollectionsFolder'+File.separatorChar+'B.postman_collection.json --iteration-data testDataFile --reporters junit,html --reporter-junit-export target/newman/TEST-testCollectionsFolder_B.xml --reporter-html-export target/newman/TEST-testCollectionsFolder_B.html'))
|
||||
assertJobStatusSuccess()
|
||||
}
|
||||
}
|
||||
@@ -61,10 +61,21 @@ public class TransportRequestCreateTest extends BasePiperTest {
|
||||
@Test
|
||||
public void changeIdNotProvidedTest() {
|
||||
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("Change document id not provided (parameter: 'changeDocumentId').")
|
||||
ChangeManagement cm = new ChangeManagement(nullScript) {
|
||||
String getChangeDocumentId(
|
||||
String from,
|
||||
String to,
|
||||
String label,
|
||||
String format
|
||||
) {
|
||||
throw new ChangeManagementException('Cannot retrieve changeId from git commits.')
|
||||
}
|
||||
}
|
||||
|
||||
jsr.step.call(script: nullScript, developmentSystemId: '001')
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("Change document id not provided (parameter: 'changeDocumentId' or via commit history).")
|
||||
|
||||
jsr.step.call(script: nullScript, developmentSystemId: '001', cmUtils: cm)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -114,7 +114,8 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
String filePath,
|
||||
String endpoint,
|
||||
String username,
|
||||
String password) {
|
||||
String password,
|
||||
String cmclientOpts) {
|
||||
throw new ChangeManagementException('Exception message')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.sap.piper.versioning
|
||||
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.RuleChain
|
||||
import util.BasePiperTest
|
||||
import util.JenkinsReadYamlRule
|
||||
import util.JenkinsShellCallRule
|
||||
import util.Rules
|
||||
|
||||
import static org.junit.Assert.assertEquals
|
||||
|
||||
class MtaArtifactVersioningTest extends BasePiperTest{
|
||||
|
||||
JenkinsReadYamlRule jryr = new JenkinsReadYamlRule(this, 'test/resources/versioning/MtaArtifactVersioning/')
|
||||
JenkinsShellCallRule jscr = new JenkinsShellCallRule(this)
|
||||
|
||||
@Rule
|
||||
public RuleChain ruleChain = Rules
|
||||
.getCommonRules(this)
|
||||
.around(jryr)
|
||||
.around(jscr)
|
||||
|
||||
@Test
|
||||
void testVersioning() {
|
||||
MtaArtifactVersioning av = new MtaArtifactVersioning(nullScript, [filePath: 'mta.yaml'])
|
||||
assertEquals('1.2.3', av.getVersion())
|
||||
av.setVersion('1.2.3-20180101')
|
||||
assertEquals("sed -i 's/version: 1.2.3/version: 1.2.3-20180101/g' mta.yaml", jscr.shell[0])
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,33 @@
|
||||
package util
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.rules.TestRule
|
||||
import org.junit.runner.Description
|
||||
import org.junit.runners.model.Statement
|
||||
|
||||
import static org.hamcrest.Matchers.containsString
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.hamcrest.Matchers
|
||||
|
||||
class JenkinsLoggingRule implements TestRule {
|
||||
|
||||
final BasePipelineTest testInstance
|
||||
|
||||
def expected = []
|
||||
|
||||
String log = ""
|
||||
|
||||
JenkinsLoggingRule(BasePipelineTest testInstance) {
|
||||
this.testInstance = testInstance
|
||||
}
|
||||
|
||||
public void expect(String substring) {
|
||||
expected.add(substring)
|
||||
}
|
||||
|
||||
@Override
|
||||
Statement apply(Statement base, Description description) {
|
||||
return statement(base)
|
||||
@@ -30,7 +43,30 @@ class JenkinsLoggingRule implements TestRule {
|
||||
log += "$echoInput \n"
|
||||
})
|
||||
|
||||
base.evaluate()
|
||||
Throwable caught
|
||||
|
||||
try {
|
||||
base.evaluate()
|
||||
} catch(Throwable thr) {
|
||||
caught = thr
|
||||
} finally {
|
||||
if(caught instanceof AssertionError) {
|
||||
// Be polite, give other rules the advantage.
|
||||
// We expect other rules located closer to the test case
|
||||
// to throw an AssertionError in case of a violation.
|
||||
throw caught
|
||||
}
|
||||
|
||||
expected.each { substring -> assertThat("Substring '${substring}' not contained in log.",
|
||||
log,
|
||||
containsString(substring)) }
|
||||
|
||||
if(caught != null) {
|
||||
// do not swallow, so that other rules located farer away
|
||||
// to the test case can react
|
||||
throw caught
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ import org.junit.runners.model.Statement
|
||||
import org.yaml.snakeyaml.Yaml
|
||||
|
||||
class JenkinsReadYamlRule implements TestRule {
|
||||
|
||||
final BasePipelineTest testInstance
|
||||
final String testRoot
|
||||
|
||||
|
||||
JenkinsReadYamlRule(BasePipelineTest testInstance) {
|
||||
JenkinsReadYamlRule(BasePipelineTest testInstance, testRoot = '') {
|
||||
this.testInstance = testInstance
|
||||
this.testRoot = testRoot
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,7 +29,7 @@ class JenkinsReadYamlRule implements TestRule {
|
||||
if(m.text) {
|
||||
return new Yaml().load(m.text)
|
||||
} else if(m.file) {
|
||||
return new Yaml().load((m.file as File).text)
|
||||
return new Yaml().load(("${this.testRoot}${m.file}" as File).text)
|
||||
} else {
|
||||
throw new IllegalArgumentException("Key 'text' is missing in map ${m}.")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
_schema-version: "2.0"
|
||||
ID: com.sap.samples.anything
|
||||
version: 1.2.3
|
||||
|
||||
modules:
|
||||
- name: any-ui
|
||||
type: html5
|
||||
path: any-ui/
|
||||
|
||||
resources:
|
||||
- name: any-resource
|
||||
@@ -2,6 +2,7 @@ import com.sap.piper.GitUtils
|
||||
import groovy.transform.Field
|
||||
import hudson.AbortException
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.ConfigurationMerger
|
||||
import com.sap.piper.cm.ChangeManagement
|
||||
import com.sap.piper.cm.ChangeManagementException
|
||||
@@ -32,19 +33,25 @@ import com.sap.piper.cm.ChangeManagementException
|
||||
'gitFormat'
|
||||
]
|
||||
|
||||
@Field Set generalConfigurationKeys = stepConfigurationKeys
|
||||
|
||||
def call(parameters = [:]) {
|
||||
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
|
||||
prepareDefaultValues script: this
|
||||
def script = parameters.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
|
||||
GitUtils gitUtils = parameters?.gitUtils ?: new GitUtils()
|
||||
|
||||
ChangeManagement cm = parameters?.cmUtils ?: new ChangeManagement(parameters.script, gitUtils)
|
||||
ChangeManagement cm = parameters?.cmUtils ?: new ChangeManagement(script, gitUtils)
|
||||
|
||||
Map configuration = ConfigurationMerger.merge(parameters.script, STEP_NAME,
|
||||
parameters, parameterKeys,
|
||||
stepConfigurationKeys)
|
||||
Map configuration = ConfigurationHelper
|
||||
.loadStepDefaults(this)
|
||||
.mixinGeneralConfig(script.commonPipelineEnvironment, generalConfigurationKeys)
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
|
||||
.mixin(parameters, parameterKeys)
|
||||
.use()
|
||||
|
||||
def changeId = configuration.changeDocumentId
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import com.sap.piper.GitUtils
|
||||
import groovy.transform.Field
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.ConfigurationMerger
|
||||
import com.sap.piper.cm.ChangeManagement
|
||||
import com.sap.piper.cm.ChangeManagementException
|
||||
@@ -15,15 +16,25 @@ import hudson.AbortException
|
||||
'clientOpts',
|
||||
'developmentSystemId',
|
||||
'credentialsId',
|
||||
'endpoint'
|
||||
'endpoint',
|
||||
'gitFrom',
|
||||
'gitTo',
|
||||
'gitChangeDocumentLabel',
|
||||
'gitFormat'
|
||||
]
|
||||
|
||||
@Field Set stepConfigurationKeys = [
|
||||
'credentialsId',
|
||||
'clientOpts',
|
||||
'endpoint'
|
||||
'endpoint',
|
||||
'gitFrom',
|
||||
'gitTo',
|
||||
'gitChangeDocumentLabel',
|
||||
'gitFormat'
|
||||
]
|
||||
|
||||
@Field generalConfigurationKeys = stepConfigurationKeys
|
||||
|
||||
def call(parameters = [:]) {
|
||||
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
@@ -32,12 +43,42 @@ def call(parameters = [:]) {
|
||||
|
||||
ChangeManagement cm = parameters.cmUtils ?: new ChangeManagement(script)
|
||||
|
||||
Map configuration = ConfigurationMerger.merge(parameters.script, STEP_NAME,
|
||||
parameters, parameterKeys,
|
||||
stepConfigurationKeys)
|
||||
Map configuration = ConfigurationHelper
|
||||
.loadStepDefaults(this)
|
||||
.mixinGeneralConfig(script.commonPipelineEnvironment, generalConfigurationKeys)
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
|
||||
.mixin(parameters, parameterKeys)
|
||||
.use()
|
||||
|
||||
def changeDocumentId = configuration.changeDocumentId
|
||||
if(!changeDocumentId) throw new AbortException('Change document id not provided (parameter: \'changeDocumentId\').')
|
||||
|
||||
if(changeDocumentId?.trim()) {
|
||||
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from parameters."
|
||||
|
||||
} else {
|
||||
|
||||
echo "[INFO] Retrieving ChangeDocumentId from commit history [from: ${configuration.gitFrom}, to: ${configuration.gitTo}]." +
|
||||
"Searching for pattern '${configuration.gitChangeDocumentLabel}'. Searching with format '${configuration.gitFormat}'."
|
||||
|
||||
try {
|
||||
changeDocumentId = cm.getChangeDocumentId(
|
||||
configuration.gitFrom,
|
||||
configuration.gitTo,
|
||||
configuration.gitChangeDocumentLabel,
|
||||
configuration.gitFormat
|
||||
)
|
||||
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from commit history"
|
||||
} catch(ChangeManagementException ex) {
|
||||
echo "[WARN] Cannot retrieve changeDocumentId from commit history: ${ex.getMessage()}."
|
||||
}
|
||||
}
|
||||
|
||||
if(! changeDocumentId?.trim()) {
|
||||
throw new AbortException("Change document id not provided (parameter: \'changeDocumentId\' or via commit history).")
|
||||
}
|
||||
|
||||
def developmentSystemId = configuration.developmentSystemId
|
||||
if(!developmentSystemId) throw new AbortException('Development system id not provided (parameter: \'developmentSystemId\').')
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import com.sap.piper.GitUtils
|
||||
import groovy.transform.Field
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.ConfigurationMerger
|
||||
import com.sap.piper.cm.ChangeManagement
|
||||
import com.sap.piper.cm.ChangeManagementException
|
||||
@@ -12,6 +13,7 @@ import hudson.AbortException
|
||||
|
||||
@Field Set parameterKeys = [
|
||||
'changeDocumentId',
|
||||
'cmClientOpts',
|
||||
'transportRequestId',
|
||||
'credentialsId',
|
||||
'endpoint'
|
||||
@@ -19,9 +21,12 @@ import hudson.AbortException
|
||||
|
||||
@Field Set stepConfigurationKeys = [
|
||||
'credentialsId',
|
||||
'cmClientOpts',
|
||||
'endpoint'
|
||||
]
|
||||
|
||||
@Field Set generalConfigurationKeys = stepConfigurationKeys
|
||||
|
||||
def call(parameters = [:]) {
|
||||
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
@@ -30,9 +35,13 @@ def call(parameters = [:]) {
|
||||
|
||||
ChangeManagement cm = new ChangeManagement(script)
|
||||
|
||||
Map configuration = ConfigurationMerger.merge(script, STEP_NAME,
|
||||
parameters, parameterKeys,
|
||||
stepConfigurationKeys)
|
||||
Map configuration = ConfigurationHelper
|
||||
.loadStepDefaults(this)
|
||||
.mixinGeneralConfig(script.commonPipelineEnvironment, generalConfigurationKeys)
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
|
||||
.mixin(parameters, parameterKeys)
|
||||
.use()
|
||||
|
||||
def changeDocumentId = configuration.changeDocumentId
|
||||
if(!changeDocumentId) throw new AbortException("Change document id not provided (parameter: 'changeDocumentId').")
|
||||
@@ -54,7 +63,7 @@ def call(parameters = [:]) {
|
||||
usernameVariable: 'username')]) {
|
||||
|
||||
try {
|
||||
cm.releaseTransportRequest(changeDocumentId, transportRequestId, endpoint, username, password)
|
||||
cm.releaseTransportRequest(changeDocumentId, transportRequestId, endpoint, username, password, configuration.cmClientOpts)
|
||||
} catch(ChangeManagementException ex) {
|
||||
throw new AbortException(ex.getMessage())
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import com.sap.piper.GitUtils
|
||||
import groovy.transform.Field
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.ConfigurationMerger
|
||||
import com.sap.piper.cm.ChangeManagement
|
||||
import com.sap.piper.cm.ChangeManagementException
|
||||
@@ -12,6 +13,7 @@ import hudson.AbortException
|
||||
|
||||
@Field Set parameterKeys = [
|
||||
'changeDocumentId',
|
||||
'cmClientOpts',
|
||||
'transportRequestId',
|
||||
'applicationId',
|
||||
'filePath',
|
||||
@@ -25,6 +27,7 @@ import hudson.AbortException
|
||||
|
||||
@Field Set generalConfigurationKeys = [
|
||||
'credentialsId',
|
||||
'cmClientOpts',
|
||||
'endpoint',
|
||||
'gitFrom',
|
||||
'gitTo',
|
||||
@@ -32,6 +35,8 @@ import hudson.AbortException
|
||||
'gitFormat'
|
||||
]
|
||||
|
||||
@Field Set stepConfigurationKeys = generalConfigurationKeys
|
||||
|
||||
def call(parameters = [:]) {
|
||||
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
@@ -40,9 +45,13 @@ def call(parameters = [:]) {
|
||||
|
||||
ChangeManagement cm = parameters.cmUtils ?: new ChangeManagement(script)
|
||||
|
||||
Map configuration = ConfigurationMerger.merge(parameters.script, STEP_NAME,
|
||||
parameters, parameterKeys,
|
||||
generalConfigurationKeys)
|
||||
Map configuration = ConfigurationHelper
|
||||
.loadStepDefaults(this)
|
||||
.mixinGeneralConfig(script.commonPipelineEnvironment, generalConfigurationKeys)
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
|
||||
.mixin(parameters, parameterKeys)
|
||||
.use()
|
||||
|
||||
def changeDocumentId = configuration.changeDocumentId
|
||||
|
||||
@@ -97,7 +106,7 @@ def call(parameters = [:]) {
|
||||
usernameVariable: 'username')]) {
|
||||
|
||||
try {
|
||||
cm.uploadFileToTransportRequest(changeDocumentId, transportRequestId, applicationId, filePath, endpoint, username, password)
|
||||
cm.uploadFileToTransportRequest(changeDocumentId, transportRequestId, applicationId, filePath, endpoint, username, password, configuration.cmClientOpts)
|
||||
} catch(ChangeManagementException ex) {
|
||||
throw new AbortException(ex.getMessage())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user