From 0dd74fe68484215a212b4529e8be80dd5610808a Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Mon, 3 Sep 2018 13:08:42 +0200 Subject: [PATCH 1/9] GitUtils: provide method for checking worktree is clean. --- src/com/sap/piper/GitUtils.groovy | 17 ++++++++++ test/groovy/com/sap/piper/GitUtilsTest.groovy | 33 ++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/com/sap/piper/GitUtils.groovy b/src/com/sap/piper/GitUtils.groovy index cb41f911c..6271e73f7 100644 --- a/src/com/sap/piper/GitUtils.groovy +++ b/src/com/sap/piper/GitUtils.groovy @@ -4,6 +4,23 @@ boolean insideWorkTree() { return sh(returnStatus: true, script: 'git rev-parse --is-inside-work-tree 1>/dev/null 2>&1') == 0 } +boolean isWorkTreeDirty() { + + if(!insideWorkTree()) error 'Method \'isWorkTreeClean\' called outside a git work tree.' + + def gitCmd = 'git diff --quiet HEAD' + def rc = sh(returnStatus: true, script: gitCmd) + + // from git man page: + // "it exits with 1 if there were differences and 0 means no differences" + // + // in case of general git trouble, e.g. outside work tree this is indicated by + // a return code higher than 1. + if(rc == 0) return false + else if (rc == 1) return true + else error "git command '${gitCmd}' return with code '${rc}'. This indicates general trouble with git." +} + String getGitCommitIdOrNull() { if ( insideWorkTree() ) { return getGitCommitId() diff --git a/test/groovy/com/sap/piper/GitUtilsTest.groovy b/test/groovy/com/sap/piper/GitUtilsTest.groovy index cacd053fe..df9b1dc18 100644 --- a/test/groovy/com/sap/piper/GitUtilsTest.groovy +++ b/test/groovy/com/sap/piper/GitUtilsTest.groovy @@ -1,5 +1,6 @@ package com.sap.piper +import hudson.AbortException import org.junit.Before import org.junit.Rule import org.junit.Test @@ -44,6 +45,36 @@ class GitUtilsTest extends BasePiperTest { assertFalse(gitUtils.insideWorkTree()) } + @Test + void testWorkTreeDirty() { + jscr.setReturnValue('git rev-parse --is-inside-work-tree 1>/dev/null 2>&1', 0) + jscr.setReturnValue('git diff --quiet HEAD', 0) + assertFalse(gitUtils.isWorkTreeDirty()) + } + + @Test + void testWorkTreeDirtyOutsideWorktree() { + thrown.expect(AbortException) + thrown.expectMessage('Method \'isWorkTreeClean\' called outside a git work tree.') + jscr.setReturnValue('git rev-parse --is-inside-work-tree 1>/dev/null 2>&1', 1) + gitUtils.isWorkTreeDirty() + } + + @Test + void testWorkTreeNotDirty() { + jscr.setReturnValue('git rev-parse --is-inside-work-tree 1>/dev/null 2>&1', 0) + jscr.setReturnValue('git diff --quiet HEAD', 1) + assertTrue(gitUtils.isWorkTreeDirty()) + } + + @Test + void testWorkTreeDirtyGeneralGitTrouble() { + thrown.expect(AbortException) + thrown.expectMessage('git command \'git diff --quiet HEAD\' return with code \'129\'. This indicates general trouble with git.') + jscr.setReturnValue('git rev-parse --is-inside-work-tree 1>/dev/null 2>&1', 0) + jscr.setReturnValue('git diff --quiet HEAD', 129) // e.g. when called outside work tree + gitUtils.isWorkTreeDirty() + } @Test void testGetGitCommitId() { @@ -90,5 +121,5 @@ class GitUtilsTest extends BasePiperTest { String[] log = gitUtils.extractLogLines('xyz') assertNotNull(log) assertThat(log.size(),is(equalTo(0))) - } + } } From 23c838d6f180924d62cade3d24f78879254d9522 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Mon, 3 Sep 2018 13:09:12 +0200 Subject: [PATCH 2/9] [refactoring] artifact set version: check for clean worktree --- vars/artifactSetVersion.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/artifactSetVersion.groovy b/vars/artifactSetVersion.groovy index 43c3b7d6a..dc7759fca 100644 --- a/vars/artifactSetVersion.groovy +++ b/vars/artifactSetVersion.groovy @@ -32,7 +32,7 @@ def call(Map parameters = [:], Closure body = null) { def gitUtils = parameters.juStabGitUtils ?: new GitUtils() if (gitUtils.insideWorkTree()) { - if (sh(returnStatus: true, script: 'git diff --quiet HEAD') != 0) + if (gitUtils.isWorkTreeDirty()) error "[${STEP_NAME}] Files in the workspace have been changed previously - aborting ${STEP_NAME}" } From 85376d951fff3e41617984b286ad120d6af4c303 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Thu, 13 Sep 2018 14:34:26 +0200 Subject: [PATCH 3/9] remove inside work tree check since this is implicitly checked by isWorkTreeDirty. --- vars/artifactSetVersion.groovy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vars/artifactSetVersion.groovy b/vars/artifactSetVersion.groovy index dc7759fca..14d94fc93 100644 --- a/vars/artifactSetVersion.groovy +++ b/vars/artifactSetVersion.groovy @@ -31,8 +31,7 @@ def call(Map parameters = [:], Closure body = null) { def gitUtils = parameters.juStabGitUtils ?: new GitUtils() - if (gitUtils.insideWorkTree()) { - if (gitUtils.isWorkTreeDirty()) + if (gitUtils.isWorkTreeDirty()) { error "[${STEP_NAME}] Files in the workspace have been changed previously - aborting ${STEP_NAME}" } From 0326dd5f8c3dbba98d441f4febdc529182a150bc Mon Sep 17 00:00:00 2001 From: Christopher Fenner Date: Wed, 7 Nov 2018 10:25:00 +0100 Subject: [PATCH 4/9] add config for CodeClimate code coverage reporting (#363) * add config for CodeClimate code coverage reporting * Update .travis.yml * Update .travis.yml * generate coverage report * Update .travis.yml * Update .travis.yml --- .travis.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5e736611f..9962d70a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,15 @@ jobs: include: - stage: Tests name: Unit Tests - script: mvn clean test --batch-mode - after_success: mvn -DrepoToken=$COVERALLS_REPO_TOKEN org.jacoco:jacoco-maven-plugin:report org.eluder.coveralls:coveralls-maven-plugin:report + before_script: + - curl -L --output cc-test-reporter https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 + - chmod +x ./cc-test-reporter + - ./cc-test-reporter before-build + script: mvn package --batch-mode + after_script: + - JACOCO_SOURCE_PATH="src vars test" ./cc-test-reporter format-coverage target/site/jacoco/jacoco.xml --input-type jacoco + - ./cc-test-reporter upload-coverage + - mvn -DrepoToken=$COVERALLS_REPO_TOKEN org.eluder.coveralls:coveralls-maven-plugin:report - stage: Docs name: Build From 5ec37170fc7529517b999e2716dfd8246e4566f7 Mon Sep 17 00:00:00 2001 From: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com> Date: Wed, 7 Nov 2018 10:39:30 +0100 Subject: [PATCH 5/9] cloudFoundryDeploy - blue-green plugin extensions (#355) * cloudFoundryDeploy - blue-green plugin extensions * support blue-green application cleanup with new plugin flag * enhance error reporting in case no app name is available * include PR feedback --- test/groovy/CloudFoundryDeployTest.groovy | 53 +++++++++++++++++++++-- vars/cloudFoundryDeploy.groovy | 9 ++-- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/test/groovy/CloudFoundryDeployTest.groovy b/test/groovy/CloudFoundryDeployTest.groovy index a22a76f50..a0ce33db2 100644 --- a/test/groovy/CloudFoundryDeployTest.groovy +++ b/test/groovy/CloudFoundryDeployTest.groovy @@ -125,7 +125,7 @@ class CloudFoundryDeployTest extends BasePiperTest { assertThat(jedr.dockerParams, hasEntry('dockerWorkspace', '/home/piper')) assertThat(jedr.dockerParams.dockerEnvVars, hasEntry('STATUS_CODE', "${200}")) assertThat(jscr.shell, hasItem(containsString('cf login -u "test_cf" -p \'********\' -a https://api.cf.eu10.hana.ondemand.com -o "testOrg" -s "testSpace"'))) - assertThat(jscr.shell, hasItem(containsString('cf push "testAppName" -f "test.yml"'))) + assertThat(jscr.shell, hasItem(containsString("cf push testAppName -f 'test.yml'"))) } @Test @@ -174,7 +174,7 @@ class CloudFoundryDeployTest extends BasePiperTest { assertThat(jedr.dockerParams, hasEntry('dockerWorkspace', '/home/piper')) assertThat(jedr.dockerParams.dockerEnvVars, hasEntry('STATUS_CODE', "${200}")) assertThat(jscr.shell, hasItem(containsString('cf login -u "test_cf" -p \'********\' -a https://api.cf.eu10.hana.ondemand.com -o "testOrg" -s "testSpace"'))) - assertThat(jscr.shell, hasItem(containsString('cf push "testAppName" -f "test.yml"'))) + assertThat(jscr.shell, hasItem(containsString("cf push testAppName -f 'test.yml'"))) } @Test @@ -197,7 +197,7 @@ class CloudFoundryDeployTest extends BasePiperTest { ]) // asserts assertThat(jscr.shell, hasItem(containsString('cf login -u "test_cf" -p \'********\' -a https://api.cf.eu10.hana.ondemand.com -o "testOrg" -s "testSpace"'))) - assertThat(jscr.shell, hasItem(containsString('cf push -f "test.yml"'))) + assertThat(jscr.shell, hasItem(containsString("cf push -f 'test.yml'"))) } @Test @@ -222,6 +222,53 @@ class CloudFoundryDeployTest extends BasePiperTest { ]) } + @Test + void testCfNativeBlueGreen() { + + jryr.registerYaml('test.yml', "applications: [[]]") + + jsr.step.cloudFoundryDeploy([ + script: nullScript, + juStabUtils: utils, + deployTool: 'cf_native', + deployType: 'blue-green', + cfOrg: 'testOrg', + cfSpace: 'testSpace', + cfCredentialsId: 'test_cfCredentialsId', + cfAppName: 'testAppName', + cfManifest: 'test.yml' + ]) + + assertThat(jedr.dockerParams, hasEntry('dockerImage', 's4sdk/docker-cf-cli')) + assertThat(jedr.dockerParams, hasEntry('dockerWorkspace', '/home/piper')) + + assertThat(jscr.shell, hasItem(containsString('cf login -u "test_cf" -p \'********\' -a https://api.cf.eu10.hana.ondemand.com -o "testOrg" -s "testSpace"'))) + assertThat(jscr.shell, hasItem(containsString("cf blue-green-deploy testAppName --delete-old-apps -f 'test.yml'"))) + } + + + @Test + void testCfNativeWithoutAppNameBlueGreen() { + + helper.registerAllowedMethod('fileExists', [String.class], { s -> return true }) + jryr.registerYaml('test.yml', "applications: [[]]") + + thrown.expect(hudson.AbortException) + thrown.expectMessage('[cloudFoundryDeploy] ERROR: Blue-green plugin requires app name to be passed (see https://github.com/bluemixgaragelondon/cf-blue-green-deploy/issues/27)') + + jsr.step.cloudFoundryDeploy([ + script: nullScript, + juStabUtils: utils, + deployTool: 'cf_native', + deployType: 'blue-green', + cfOrg: 'testOrg', + cfSpace: 'testSpace', + cfCredentialsId: 'test_cfCredentialsId', + cfManifest: 'test.yml' + ]) + } + + @Test void testMta() { jsr.step.cloudFoundryDeploy([ diff --git a/vars/cloudFoundryDeploy.groovy b/vars/cloudFoundryDeploy.groovy index 92efd122c..a206ee6af 100644 --- a/vars/cloudFoundryDeploy.groovy +++ b/vars/cloudFoundryDeploy.groovy @@ -126,6 +126,9 @@ def deployCfNative (config) { // check if appName is available if (config.cloudFoundry.appName == null || config.cloudFoundry.appName == '') { + if (config.deployType == 'blue-green') { + error "[${STEP_NAME}] ERROR: Blue-green plugin requires app name to be passed (see https://github.com/bluemixgaragelondon/cf-blue-green-deploy/issues/27)" + } if (fileExists(config.cloudFoundry.manifest)) { def manifest = readYaml file: config.cloudFoundry.manifest if (!manifest || !manifest.applications || !manifest.applications[0].name) @@ -141,11 +144,7 @@ def deployCfNative (config) { export HOME=${config.dockerWorkspace} cf login -u \"${username}\" -p '${password}' -a ${config.cloudFoundry.apiEndpoint} -o \"${config.cloudFoundry.org}\" -s \"${config.cloudFoundry.space}\" cf plugins - cf ${deployCommand} ${config.cloudFoundry.appName?"\"${config.cloudFoundry.appName}\"":''} -f \"${config.cloudFoundry.manifest}\" ${config.smokeTest}""" - def retVal = sh script: "cf app \"${config.cloudFoundry.appName}-old\"", returnStatus: true - if (retVal == 0) { - sh "cf delete \"${config.cloudFoundry.appName}-old\" -r -f" - } + cf ${deployCommand} ${config.cloudFoundry.appName?:''} ${config.deployType == 'blue-green'?'--delete-old-apps':''} -f '${config.cloudFoundry.manifest}' ${config.smokeTest}""" sh "cf logout" } } From ce362f4ae9750539e95c7553582c41126891b5f3 Mon Sep 17 00:00:00 2001 From: Christopher Fenner Date: Wed, 7 Nov 2018 11:37:18 +0100 Subject: [PATCH 6/9] correct usage of commonPipelineEnvironment (#369) --- vars/influxWriteData.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/influxWriteData.groovy b/vars/influxWriteData.groovy index 755efa61c..e1c323f69 100644 --- a/vars/influxWriteData.groovy +++ b/vars/influxWriteData.groovy @@ -33,7 +33,7 @@ void call(Map parameters = [:]) { .mixinStepConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS) .mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, STEP_CONFIG_KEYS) .mixin([ - artifactVersion: commonPipelineEnvironment.getArtifactVersion() + artifactVersion: script.commonPipelineEnvironment.getArtifactVersion() ]) .mixin(parameters, PARAMETER_KEYS) .use() From 10ec0473c1c47ef6e43fad51fe3051808040f2d5 Mon Sep 17 00:00:00 2001 From: Christopher Fenner Date: Wed, 7 Nov 2018 11:45:38 +0100 Subject: [PATCH 7/9] correct step invokation in tests (#368) * correct step invokation in tests * correct step invokation in tests * correct step invokation in tests --- template/StepTestTemplateTest.groovy | 2 +- test/groovy/ChecksPublishResultsTest.groovy | 28 +++++----- test/groovy/DurationMeasureTest.groovy | 2 +- test/groovy/InfluxWriteDataTest.groovy | 6 +- test/groovy/MtaBuildTest.groovy | 34 +++++------ test/groovy/NeoDeployTest.groovy | 56 +++++++++---------- test/groovy/PipelineExecuteTest.groovy | 6 +- .../PipelineStashFilesAfterBuildTest.groovy | 6 +- .../PipelineStashFilesBeforeBuildTest.groovy | 4 +- test/groovy/PrepareDefaultValuesTest.groovy | 16 +++--- .../SetupCommonPipelineEnvironmentTest.groovy | 4 +- test/groovy/ToolValidateTest.groovy | 32 +++++------ test/groovy/TransportRequestCreateTest.groovy | 12 ++-- .../groovy/TransportRequestReleaseTest.groovy | 10 ++-- .../TransportRequestUploadFileTest.groovy | 24 ++++---- 15 files changed, 121 insertions(+), 121 deletions(-) diff --git a/template/StepTestTemplateTest.groovy b/template/StepTestTemplateTest.groovy index 8d5c8f404..8f2cb936f 100644 --- a/template/StepTestTemplateTest.groovy +++ b/template/StepTestTemplateTest.groovy @@ -25,7 +25,7 @@ class StepTestTemplateTest extends BasePipelineTest { @Test void testStepTestTemplate() throws Exception { - jsr.step.call() + jsr.step.stepTestTemplate() // asserts assertTrue(true) assertJobStatusSuccess() diff --git a/test/groovy/ChecksPublishResultsTest.groovy b/test/groovy/ChecksPublishResultsTest.groovy index 49bd3ab78..c8af586cd 100644 --- a/test/groovy/ChecksPublishResultsTest.groovy +++ b/test/groovy/ChecksPublishResultsTest.groovy @@ -43,7 +43,7 @@ class ChecksPublishResultsTest extends BasePiperTest { @Test void testPublishWithDefaultSettings() throws Exception { - jsr.step.call(script: nullScript) + jsr.step.checksPublishResults(script: nullScript) assertTrue("AnalysisPublisher options not set", publisherStepOptions['AnalysisPublisher'] != null) // ensure nothing else is published @@ -56,7 +56,7 @@ class ChecksPublishResultsTest extends BasePiperTest { @Test void testPublishForJavaWithDefaultSettings() throws Exception { - jsr.step.call(script: nullScript, pmd: true, cpd: true, findbugs: true, checkstyle: true) + jsr.step.checksPublishResults(script: nullScript, pmd: true, cpd: true, findbugs: true, checkstyle: true) assertTrue("AnalysisPublisher options not set", publisherStepOptions['AnalysisPublisher'] != null) assertTrue("PmdPublisher options not set", publisherStepOptions['PmdPublisher'] != null) @@ -74,7 +74,7 @@ class ChecksPublishResultsTest extends BasePiperTest { @Test void testPublishForJavaScriptWithDefaultSettings() throws Exception { - jsr.step.call(script: nullScript, eslint: true) + jsr.step.checksPublishResults(script: nullScript, eslint: true) assertTrue("AnalysisPublisher options not set", publisherStepOptions['AnalysisPublisher'] != null) assertTrue("WarningsPublisher options not set", publisherStepOptions['WarningsPublisher'] != null) @@ -92,7 +92,7 @@ class ChecksPublishResultsTest extends BasePiperTest { @Test void testPublishForPythonWithDefaultSettings() throws Exception { - jsr.step.call(script: nullScript, pylint: true) + jsr.step.checksPublishResults(script: nullScript, pylint: true) assertTrue("AnalysisPublisher options not set", publisherStepOptions['AnalysisPublisher'] != null) assertTrue("WarningsPublisher options not set", publisherStepOptions['WarningsPublisher'] != null) @@ -111,7 +111,7 @@ class ChecksPublishResultsTest extends BasePiperTest { @Test void testPublishNothing() throws Exception { - jsr.step.call(script: nullScript, aggregation: false) + jsr.step.checksPublishResults(script: nullScript, aggregation: false) // ensure nothing is published assertTrue("AnalysisPublisher options not empty", publisherStepOptions['AnalysisPublisher'] == null) @@ -124,7 +124,7 @@ class ChecksPublishResultsTest extends BasePiperTest { @Test void testPublishNothingExplicitFalse() throws Exception { - jsr.step.call(script: nullScript, pmd: false) + jsr.step.checksPublishResults(script: nullScript, pmd: false) assertTrue("AnalysisPublisher options not set", publisherStepOptions['AnalysisPublisher'] != null) // ensure nothing else is published @@ -137,7 +137,7 @@ class ChecksPublishResultsTest extends BasePiperTest { @Test void testPublishNothingImplicitTrue() throws Exception { - jsr.step.call(script: nullScript, pmd: [:]) + jsr.step.checksPublishResults(script: nullScript, pmd: [:]) // ensure pmd is not published assertTrue("PmdPublisher options not set", publisherStepOptions['PmdPublisher'] != null) @@ -145,7 +145,7 @@ class ChecksPublishResultsTest extends BasePiperTest { @Test void testPublishNothingExplicitActiveFalse() throws Exception { - jsr.step.call(script: nullScript, pmd: [active: false]) + jsr.step.checksPublishResults(script: nullScript, pmd: [active: false]) // ensure pmd is not published assertTrue("PmdPublisher options not empty", publisherStepOptions['PmdPublisher'] == null) @@ -154,7 +154,7 @@ class ChecksPublishResultsTest extends BasePiperTest { @Test void testPublishWithChangedStepDefaultSettings() throws Exception { // pmd has been set to active: true in step configuration - jsr.step.call(script: [commonPipelineEnvironment: [ + jsr.step.checksPublishResults(script: [commonPipelineEnvironment: [ configuration: [steps: [checksPublishResults: [pmd: [active: true]]]] ]]) @@ -169,7 +169,7 @@ class ChecksPublishResultsTest extends BasePiperTest { @Test void testPublishWithCustomPattern() throws Exception { - jsr.step.call(script: nullScript, eslint: [pattern: 'my-fancy-file.ext'], pmd: [pattern: 'this-is-not-a-patter.xml']) + jsr.step.checksPublishResults(script: nullScript, eslint: [pattern: 'my-fancy-file.ext'], pmd: [pattern: 'this-is-not-a-patter.xml']) assertTrue("AnalysisPublisher options not set", publisherStepOptions['AnalysisPublisher'] != null) assertTrue("PmdPublisher options not set", publisherStepOptions['PmdPublisher'] != null) @@ -186,7 +186,7 @@ class ChecksPublishResultsTest extends BasePiperTest { @Test void testPublishWithArchive() throws Exception { - jsr.step.call(script: nullScript, archive: true, eslint: true, pmd: true, cpd: true, findbugs: true, checkstyle: true) + jsr.step.checksPublishResults(script: nullScript, archive: true, eslint: true, pmd: true, cpd: true, findbugs: true, checkstyle: true) assertTrue("ArchivePatterns number not correct", archiveStepPatterns.size() == 5) assertTrue("ArchivePatterns contains no PMD pattern", archiveStepPatterns.contains('**/target/pmd.xml')) @@ -198,7 +198,7 @@ class ChecksPublishResultsTest extends BasePiperTest { @Test void testPublishWithPartialArchive() throws Exception { - jsr.step.call(script: nullScript, archive: true, eslint: [archive: false], pmd: true, cpd: true, findbugs: true, checkstyle: true) + jsr.step.checksPublishResults(script: nullScript, archive: true, eslint: [archive: false], pmd: true, cpd: true, findbugs: true, checkstyle: true) assertTrue("ArchivePatterns number not correct", archiveStepPatterns.size() == 4) assertTrue("ArchivePatterns contains no PMD pattern", archiveStepPatterns.contains('**/target/pmd.xml')) @@ -211,7 +211,7 @@ class ChecksPublishResultsTest extends BasePiperTest { @Test void testPublishWithDefaultThresholds() throws Exception { - jsr.step.call(script: nullScript, pmd: true) + jsr.step.checksPublishResults(script: nullScript, pmd: true) assertTrue("AnalysisPublisher options not set", publisherStepOptions['AnalysisPublisher'] != null) @@ -245,7 +245,7 @@ class ChecksPublishResultsTest extends BasePiperTest { @Test void testPublishWithThresholds() throws Exception { - jsr.step.call(script: nullScript, aggregation: [thresholds: [fail: [high: '10']]], pmd: true) + jsr.step.checksPublishResults(script: nullScript, aggregation: [thresholds: [fail: [high: '10']]], pmd: true) assertTrue("AnalysisPublisher options not set", publisherStepOptions['AnalysisPublisher'] != null) assertTrue("PmdPublisher options not set", publisherStepOptions['PmdPublisher'] != null) diff --git a/test/groovy/DurationMeasureTest.groovy b/test/groovy/DurationMeasureTest.groovy index 17fade769..898094c5c 100644 --- a/test/groovy/DurationMeasureTest.groovy +++ b/test/groovy/DurationMeasureTest.groovy @@ -24,7 +24,7 @@ class DurationMeasureTest extends BasePiperTest { @Test void testDurationMeasurement() throws Exception { def bodyExecuted = false - jsr.step.call(script: nullScript, measurementName: 'test') { + jsr.step.durationMeasure(script: nullScript, measurementName: 'test') { bodyExecuted = true } assertTrue(nullScript.commonPipelineEnvironment.getPipelineMeasurement('test') != null) diff --git a/test/groovy/InfluxWriteDataTest.groovy b/test/groovy/InfluxWriteDataTest.groovy index e52d535da..49e80051f 100644 --- a/test/groovy/InfluxWriteDataTest.groovy +++ b/test/groovy/InfluxWriteDataTest.groovy @@ -55,7 +55,7 @@ class InfluxWriteDataTest extends BasePiperTest { void testInfluxWriteDataWithDefault() throws Exception { nullScript.commonPipelineEnvironment.setArtifactVersion('1.2.3') - jsr.step.call(script: nullScript) + jsr.step.influxWriteData(script: nullScript) assertTrue(loggingRule.log.contains('Artifact version: 1.2.3')) @@ -74,7 +74,7 @@ class InfluxWriteDataTest extends BasePiperTest { void testInfluxWriteDataNoInflux() throws Exception { nullScript.commonPipelineEnvironment.setArtifactVersion('1.2.3') - jsr.step.call(script: nullScript, influxServer: '') + jsr.step.influxWriteData(script: nullScript, influxServer: '') assertEquals(0, stepMap.size()) @@ -87,7 +87,7 @@ class InfluxWriteDataTest extends BasePiperTest { @Test void testInfluxWriteDataNoArtifactVersion() throws Exception { - jsr.step.call(script: nullScript) + jsr.step.influxWriteData(script: nullScript) assertEquals(0, stepMap.size()) assertEquals(0, fileMap.size()) diff --git a/test/groovy/MtaBuildTest.groovy b/test/groovy/MtaBuildTest.groovy index 2c83c8116..05b238846 100644 --- a/test/groovy/MtaBuildTest.groovy +++ b/test/groovy/MtaBuildTest.groovy @@ -50,7 +50,7 @@ public class MtaBuildTest extends BasePiperTest { @Test void environmentPathTest() { - jsr.step.call(script: nullScript, buildTarget: 'NEO') + jsr.step.mtaBuild(script: nullScript, buildTarget: 'NEO') assert jscr.shell.find { c -> c.contains('PATH=./node_modules/.bin:/usr/bin')} } @@ -59,7 +59,7 @@ public class MtaBuildTest extends BasePiperTest { @Test void sedTest() { - jsr.step.call(script: nullScript, buildTarget: 'NEO') + jsr.step.mtaBuild(script: nullScript, buildTarget: 'NEO') assert jscr.shell.find { c -> c =~ /sed -ie "s\/\\\$\{timestamp\}\/`date \+%Y%m%d%H%M%S`\/g" "mta.yaml"$/} } @@ -68,7 +68,7 @@ public class MtaBuildTest extends BasePiperTest { @Test void mtarFilePathFromCommonPipelineEnviromentTest() { - jsr.step.call(script: nullScript, + jsr.step.mtaBuild(script: nullScript, buildTarget: 'NEO') def mtarFilePath = nullScript.commonPipelineEnvironment.getMtarFilePath() @@ -79,7 +79,7 @@ public class MtaBuildTest extends BasePiperTest { @Test void mtaJarLocationAsParameterTest() { - jsr.step.call(script: nullScript, mtaJarLocation: '/mylocation/mta/mta.jar', buildTarget: 'NEO') + jsr.step.mtaBuild(script: nullScript, mtaJarLocation: '/mylocation/mta/mta.jar', buildTarget: 'NEO') assert jscr.shell.find { c -> c.contains('-jar /mylocation/mta/mta.jar --mtar')} @@ -94,7 +94,7 @@ public class MtaBuildTest extends BasePiperTest { jryr.registerYaml('mta.yaml', { throw new FileNotFoundException() }) thrown.expect(FileNotFoundException) - jsr.step.call(script: nullScript, buildTarget: 'NEO') + jsr.step.mtaBuild(script: nullScript, buildTarget: 'NEO') } @@ -106,7 +106,7 @@ public class MtaBuildTest extends BasePiperTest { jryr.registerYaml('mta.yaml', badMtaYaml()) - jsr.step.call(script: nullScript, buildTarget: 'NEO') + jsr.step.mtaBuild(script: nullScript, buildTarget: 'NEO') } @@ -118,7 +118,7 @@ public class MtaBuildTest extends BasePiperTest { jryr.registerYaml('mta.yaml', noIdMtaYaml() ) - jsr.step.call(script: nullScript, buildTarget: 'NEO') + jsr.step.mtaBuild(script: nullScript, buildTarget: 'NEO') } @@ -127,7 +127,7 @@ public class MtaBuildTest extends BasePiperTest { helper.registerAllowedMethod('sh', [Map], { Map m -> getVersionWithEnvVars(m) }) - jsr.step.call(script: nullScript, buildTarget: 'NEO') + jsr.step.mtaBuild(script: nullScript, buildTarget: 'NEO') assert jscr.shell.find { c -> c.contains("-jar /env/mta/mta.jar --mtar")} assert jlr.log.contains("SAP Multitarget Application Archive Builder file '/env/mta/mta.jar' retrieved from environment.") @@ -140,7 +140,7 @@ public class MtaBuildTest extends BasePiperTest { nullScript.commonPipelineEnvironment.configuration = [steps:[mtaBuild:[mtaJarLocation: '/config/mta/mta.jar']]] - jsr.step.call(script: nullScript, + jsr.step.mtaBuild(script: nullScript, buildTarget: 'NEO') assert jscr.shell.find(){ c -> c.contains("-jar /config/mta/mta.jar --mtar")} @@ -152,7 +152,7 @@ public class MtaBuildTest extends BasePiperTest { @Test void mtaJarLocationFromDefaultStepConfigurationTest() { - jsr.step.call(script: nullScript, + jsr.step.mtaBuild(script: nullScript, buildTarget: 'NEO') assert jscr.shell.find(){ c -> c.contains("-jar mta.jar --mtar")} @@ -164,7 +164,7 @@ public class MtaBuildTest extends BasePiperTest { @Test void buildTargetFromParametersTest() { - jsr.step.call(script: nullScript, buildTarget: 'NEO') + jsr.step.mtaBuild(script: nullScript, buildTarget: 'NEO') assert jscr.shell.find { c -> c.contains('java -jar mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO build')} } @@ -175,7 +175,7 @@ public class MtaBuildTest extends BasePiperTest { nullScript.commonPipelineEnvironment.configuration = [steps:[mtaBuild:[buildTarget: 'NEO']]] - jsr.step.call(script: nullScript) + jsr.step.mtaBuild(script: nullScript) assert jscr.shell.find(){ c -> c.contains('java -jar mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO build')} } @@ -183,7 +183,7 @@ public class MtaBuildTest extends BasePiperTest { @Test void canConfigureDockerImage() { - jsr.step.call(script: nullScript, dockerImage: 'mta-docker-image:latest') + jsr.step.mtaBuild(script: nullScript, dockerImage: 'mta-docker-image:latest') assert 'mta-docker-image:latest' == jder.dockerParams.dockerImage } @@ -191,7 +191,7 @@ public class MtaBuildTest extends BasePiperTest { @Test void canConfigureDockerOptions() { - jsr.step.call(script: nullScript, dockerOptions: 'something') + jsr.step.mtaBuild(script: nullScript, dockerOptions: 'something') assert 'something' == jder.dockerParams.dockerOptions } @@ -201,7 +201,7 @@ public class MtaBuildTest extends BasePiperTest { nullScript.commonPipelineEnvironment.defaultConfiguration = [steps:[mtaBuild:[buildTarget: 'NEO']]] - jsr.step.call(script: nullScript) + jsr.step.mtaBuild(script: nullScript) assert jscr.shell.find { c -> c.contains('java -jar mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO build')} } @@ -210,7 +210,7 @@ public class MtaBuildTest extends BasePiperTest { @Test void extensionFromParametersTest() { - jsr.step.call(script: nullScript, buildTarget: 'NEO', extension: 'param_extension') + jsr.step.mtaBuild(script: nullScript, buildTarget: 'NEO', extension: 'param_extension') assert jscr.shell.find { c -> c.contains('java -jar mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO --extension=param_extension build')} } @@ -221,7 +221,7 @@ public class MtaBuildTest extends BasePiperTest { nullScript.commonPipelineEnvironment.configuration = [steps:[mtaBuild:[buildTarget: 'NEO', extension: 'config_extension']]] - jsr.step.call(script: nullScript) + jsr.step.mtaBuild(script: nullScript) assert jscr.shell.find(){ c -> c.contains('java -jar mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO --extension=config_extension build')} } diff --git a/test/groovy/NeoDeployTest.groovy b/test/groovy/NeoDeployTest.groovy index 3e6841981..31f02581f 100644 --- a/test/groovy/NeoDeployTest.groovy +++ b/test/groovy/NeoDeployTest.groovy @@ -85,7 +85,7 @@ class NeoDeployTest extends BasePiperTest { nullScript.commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'trialuser123') nullScript.commonPipelineEnvironment.configuration = [:] - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: archiveName, neoCredentialsId: 'myCredentialsId' ) @@ -103,7 +103,7 @@ class NeoDeployTest extends BasePiperTest { @Test void straightForwardTestConfigViaConfiguration() { - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: archiveName, neoCredentialsId: 'myCredentialsId' ) @@ -127,7 +127,7 @@ class NeoDeployTest extends BasePiperTest { nullScript.commonPipelineEnvironment.configuration = [steps:[neoDeploy: [host: 'configuration-frwk.deploy.host.com', account: 'configurationFrwkUser123']]] - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: archiveName, neoCredentialsId: 'myCredentialsId' ) @@ -145,7 +145,7 @@ class NeoDeployTest extends BasePiperTest { @Test void archivePathFromCPETest() { nullScript.commonPipelineEnvironment.setMtarFilePath('archive.mtar') - jsr.step.call(script: nullScript) + jsr.step.neoDeploy(script: nullScript) Assert.assertThat(jscr.shell, new CommandLineMatcher().hasProlog("#!/bin/bash \"/opt/neo/tools/neo.sh\" deploy-mta") @@ -155,7 +155,7 @@ class NeoDeployTest extends BasePiperTest { @Test void archivePathFromParamsHasHigherPrecedenceThanCPETest() { nullScript.commonPipelineEnvironment.setMtarFilePath('archive2.mtar') - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: "archive.mtar") Assert.assertThat(jscr.shell, @@ -169,7 +169,7 @@ class NeoDeployTest extends BasePiperTest { thrown.expect(CredentialNotFoundException) - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: archiveName, neoCredentialsId: 'badCredentialsId' ) @@ -179,7 +179,7 @@ class NeoDeployTest extends BasePiperTest { @Test void credentialsIdNotProvidedTest() { - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: archiveName ) @@ -199,7 +199,7 @@ class NeoDeployTest extends BasePiperTest { helper.registerAllowedMethod('sh', [Map], { Map m -> getVersionWithPath(m) }) - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: archiveName ) @@ -214,7 +214,7 @@ class NeoDeployTest extends BasePiperTest { helper.registerAllowedMethod('sh', [Map], { Map m -> getVersionWithPath(m) }) - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: archiveName, neoCredentialsId: 'myCredentialsId', neoHome: '/param/neo' @@ -229,7 +229,7 @@ class NeoDeployTest extends BasePiperTest { @Test void neoHomeFromEnvironmentTest() { - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: archiveName ) @@ -246,7 +246,7 @@ class NeoDeployTest extends BasePiperTest { nullScript.commonPipelineEnvironment.configuration = [steps:[neoDeploy: [host: 'test.deploy.host.com', account: 'trialuser123', neoHome: '/config/neo']]] - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: archiveName ) @@ -262,7 +262,7 @@ class NeoDeployTest extends BasePiperTest { thrown.expect(Exception) thrown.expectMessage('Archive path not configured (parameter "archivePath").') - jsr.step.call(script: nullScript) + jsr.step.neoDeploy(script: nullScript) } @@ -272,7 +272,7 @@ class NeoDeployTest extends BasePiperTest { thrown.expect(AbortException) thrown.expectMessage('Archive cannot be found') - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: 'wrongArchiveName') } @@ -285,13 +285,13 @@ class NeoDeployTest extends BasePiperTest { nullScript.commonPipelineEnvironment.configuration = [:] - jsr.step.call(script: nullScript, archivePath: archiveName) + jsr.step.neoDeploy(script: nullScript, archivePath: archiveName) } @Test void mtaDeployModeTest() { - jsr.step.call(script: nullScript, archivePath: archiveName, deployMode: 'mta') + jsr.step.neoDeploy(script: nullScript, archivePath: archiveName, deployMode: 'mta') Assert.assertThat(jscr.shell, new CommandLineMatcher().hasProlog("#!/bin/bash \"/opt/neo/tools/neo.sh\" deploy-mta") @@ -307,7 +307,7 @@ class NeoDeployTest extends BasePiperTest { @Test void warFileParamsDeployModeTest() { - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, applicationName: 'testApp', runtime: 'neo-javaee6-wp', runtimeVersion: '2.125', @@ -333,7 +333,7 @@ class NeoDeployTest extends BasePiperTest { @Test void warFileParamsDeployModeRollingUpdateTest() { - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: warArchiveName, deployMode: 'warParams', applicationName: 'testApp', @@ -358,7 +358,7 @@ class NeoDeployTest extends BasePiperTest { @Test void warPropertiesFileDeployModeTest() { - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: warArchiveName, deployMode: 'warPropertiesFile', propertiesFile: propertiesFileName, @@ -379,7 +379,7 @@ class NeoDeployTest extends BasePiperTest { @Test void warPropertiesFileDeployModeRollingUpdateTest() { - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: warArchiveName, deployMode: 'warPropertiesFile', propertiesFile: propertiesFileName, @@ -403,7 +403,7 @@ class NeoDeployTest extends BasePiperTest { thrown.expect(Exception) thrown.expectMessage('ERROR - NO VALUE AVAILABLE FOR applicationName') - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: warArchiveName, deployMode: 'warParams', runtime: 'neo-javaee6-wp', @@ -417,7 +417,7 @@ class NeoDeployTest extends BasePiperTest { thrown.expect(Exception) thrown.expectMessage('ERROR - NO VALUE AVAILABLE FOR runtime') - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: warArchiveName, applicationName: 'testApp', deployMode: 'warParams', @@ -430,7 +430,7 @@ class NeoDeployTest extends BasePiperTest { thrown.expect(Exception) thrown.expectMessage('ERROR - NO VALUE AVAILABLE FOR runtimeVersion') - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: warArchiveName, applicationName: 'testApp', deployMode: 'warParams', @@ -443,7 +443,7 @@ class NeoDeployTest extends BasePiperTest { thrown.expect(Exception) thrown.expectMessage("[neoDeploy] Invalid deployMode = 'illegalMode'. Valid 'deployMode' values are: [mta, warParams, warPropertiesFile]") - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: warArchiveName, deployMode: 'illegalMode', applicationName: 'testApp', @@ -459,7 +459,7 @@ class NeoDeployTest extends BasePiperTest { thrown.expect(Exception) thrown.expectMessage("[neoDeploy] Invalid vmSize = 'illegalVM'. Valid 'vmSize' values are: [lite, pro, prem, prem-plus].") - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: warArchiveName, deployMode: 'warParams', applicationName: 'testApp', @@ -475,7 +475,7 @@ class NeoDeployTest extends BasePiperTest { thrown.expect(Exception) thrown.expectMessage("[neoDeploy] Invalid warAction = 'illegalWARAction'. Valid 'warAction' values are: [deploy, rolling-update].") - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: warArchiveName, deployMode: 'warParams', applicationName: 'testApp', @@ -490,7 +490,7 @@ class NeoDeployTest extends BasePiperTest { nullScript.commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'configPropsUser123') - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: archiveName, deployHost: "my.deploy.host.com" ) @@ -503,7 +503,7 @@ class NeoDeployTest extends BasePiperTest { nullScript.commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'configPropsUser123') - jsr.step.call(script: nullScript, + jsr.step.neoDeploy(script: nullScript, archivePath: archiveName, host: "my.deploy.host.com", deployAccount: "myAccount" @@ -600,7 +600,7 @@ class NeoDeployTest extends BasePiperTest { this.opts.add(new MapEntry(key, value)) return this } - + CommandLineMatcher hasArgument(String arg) { this.args.add(arg) return this diff --git a/test/groovy/PipelineExecuteTest.groovy b/test/groovy/PipelineExecuteTest.groovy index b1db7ef0c..f2de200b4 100644 --- a/test/groovy/PipelineExecuteTest.groovy +++ b/test/groovy/PipelineExecuteTest.groovy @@ -44,7 +44,7 @@ class PipelineExecuteTest extends BasePiperTest { @Test void straightForwardTest() { - jsr.step.call(repoUrl: "https://test.com/myRepo.git") + jsr.step.pipelineExecute(repoUrl: "https://test.com/myRepo.git") assert load == "Jenkinsfile" assert checkoutParameters.branch == 'master' assert checkoutParameters.repoUrl == "https://test.com/myRepo.git" @@ -55,7 +55,7 @@ class PipelineExecuteTest extends BasePiperTest { @Test void parameterizeTest() { - jsr.step.call(repoUrl: "https://test.com/anotherRepo.git", + jsr.step.pipelineExecute(repoUrl: "https://test.com/anotherRepo.git", branch: 'feature', path: 'path/to/Jenkinsfile', credentialsId: 'abcd1234') @@ -73,6 +73,6 @@ class PipelineExecuteTest extends BasePiperTest { thrown.expect(Exception) thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR repoUrl") - jsr.step.call() + jsr.step.pipelineExecute() } } diff --git a/test/groovy/PipelineStashFilesAfterBuildTest.groovy b/test/groovy/PipelineStashFilesAfterBuildTest.groovy index 370ad9d7f..bad2f439e 100644 --- a/test/groovy/PipelineStashFilesAfterBuildTest.groovy +++ b/test/groovy/PipelineStashFilesAfterBuildTest.groovy @@ -26,7 +26,7 @@ class PipelineStashFilesAfterBuildTest extends BasePiperTest { searchTerm -> return false }) - jsr.step.call( + jsr.step.pipelineStashFilesAfterBuild( script: nullScript, juStabUtils: utils ) @@ -42,7 +42,7 @@ class PipelineStashFilesAfterBuildTest extends BasePiperTest { searchTerm -> return true }) - jsr.step.call( + jsr.step.pipelineStashFilesAfterBuild( script: nullScript, juStabUtils: utils, runCheckmarx: true @@ -59,7 +59,7 @@ class PipelineStashFilesAfterBuildTest extends BasePiperTest { searchTerm -> return true }) - jsr.step.call( + jsr.step.pipelineStashFilesAfterBuild( script: [commonPipelineEnvironment: [configuration: [steps: [executeCheckmarxScan: [checkmarxProject: 'TestProject']]]]], juStabUtils: utils, ) diff --git a/test/groovy/PipelineStashFilesBeforeBuildTest.groovy b/test/groovy/PipelineStashFilesBeforeBuildTest.groovy index bd97eec6e..6b81bc4d7 100644 --- a/test/groovy/PipelineStashFilesBeforeBuildTest.groovy +++ b/test/groovy/PipelineStashFilesBeforeBuildTest.groovy @@ -24,7 +24,7 @@ class PipelineStashFilesBeforeBuildTest extends BasePiperTest { @Test void testStashBeforeBuildNoOpa() { - jsr.step.call(script: nullScript, juStabUtils: utils) + jsr.step.pipelineStashFilesBeforeBuild(script: nullScript, juStabUtils: utils) // asserts assertEquals('mkdir -p gitmetadata', jscr.shell[0]) @@ -44,7 +44,7 @@ class PipelineStashFilesBeforeBuildTest extends BasePiperTest { @Test void testStashBeforeBuildOpa() { - jsr.step.call(script: nullScript, juStabUtils: utils, runOpaTests: true) + jsr.step.pipelineStashFilesBeforeBuild(script: nullScript, juStabUtils: utils, runOpaTests: true) // asserts assertThat(jlr.log, containsString('Stash content: buildDescriptor')) diff --git a/test/groovy/PrepareDefaultValuesTest.groovy b/test/groovy/PrepareDefaultValuesTest.groovy index 6d9195f48..54a3cd56b 100644 --- a/test/groovy/PrepareDefaultValuesTest.groovy +++ b/test/groovy/PrepareDefaultValuesTest.groovy @@ -43,7 +43,7 @@ public class PrepareDefaultValuesTest extends BasePiperTest { @Test public void testDefaultPipelineEnvironmentOnly() { - jsr.step.call(script: nullScript) + jsr.step.prepareDefaultValues(script: nullScript) assert DefaultValueCache.getInstance().getDefaultValues().size() == 1 assert DefaultValueCache.getInstance().getDefaultValues().default == 'config' @@ -55,7 +55,7 @@ public class PrepareDefaultValuesTest extends BasePiperTest { def instance = DefaultValueCache.createInstance([key:'value']) // existing instance is dropped in case a custom config is provided. - jsr.step.call(script: nullScript, customDefaults: 'custom.yml') + jsr.step.prepareDefaultValues(script: nullScript, customDefaults: 'custom.yml') // this check is for checking we have another instance assert ! instance.is(DefaultValueCache.getInstance()) @@ -72,7 +72,7 @@ public class PrepareDefaultValuesTest extends BasePiperTest { def instance = DefaultValueCache.createInstance([key:'value']) - jsr.step.call(script: nullScript) + jsr.step.prepareDefaultValues(script: nullScript) assert instance.is(DefaultValueCache.getInstance()) assert DefaultValueCache.getInstance().getDefaultValues().size() == 1 @@ -86,13 +86,13 @@ public class PrepareDefaultValuesTest extends BasePiperTest { thrown.expect(hudson.AbortException.class) thrown.expectMessage('No such library resource not_found could be found') - jsr.step.call(script: nullScript, customDefaults: 'not_found') + jsr.step.prepareDefaultValues(script: nullScript, customDefaults: 'not_found') } @Test public void testDefaultPipelineEnvironmentWithCustomConfigReferencedAsString() { - jsr.step.call(script: nullScript, customDefaults: 'custom.yml') + jsr.step.prepareDefaultValues(script: nullScript, customDefaults: 'custom.yml') assert DefaultValueCache.getInstance().getDefaultValues().size() == 2 assert DefaultValueCache.getInstance().getDefaultValues().default == 'config' @@ -102,7 +102,7 @@ public class PrepareDefaultValuesTest extends BasePiperTest { @Test public void testDefaultPipelineEnvironmentWithCustomConfigReferencedAsList() { - jsr.step.call(script: nullScript, customDefaults: ['custom.yml']) + jsr.step.prepareDefaultValues(script: nullScript, customDefaults: ['custom.yml']) assert DefaultValueCache.getInstance().getDefaultValues().size() == 2 assert DefaultValueCache.getInstance().getDefaultValues().default == 'config' @@ -112,7 +112,7 @@ public class PrepareDefaultValuesTest extends BasePiperTest { @Test public void testAssertNoLogMessageInCaseOfNoAdditionalConfigFiles() { - jsr.step.call(script: nullScript) + jsr.step.prepareDefaultValues(script: nullScript) assert ! jlr.log.contains("Loading configuration file 'default_pipeline_environment.yml'") } @@ -120,7 +120,7 @@ public class PrepareDefaultValuesTest extends BasePiperTest { @Test public void testAssertLogMessageInCaseOfMoreThanOneConfigFile() { - jsr.step.call(script: nullScript, customDefaults: ['custom.yml']) + jsr.step.prepareDefaultValues(script: nullScript, customDefaults: ['custom.yml']) assert jlr.log.contains("Loading configuration file 'default_pipeline_environment.yml'") assert jlr.log.contains("Loading configuration file 'custom.yml'") diff --git a/test/groovy/SetupCommonPipelineEnvironmentTest.groovy b/test/groovy/SetupCommonPipelineEnvironmentTest.groovy index 39531f519..528badbd3 100644 --- a/test/groovy/SetupCommonPipelineEnvironmentTest.groovy +++ b/test/groovy/SetupCommonPipelineEnvironmentTest.groovy @@ -55,7 +55,7 @@ class SetupCommonPipelineEnvironmentTest extends BasePiperTest { return path.endsWith('.pipeline/config.yml') }) - jsr.step.call(script: nullScript, utils: getSWAMockedUtils()) + jsr.step.setupCommonPipelineEnvironment(script: nullScript, utils: getSWAMockedUtils()) assertEquals(Boolean.FALSE.toString(), swaOldConfigUsed) assertEquals('.pipeline/config.yml', usedConfigFile) @@ -71,7 +71,7 @@ class SetupCommonPipelineEnvironmentTest extends BasePiperTest { return path.endsWith('.pipeline/config.properties') }) - jsr.step.call(script: nullScript, utils: getSWAMockedUtils()) + jsr.step.setupCommonPipelineEnvironment(script: nullScript, utils: getSWAMockedUtils()) assertEquals(Boolean.TRUE.toString(), swaOldConfigUsed) assertEquals('.pipeline/config.properties', usedConfigFile) diff --git a/test/groovy/ToolValidateTest.groovy b/test/groovy/ToolValidateTest.groovy index 5bb5b79fb..0f237a3a0 100644 --- a/test/groovy/ToolValidateTest.groovy +++ b/test/groovy/ToolValidateTest.groovy @@ -35,7 +35,7 @@ class ToolValidateTest extends BasePiperTest { thrown.expect(IllegalArgumentException) thrown.expectMessage("The parameter 'home' can not be null or empty.") - jsr.step.call(tool: 'java') + jsr.step.toolValidate(tool: 'java') } @Test @@ -44,7 +44,7 @@ class ToolValidateTest extends BasePiperTest { thrown.expect(IllegalArgumentException) thrown.expectMessage("The parameter 'home' can not be null or empty.") - jsr.step.call(tool: 'java', home: '') + jsr.step.toolValidate(tool: 'java', home: '') } @Test @@ -55,7 +55,7 @@ class ToolValidateTest extends BasePiperTest { thrown.expect(IllegalArgumentException) thrown.expectMessage("The parameter 'tool' can not be null or empty.") - jsr.step.call(tool: null, home: home) + jsr.step.toolValidate(tool: null, home: home) } @Test @@ -66,7 +66,7 @@ class ToolValidateTest extends BasePiperTest { thrown.expect(IllegalArgumentException) thrown.expectMessage("The parameter 'tool' can not be null or empty.") - jsr.step.call(tool: '', home: home) + jsr.step.toolValidate(tool: '', home: home) } @Test @@ -77,7 +77,7 @@ class ToolValidateTest extends BasePiperTest { thrown.expect(AbortException) thrown.expectMessage("The tool 'test' is not supported.") - jsr.step.call(tool: 'test', home: home) + jsr.step.toolValidate(tool: 'test', home: home) } @Test @@ -88,7 +88,7 @@ class ToolValidateTest extends BasePiperTest { helper.registerAllowedMethod('sh', [Map], { Map m -> getNoVersion(m) }) - jsr.step.call(tool: 'java', home: home) + jsr.step.toolValidate(tool: 'java', home: home) } @Test @@ -99,7 +99,7 @@ class ToolValidateTest extends BasePiperTest { helper.registerAllowedMethod('sh', [Map], { Map m -> getNoVersion(m) }) - jsr.step.call(tool: 'mta', home: home) + jsr.step.toolValidate(tool: 'mta', home: home) } @Test @@ -110,7 +110,7 @@ class ToolValidateTest extends BasePiperTest { helper.registerAllowedMethod('sh', [Map], { Map m -> getNoVersion(m) }) - jsr.step.call(tool: 'neo', home: home) + jsr.step.toolValidate(tool: 'neo', home: home) } @Test @@ -121,7 +121,7 @@ class ToolValidateTest extends BasePiperTest { helper.registerAllowedMethod('sh', [Map], { Map m -> getNoVersion(m) }) - jsr.step.call(tool: 'cm', home: home) + jsr.step.toolValidate(tool: 'cm', home: home) } @Test @@ -132,7 +132,7 @@ class ToolValidateTest extends BasePiperTest { helper.registerAllowedMethod('sh', [Map], { Map m -> getIncompatibleVersion(m) }) - jsr.step.call(tool: 'java', home: home) + jsr.step.toolValidate(tool: 'java', home: home) } @Test @@ -143,7 +143,7 @@ class ToolValidateTest extends BasePiperTest { helper.registerAllowedMethod('sh', [Map], { Map m -> getIncompatibleVersion(m) }) - jsr.step.call(tool: 'mta', home: home) + jsr.step.toolValidate(tool: 'mta', home: home) } @Test @@ -155,7 +155,7 @@ class ToolValidateTest extends BasePiperTest { helper.registerAllowedMethod('sh', [Map], { Map m -> getIncompatibleVersion(m) }) binding.setVariable('tool', 'cm') - jsr.step.call(tool: 'cm', home: home) + jsr.step.toolValidate(tool: 'cm', home: home) } @Test @@ -163,7 +163,7 @@ class ToolValidateTest extends BasePiperTest { helper.registerAllowedMethod('sh', [Map], { Map m -> getVersion(m) }) - jsr.step.call(tool: 'java', home: home) + jsr.step.toolValidate(tool: 'java', home: home) assert jlr.log.contains('Verifying Java version 1.8.0 or compatible version.') assert jlr.log.contains('Java version 1.8.0 is installed.') @@ -174,7 +174,7 @@ class ToolValidateTest extends BasePiperTest { helper.registerAllowedMethod('sh', [Map], { Map m -> getVersion(m) }) - jsr.step.call(tool: 'mta', home: home) + jsr.step.toolValidate(tool: 'mta', home: home) assert jlr.log.contains('Verifying SAP Multitarget Application Archive Builder version 1.0.6 or compatible version.') assert jlr.log.contains('SAP Multitarget Application Archive Builder version 1.0.6 is installed.') @@ -185,7 +185,7 @@ class ToolValidateTest extends BasePiperTest { helper.registerAllowedMethod('sh', [Map], { Map m -> getVersion(m) }) - jsr.step.call(tool: 'neo', home: home) + jsr.step.toolValidate(tool: 'neo', home: home) } @Test @@ -193,7 +193,7 @@ class ToolValidateTest extends BasePiperTest { helper.registerAllowedMethod('sh', [Map], { Map m -> getVersion(m) }) - jsr.step.call(tool: 'cm', home: home) + jsr.step.toolValidate(tool: 'cm', home: home) assert jlr.log.contains('Verifying Change Management Command Line Interface version 0.0.1 or compatible version.') assert jlr.log.contains('Change Management Command Line Interface version 0.0.1 is installed.') diff --git a/test/groovy/TransportRequestCreateTest.groovy b/test/groovy/TransportRequestCreateTest.groovy index a7170699e..8a9c0dc52 100644 --- a/test/groovy/TransportRequestCreateTest.groovy +++ b/test/groovy/TransportRequestCreateTest.groovy @@ -69,7 +69,7 @@ public class TransportRequestCreateTest extends BasePiperTest { } } - jsr.step.call(script: nullScript, developmentSystemId: '001', cmUtils: cm) + jsr.step.transportRequestCreate(script: nullScript, developmentSystemId: '001', cmUtils: cm) } @Test @@ -78,7 +78,7 @@ public class TransportRequestCreateTest extends BasePiperTest { thrown.expect(IllegalArgumentException) thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR developmentSystemId") - jsr.step.call(script: nullScript, changeDocumentId: '001') + jsr.step.transportRequestCreate(script: nullScript, changeDocumentId: '001') } @Test @@ -101,7 +101,7 @@ public class TransportRequestCreateTest extends BasePiperTest { thrown.expect(AbortException) thrown.expectMessage("Exception message.") - jsr.step.call(script: nullScript, changeDocumentId: '001', developmentSystemId: '001', cmUtils: cm) + jsr.step.transportRequestCreate(script: nullScript, changeDocumentId: '001', developmentSystemId: '001', cmUtils: cm) } @Test @@ -127,7 +127,7 @@ public class TransportRequestCreateTest extends BasePiperTest { } } - def transportId = jsr.step.call(script: nullScript, changeDocumentId: '001', developmentSystemId: '001', cmUtils: cm) + def transportId = jsr.step.transportRequestCreate(script: nullScript, changeDocumentId: '001', developmentSystemId: '001', cmUtils: cm) assert transportId == '001' assert result == [changeId: '001', @@ -166,7 +166,7 @@ public class TransportRequestCreateTest extends BasePiperTest { } } - def transportId = jsr.step.call(script: nullScript, + def transportId = jsr.step.transportRequestCreate(script: nullScript, transportType: 'W', targetSystem: 'XYZ', description: 'desc', @@ -191,7 +191,7 @@ public class TransportRequestCreateTest extends BasePiperTest { jlr.expect('[INFO] Change management integration intentionally switched off.') - jsr.step.call(script: nullScript, + jsr.step.transportRequestCreate(script: nullScript, changeManagement: [type: 'NONE']) } } diff --git a/test/groovy/TransportRequestReleaseTest.groovy b/test/groovy/TransportRequestReleaseTest.groovy index 4042f978e..2f740d180 100644 --- a/test/groovy/TransportRequestReleaseTest.groovy +++ b/test/groovy/TransportRequestReleaseTest.groovy @@ -62,7 +62,7 @@ public class TransportRequestReleaseTest extends BasePiperTest { thrown.expect(IllegalArgumentException) thrown.expectMessage("Change document id not provided (parameter: 'changeDocumentId' or via commit history).") - jsr.step.call(script: nullScript, transportRequestId: '001', cmUtils: cm) + jsr.step.transportRequestRelease(script: nullScript, transportRequestId: '001', cmUtils: cm) } @Test @@ -80,7 +80,7 @@ public class TransportRequestReleaseTest extends BasePiperTest { thrown.expect(IllegalArgumentException) thrown.expectMessage("Transport request id not provided (parameter: 'transportRequestId' or via commit history).") - jsr.step.call(script: nullScript, changeDocumentId: '001', cmUtils: cm) + jsr.step.transportRequestRelease(script: nullScript, changeDocumentId: '001', cmUtils: cm) } @Test @@ -102,7 +102,7 @@ public class TransportRequestReleaseTest extends BasePiperTest { } } - jsr.step.call(script: nullScript, changeDocumentId: '001', transportRequestId: '001', cmUtils: cm) + jsr.step.transportRequestRelease(script: nullScript, changeDocumentId: '001', transportRequestId: '001', cmUtils: cm) } @Test @@ -130,7 +130,7 @@ public class TransportRequestReleaseTest extends BasePiperTest { } } - jsr.step.call(script: nullScript, changeDocumentId: '001', transportRequestId: '002', cmUtils: cm) + jsr.step.transportRequestRelease(script: nullScript, changeDocumentId: '001', transportRequestId: '002', cmUtils: cm) assert receivedParams == [type: BackendType.SOLMAN, changeId: '001', @@ -145,7 +145,7 @@ public class TransportRequestReleaseTest extends BasePiperTest { jlr.expect('[INFO] Change management integration intentionally switched off.') - jsr.step.call(script: nullScript, + jsr.step.transportRequestRelease(script: nullScript, changeManagement: [type: 'NONE']) } } diff --git a/test/groovy/TransportRequestUploadFileTest.groovy b/test/groovy/TransportRequestUploadFileTest.groovy index b17156f32..772ba71fe 100644 --- a/test/groovy/TransportRequestUploadFileTest.groovy +++ b/test/groovy/TransportRequestUploadFileTest.groovy @@ -73,7 +73,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest { } } - jsr.step.call(script: nullScript, transportRequestId: '001', applicationId: 'app', filePath: '/path', cmUtils: cm) + jsr.step.transportRequestUploadFile(script: nullScript, transportRequestId: '001', applicationId: 'app', filePath: '/path', cmUtils: cm) } @Test @@ -93,7 +93,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest { thrown.expect(IllegalArgumentException) thrown.expectMessage("Transport request id not provided (parameter: 'transportRequestId' or via commit history).") - jsr.step.call(script: nullScript, changeDocumentId: '001', applicationId: 'app', filePath: '/path', cmUtils: cm) + jsr.step.transportRequestUploadFile(script: nullScript, changeDocumentId: '001', applicationId: 'app', filePath: '/path', cmUtils: cm) } @Test @@ -106,7 +106,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest { thrown.expect(IllegalArgumentException) thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR applicationId") - jsr.step.call(script: nullScript, changeDocumentId: '001', transportRequestId: '001', filePath: '/path') + jsr.step.transportRequestUploadFile(script: nullScript, changeDocumentId: '001', transportRequestId: '001', filePath: '/path') } @Test @@ -115,7 +115,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest { thrown.expect(IllegalArgumentException) thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR filePath") - jsr.step.call(script: nullScript, changeDocumentId: '001', transportRequestId: '001', applicationId: 'app') + jsr.step.transportRequestUploadFile(script: nullScript, changeDocumentId: '001', transportRequestId: '001', applicationId: 'app') } @Test @@ -137,7 +137,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest { thrown.expect(AbortException) thrown.expectMessage("Exception message") - jsr.step.call(script: nullScript, + jsr.step.transportRequestUploadFile(script: nullScript, changeDocumentId: '001', transportRequestId: '001', applicationId: 'app', @@ -172,7 +172,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest { } } - jsr.step.call(script: nullScript, + jsr.step.transportRequestUploadFile(script: nullScript, changeManagement: [type: 'CTS'], transportRequestId: '002', filePath: '/path', @@ -218,7 +218,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest { } } - jsr.step.call(script: nullScript, + jsr.step.transportRequestUploadFile(script: nullScript, changeDocumentId: '001', transportRequestId: '002', applicationId: 'app', @@ -289,7 +289,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest { } } - jsr.step.call(script: nullScript, + jsr.step.transportRequestUploadFile(script: nullScript, changeDocumentId: '001', transportRequestId: '002', applicationId: 'app', @@ -319,7 +319,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest { } } - jsr.step.call(script: nullScript, + jsr.step.transportRequestUploadFile(script: nullScript, changeDocumentId: '001', transportRequestId: '002', applicationId: 'app', @@ -347,7 +347,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest { } } - jsr.step.call(script: nullScript, + jsr.step.transportRequestUploadFile(script: nullScript, changeDocumentId: '001', transportRequestId: '001', applicationId: 'app', @@ -361,7 +361,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest { thrown.expectMessage('Invalid backend type: \'DUMMY\'. Valid values: [SOLMAN, CTS, NONE]. ' + 'Configuration: \'changeManagement/type\'.') - jsr.step.call(script: nullScript, + jsr.step.transportRequestUploadFile(script: nullScript, applicationId: 'app', filePath: '/path', changeManagement: [type: 'DUMMY']) @@ -373,7 +373,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest { jlr.expect('[INFO] Change management integration intentionally switched off.') - jsr.step.call(script: nullScript, + jsr.step.transportRequestUploadFile(script: nullScript, changeManagement: [type: 'NONE']) } From 87bc3e9b9696df7e28739078a4bbb401660d0ac5 Mon Sep 17 00:00:00 2001 From: Christopher Fenner Date: Wed, 7 Nov 2018 12:05:28 +0100 Subject: [PATCH 8/9] run docs build for PRs in parallel to unit tests (#371) --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9962d70a2..ec5e47e80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,14 +25,13 @@ jobs: - JACOCO_SOURCE_PATH="src vars test" ./cc-test-reporter format-coverage target/site/jacoco/jacoco.xml --input-type jacoco - ./cc-test-reporter upload-coverage - mvn -DrepoToken=$COVERALLS_REPO_TOKEN org.eluder.coveralls:coveralls-maven-plugin:report - - - stage: Docs - name: Build + - name: Docs Build if: type = pull_request install: docker pull squidfunk/mkdocs-material:3.0.4 script: docker run --rm -it -v ${TRAVIS_BUILD_DIR}:/docs -w /docs/documentation squidfunk/mkdocs-material:3.0.4 build --clean --verbose --strict - - name: Deploy + - stage: Docs + name: Deploy if: repo = "SAP/jenkins-library" AND branch = master AND NOT type = pull_request install: - docker pull squidfunk/mkdocs-material:3.0.4 From e487ad5055b0f4e4d6b975b4c0b27406117427bd Mon Sep 17 00:00:00 2001 From: Christopher Fenner Date: Wed, 7 Nov 2018 13:08:24 +0100 Subject: [PATCH 9/9] disable download logs in maven (#370) --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index ec5e47e80..eda937618 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,9 @@ language: groovy sudo: required services: - docker +env: + global: + MAVEN_OPTS=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn cache: directories: - $HOME/.m2