From 463bdfabaaf738fafbcb9cf0f1389c1be90bae97 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Thu, 21 Mar 2019 16:21:55 +0100 Subject: [PATCH 01/67] Introduce step helper --- test/groovy/CommonStepsTest.groovy | 8 +------- test/groovy/util/StepHelper.groovy | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 test/groovy/util/StepHelper.groovy diff --git a/test/groovy/CommonStepsTest.groovy b/test/groovy/CommonStepsTest.groovy index aca11b1fb..0ed0575ab 100644 --- a/test/groovy/CommonStepsTest.groovy +++ b/test/groovy/CommonStepsTest.groovy @@ -4,6 +4,7 @@ import static org.hamcrest.Matchers.equalTo import static org.hamcrest.Matchers.is import static org.junit.Assert.assertThat import static org.junit.Assert.fail +import static util.StepHelper.getSteps import java.io.File; import java.util.stream.Collectors @@ -241,11 +242,4 @@ public class CommonStepsTest extends BasePiperTest{ assertThat("Steps with call methods with return types other than void: ${stepsWithCallMethodsOtherThanVoid}", stepsWithCallMethodsOtherThanVoid, is(empty())) } - - private static getSteps() { - List steps = [] - new File('vars').traverse(type: FileType.FILES, maxDepth: 0) - { if(it.getName().endsWith('.groovy')) steps << (it =~ /vars[\\\/](.*)\.groovy/)[0][1] } - return steps - } } diff --git a/test/groovy/util/StepHelper.groovy b/test/groovy/util/StepHelper.groovy new file mode 100644 index 000000000..59fb311e5 --- /dev/null +++ b/test/groovy/util/StepHelper.groovy @@ -0,0 +1,15 @@ +package util; + +import java.util.List; + +import groovy.io.FileType + +public class StepHelper { + + private static getSteps() { + List steps = [] + new File('vars').traverse(type: FileType.FILES, maxDepth: 0) + { if(it.getName().endsWith('.groovy')) steps << (it =~ /vars[\\\/](.*)\.groovy/)[0][1] } + return steps + } +} From 8cba85b63e2f3f6b24e8438db46c5c9c9a9ae239 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 19 Mar 2019 12:40:58 +0100 Subject: [PATCH 02/67] Create step specific plugin lists: Helper class for tracking step calls Before the test we remmber which test is currently running. During the test we collect all the calls to steps. Beside that we persist the names of all steps within this shared lib itself. After the test(s) we write a corresponding json file. In fact we write the file after each test, which is too often. But since we don't know which test is the last test we can't do better. The resulting file can be used later on for resolving the plugins contributing the particular steps. With that we are able to create a list of required plugins for each step. --- test/groovy/util/StepTracker.groovy | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 test/groovy/util/StepTracker.groovy diff --git a/test/groovy/util/StepTracker.groovy b/test/groovy/util/StepTracker.groovy new file mode 100644 index 000000000..748ad6532 --- /dev/null +++ b/test/groovy/util/StepTracker.groovy @@ -0,0 +1,69 @@ +package util + +import static com.lesfurets.jenkins.unit.MethodSignature.method +import static util.StepHelper.getSteps + +import org.codehaus.groovy.runtime.MetaClassHelper +import com.lesfurets.jenkins.unit.MethodSignature +import com.lesfurets.jenkins.unit.PipelineTestHelper +import groovy.json.JsonBuilder + +class StepTracker { + + /* + * Contains the piper steps as key (derived from the test name, so this is blurry since it might + * contains also other cases than only piper step name) and the observed calls in a collection. + */ + static Map piperStepCallMapping = [:] + static Set piperSteps = StepHelper.getSteps() + + static Set calls + + static { + initialize() + } + + final static void initialize() { + + PipelineTestHelper.metaClass.getAllowedMethodEntry = { + + // We need to be careful here, in case we switch to another + // version of the Les Furets framework we have to check if + // this here still works. + + String name, Object[] args -> + + Class[] paramTypes = MetaClassHelper.castArgumentsToClassArray(args) + MethodSignature signature = method(name, paramTypes) + def intercepted = allowedMethodCallbacks.find { k, v -> k == signature } + + if(intercepted != null) + StepTracker.add(name) + + return intercepted + } + } + + static void before(String stepName) { + + if(piperStepCallMapping[stepName] == null) + piperStepCallMapping[stepName] = (Set)[] + calls = piperStepCallMapping[stepName] + } + + static void after() { + calls = null + write() + } + static void add (String call) { + calls.add(call) + } + + static private void write() { + Map root = [ + piperSteps: piperSteps, + calls: piperStepCallMapping.sort() + ] + new File('target/trackedCalls.json').write(new JsonBuilder(root).toPrettyString()) + } +} From 0aea255a37a705a0ceb675a443e50b06ee8e0dd8 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Wed, 27 Mar 2019 15:44:06 +0100 Subject: [PATCH 03/67] Create step specific plugin lists: Make use of the step tracker --- test/groovy/util/LibraryLoadingTestExecutionListener.groovy | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/groovy/util/LibraryLoadingTestExecutionListener.groovy b/test/groovy/util/LibraryLoadingTestExecutionListener.groovy index cc2e58675..85b8d0c7c 100644 --- a/test/groovy/util/LibraryLoadingTestExecutionListener.groovy +++ b/test/groovy/util/LibraryLoadingTestExecutionListener.groovy @@ -90,6 +90,7 @@ class LibraryLoadingTestExecutionListener extends AbstractTestExecutionListener @Override void beforeTestClass(TestContext testContext) throws Exception { super.beforeTestClass(testContext) + StepTracker.before(testContext.testClass.getSimpleName()) def helper = LibraryLoadingTestExecutionListener.getSingletonInstance() registerDefaultAllowedMethods(helper) LibraryLoadingTestExecutionListener.START_CLASS_TRACKING = true @@ -98,6 +99,7 @@ class LibraryLoadingTestExecutionListener extends AbstractTestExecutionListener @Override void afterTestClass(TestContext testContext) throws Exception { super.afterTestClass(testContext) + StepTracker.after() PipelineTestHelper helper = LibraryLoadingTestExecutionListener.getSingletonInstance() helper.clearAllowedMethodCallbacks(LibraryLoadingTestExecutionListener.TRACKED_ON_CLASS) LibraryLoadingTestExecutionListener.TRACKED_ON_CLASS.clear() @@ -123,6 +125,7 @@ class LibraryLoadingTestExecutionListener extends AbstractTestExecutionListener void beforeTestMethod(TestContext testContext) throws Exception { super.beforeTestMethod(testContext) def testInstance = testContext.getTestInstance() + StepTracker.before(testInstance.getClass().getSimpleName()) testInstance.binding.setVariable('currentBuild', [result: 'SUCCESS', currentResult: 'SUCCESS']) PipelineTestHelper helper = LibraryLoadingTestExecutionListener.getSingletonInstance() LibraryLoadingTestExecutionListener.START_METHOD_TRACKING = true @@ -132,6 +135,7 @@ class LibraryLoadingTestExecutionListener extends AbstractTestExecutionListener void afterTestMethod(TestContext testContext) throws Exception { super.afterTestMethod(testContext) def testInstance = testContext.getTestInstance() + StepTracker.after() PipelineTestHelper helper = LibraryLoadingTestExecutionListener.getSingletonInstance() helper.clearCallStack() @@ -192,6 +196,7 @@ class LibraryLoadingTestExecutionListener extends AbstractTestExecutionListener static class PipelineTestHelperHook { def helper = new PipelineTestHelper() { + def clearAllowedMethodCallbacks(Collection c = []) { List itemsToRemove = [] c.each { From 80f14ff9a2d422f260e4c76538b439e6dc562914 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Wed, 27 Mar 2019 15:44:28 +0100 Subject: [PATCH 04/67] Resolve calls to plugin steps in a transitive way We have the case that one piper step calls other piper steps. In such cases we would like to get all the plugin calls. The direct calls but also the calls performed by nested piper-lib step calls. The plugin calls as we registed them during listing to the tests are resolved with the script provided by this commit. --- steps.groovy | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 steps.groovy diff --git a/steps.groovy b/steps.groovy new file mode 100644 index 000000000..4f851bf49 --- /dev/null +++ b/steps.groovy @@ -0,0 +1,111 @@ +import groovy.json .JsonSlurper + +def steps = new JsonSlurper().parseText(new File('target/trackedCalls.json').text) + +def piperSteps = steps.piperSteps +def calls = steps.calls + +def _calls = [:] + +// Adjust naming +calls.each { c -> + _calls.put(retrieveStepName(c.key), c.value as Set) +} + +calls = _calls +_calls = null + +// Remove selfs +calls.each { c -> + c.value.remove(c.key) +} + +int counter=0 + +def alreadyHandled = [] + +while(counter < 1600) { + + def hereWeNeedToReplace + def toBeReplaced + + if(alreadyHandled.size() == calls.size()) break + + for (def call in calls.entrySet()) { + + stepName = call.key + calledSteps = call.value + + if(alreadyHandled.contains(stepName)) { + continue + } + + for (def calledStep in calledSteps) { + + if (calledStep in Map) { + } else { + if(calledStep in piperSteps) { + toBeReplaced = calledStep + hereWeNeedToReplace = calledSteps + break + } + } + } + if(toBeReplaced) { + def replacement = [:] + replacement[toBeReplaced] = calls[toBeReplaced] as Set + def removed = hereWeNeedToReplace.remove(toBeReplaced) + hereWeNeedToReplace.add(replacement) + counter++ + } else { + alreadyHandled << stepName + } + break + } +} + + +piperStepCallMappings = [:] + +for(def entry : calls.entrySet()) { + def performedCalls = flatten(entry, (Set)[]) + piperStepCallMappings.put(entry.key, performedCalls) +} + +File performedCalls = new File('target/performedCalls.json') +if (performedCalls.exists()) performedCalls.delete() +performedCalls << groovy.json.JsonOutput.toJson(piperStepCallMappings) + +def flatten(def entry, Set result) { + + for(def e : entry.value) { + if(e in Map) { // the map here is expected to hold one entry always + for(def steps : e.entrySet().value) { + for(def step : steps) { + if (step in Map) { + flatten(step, result) + } else { + result << step + } + } + } + } else { + result << e.value.toString() + } + } + result +} + +static retrieveStepName(String s) { + firstCharToLowerCase(removeTrailing(s, 'Test')) +} + +static removeTrailing(String s, String trail) { + return s.replaceAll(trail + '$', '') +} + +static firstCharToLowerCase(CharSequence cs) { + char[] c = cs.getChars() + c[0] = Character.toLowerCase(c[0]) + new String(c) +} From db3507d57a977d4f57487a7fce59e8a137723163 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Thu, 28 Mar 2019 17:04:08 +0100 Subject: [PATCH 05/67] init script for resolving plugins --- resolvePlugins.groovy | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 resolvePlugins.groovy diff --git a/resolvePlugins.groovy b/resolvePlugins.groovy new file mode 100644 index 000000000..d3a6538da --- /dev/null +++ b/resolvePlugins.groovy @@ -0,0 +1,42 @@ +import jenkins.model.Jenkins + +def stepCallMapping = new groovy.json.JsonSlurper().parseText(new File(System.getenv()['calls']).text) + +def stepPluginMapping = [:] + +println "[INFO] Resolving plugins ..." + +for(def step in stepCallMapping) { + def resolvedPlugins = [:] + for(def call in step.value) { + def resolvedPlugin = resolvePlugin(call) + if (! resolvedPlugin) resolvedPlugin = 'UNIDENTIFIED' + if(resolvedPlugins[resolvedPlugin] == null) + resolvedPlugins[resolvedPlugin] = (Set)[] + resolvedPlugins[resolvedPlugin] << call + stepPluginMapping.put(step.key,resolvedPlugins) + } +} + +def result = System.getenv()['result'] +new File(result).write(new groovy.json.JsonOutput().toJson(stepPluginMapping)) + +println "[INFO] plugins resolved. Result: ${result}." + + +def resolvePlugin(call) { + + def plugins = Jenkins.get().pluginManager.getPlugins() + + def s = new org.jenkinsci.plugins.workflow.cps.Snippetizer() + + def pDescs = s.getQuasiDescriptors(false) + + + for(def pd in pDescs) { + if(pd.getSymbol() == call) + return pd.real.plugin?.shortName + } + return null +} + From 6fb782ac3c2744dc1d0beaf64668c5b64221caec Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 29 Mar 2019 16:54:01 +0100 Subject: [PATCH 06/67] put everything together --- .../init.groovy.d/resolvePlugins.groovy | 53 +++++++++++++++++++ resolvePlugins.sh | 30 +++++++++++ 2 files changed, 83 insertions(+) create mode 100644 jenkins_home_init/init.groovy.d/resolvePlugins.groovy create mode 100755 resolvePlugins.sh diff --git a/jenkins_home_init/init.groovy.d/resolvePlugins.groovy b/jenkins_home_init/init.groovy.d/resolvePlugins.groovy new file mode 100644 index 000000000..d38f82201 --- /dev/null +++ b/jenkins_home_init/init.groovy.d/resolvePlugins.groovy @@ -0,0 +1,53 @@ +import groovy.json.JsonOutput +import groovy.json.JsonSlurper + +import jenkins.model.Jenkins + +def resolvePlugins() { + def stepCallMapping = new JsonSlurper().parseText(new File(System.getenv()['calls']).text) + + def stepPluginMapping = [:] + + println "[INFO] Resolving plugins ..." + + for(def step in stepCallMapping) { + def resolvedPlugins = [:] + for(def call in step.value) { + def resolvedPlugin = resolvePlugin(call) + if (! resolvedPlugin) resolvedPlugin = 'UNIDENTIFIED' + if(resolvedPlugins[resolvedPlugin] == null) + resolvedPlugins[resolvedPlugin] = (Set)[] + resolvedPlugins[resolvedPlugin] << call + stepPluginMapping.put(step.key,resolvedPlugins) + } + } + + def result = System.getenv()['result'] + new File(result).write(new JsonOutput().toJson(stepPluginMapping)) + + println "[INFO] plugins resolved. Result: ${result}." +} + +def resolvePlugin(call) { + + def plugins = Jenkins.get().pluginManager.getPlugins() + + def s = new org.jenkinsci.plugins.workflow.cps.Snippetizer() + + def pDescs = s.getQuasiDescriptors(false) + + + for(def pd in pDescs) { + if(pd.getSymbol() == call) + return pd.real.plugin?.shortName + } + return null +} + +try { + resolvePlugins() +} catch(Exception e) { + def result = System.getenv()['result'] + new File(new File(result).getParentFile(), 'FAILURE').text = '' + throw e +} diff --git a/resolvePlugins.sh b/resolvePlugins.sh new file mode 100755 index 000000000..37a108ee5 --- /dev/null +++ b/resolvePlugins.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +mvn clean test +groovy steps.groovy + + +[ -d jenkins_home ] && rm -rf jenkins_home + cp -r jenkins_home_init jenkins_home + +CALLS="`pwd`/jenkins_home/piper/calls.json" + +mkdir -p `dirname ${CALLS}` + +mv target/performedCalls.json ${CALLS} + +[ -f ${CALLS} ] || { echo "File \"${CALLS}\" does not exist." ; exit 1; } + +cID=$(docker run -d -v `pwd`/jenkins_home:/var/jenkins_home --env calls=/var/jenkins_home/piper/calls.json --env result=/var/jenkins_home/piper/result.json ppiper/jenkins-master); +echo "ContainerId: ${cID}"; +while true +do + [ -f jenkins_home/piper/result.json ] && { docker rm -f ${cID}; break; } # normal ... + [ -f jenkins_home/piper/FAILURE ] && { docker rm -f ${cID}; break; } # executing of our init script failed + docker ps --no-trunc |grep -q ${cID} || break # docker container does not run anymore + echo "[INFO] waiting for results" + sleep 10 +done + +RESULT="`pwd`/jenkins_home/piper/result.json" +[ -f ${RESULT} ] && cat jenkins_home/piper/result.json From ab392c11ee0a9800f505c1c7ed497002f095f4ab Mon Sep 17 00:00:00 2001 From: Oliver Feldmann Date: Mon, 1 Apr 2019 11:07:05 +0200 Subject: [PATCH 07/67] Remove malignous blank in import statement Co-Authored-By: marcusholl --- steps.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/steps.groovy b/steps.groovy index 4f851bf49..ab25b6fd7 100644 --- a/steps.groovy +++ b/steps.groovy @@ -1,4 +1,4 @@ -import groovy.json .JsonSlurper +import groovy.json.JsonSlurper def steps = new JsonSlurper().parseText(new File('target/trackedCalls.json').text) From 48c96a5a31b7115b9566e0a2b3cbec71a7220456 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 29 Mar 2019 16:23:36 +0100 Subject: [PATCH 08/67] Avoid having the same string literal for the neo log folder three times --- vars/neoDeploy.groovy | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index db7065a81..166d2cbc3 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -196,9 +196,11 @@ void call(parameters = [:]) { private deploy(script, utils, Map configuration, NeoCommandHelper neoCommandHelper, dockerImage, DeployMode deployMode) { + String logFolder = 'logs/neo' + try { - sh "mkdir -p logs/neo" - withEnv(["neo_logging_location=${pwd()}/logs/neo"]) { + sh "mkdir -p ${logFolder}" + withEnv(["neo_logging_location=${pwd()}/${logFolder}"]) { if (deployMode.isWarDeployment()) { ConfigurationHelper.newInstance(this, configuration).withPropertyInValues('warAction', WarAction.stringValues()) WarAction warAction = WarAction.fromString(configuration.warAction) @@ -238,7 +240,7 @@ private deploy(script, utils, Map configuration, NeoCommandHelper neoCommandHelp echo "Error while deploying to SAP Cloud Platform. Here are the neo.sh logs:" try { - sh "cat logs/neo/*" + sh "cat ${logFolder}/*" } catch(Exception e) { echo "Unable to provide the logs." ex.addSuppressed(e) From 74af6bab5f5a6be499e59a538730254908677020 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 10 May 2019 16:41:40 +0200 Subject: [PATCH 09/67] Add extensions to neoDeploy Extensions can be provided via --extension --e to the neo deploy command line for deploy-mta. This commits adds support for providing extension files. --- .../piper/tools/neo/NeoCommandHelper.groovy | 10 +- test/groovy/NeoDeployTest.groovy | 111 ++++++++++++++++++ .../tools/neo/NeoCommandHelperTest.groovy | 7 +- vars/neoDeploy.groovy | 23 +++- 4 files changed, 146 insertions(+), 5 deletions(-) diff --git a/src/com/sap/piper/tools/neo/NeoCommandHelper.groovy b/src/com/sap/piper/tools/neo/NeoCommandHelper.groovy index 8f883c939..09ba4a28d 100644 --- a/src/com/sap/piper/tools/neo/NeoCommandHelper.groovy +++ b/src/com/sap/piper/tools/neo/NeoCommandHelper.groovy @@ -8,12 +8,14 @@ class NeoCommandHelper { private Script step private DeployMode deployMode private Map deploymentConfiguration + private Set extensions private String user private String password private String source //Warning: Commands generated with this class can contain passwords and should only be used within the step withCredentials NeoCommandHelper(Script step, DeployMode deployMode, Map deploymentConfiguration, + Set extensions, String user, String password, String source) { this.step = step this.deployMode = deployMode @@ -21,6 +23,7 @@ class NeoCommandHelper { this.user = user this.password = password this.source = source + this.extensions = extensions ?: (Set)[] } private String prolog() { @@ -47,7 +50,7 @@ class NeoCommandHelper { } String deployMta() { - return "${prolog()} deploy-mta --synchronous ${mainArgs()} ${source()}" + return "${prolog()} deploy-mta --synchronous ${mainArgs()}${extensions()} ${source()}" } String cloudCockpitLink() { @@ -87,6 +90,11 @@ class NeoCommandHelper { return "--source ${BashUtils.quoteAndEscape(source)}" } + private String extensions() { + if(! this.extensions) return '' + ' --extensions ' + ((Iterable)this.extensions.collect({ "'${it}'" })).join(',') + } + private String mainArgs() { String usernamePassword = "--user ${BashUtils.quoteAndEscape(user)} --password ${BashUtils.quoteAndEscape(password)}" diff --git a/test/groovy/NeoDeployTest.groovy b/test/groovy/NeoDeployTest.groovy index d4b30a67f..4a897f4b7 100644 --- a/test/groovy/NeoDeployTest.groovy +++ b/test/groovy/NeoDeployTest.groovy @@ -1,14 +1,19 @@ +import com.sap.piper.StepAssertions import com.sap.piper.Utils + +import groovy.lang.Script import hudson.AbortException import static org.hamcrest.Matchers.allOf import static org.hamcrest.Matchers.containsString import static org.hamcrest.Matchers.not +import static org.junit.Assert.assertThat import org.hamcrest.Matchers import org.hamcrest.BaseMatcher import org.hamcrest.Description import org.jenkinsci.plugins.credentialsbinding.impl.CredentialNotFoundException +import org.junit.After import org.junit.Assert import org.junit.Before import org.junit.Rule @@ -76,6 +81,11 @@ class NeoDeployTest extends BasePiperTest { nullScript.commonPipelineEnvironment.configuration = [steps: [neoDeploy: [neo: [host: 'test.deploy.host.com', account: 'trialuser123']]]] } + @After + void tearDown() { + GroovySystem.metaClassRegistry.removeMetaClass(StepAssertions) + } + @Test void straightForwardTestConfigViaParameters() { @@ -122,6 +132,107 @@ class NeoDeployTest extends BasePiperTest { .hasSingleQuotedOption('source', archiveName)) } + @Test + void extensionsAsStringTest() { + + def checkedExtensionFiles = [] + + StepAssertions.metaClass.static.assertFileExists = + { Script step, String filePath -> + checkedExtensionFiles << filePath + if( ! [archiveName, 'myExtension.yml'].contains(filePath) ) + step.error("File ${filePath} cannot be found.") + } + + stepRule.step.neoDeploy( + script: nullScript, + source: archiveName, + mtaExtensionDescriptors: 'myExtension.yml' + ) + + assert checkedExtensionFiles.contains('myExtension.yml') + + assertThat(shellRule.shell, + new CommandLineMatcher() + .hasProlog('neo.sh deploy-mta') + .hasSingleQuotedOption('extensions', 'myExtension.yml')) + } + + @Test + void extensionsAsSetTest() { + Set extensions= ['myExtension1.yml' ,'myExtension2.yml'] + extensionsAsCollectionTest(extensions) + } + + @Test + void extensionsAsListTest() { + List extensions= ['myExtension1.yml' ,'myExtension2.yml'] + extensionsAsCollectionTest(extensions) + } + @Test + void sameExtensionProvidedTwiceTest() { + List extensions= ['myExtension1.yml' ,'myExtension2.yml', 'myExtension1.yml'] + extensionsAsCollectionTest(extensions) + } + + void extensionsAsCollectionTest(def extensions) { + + def checkedExtensionFiles = [] + + StepAssertions.metaClass.static.assertFileExists = + { Script step, String filePath -> + checkedExtensionFiles << filePath + if( ! [ + archiveName, + 'myExtension1.yml', + 'myExtension2.yml', + ].contains(filePath) ) + step.error("File ${filePath} cannot be found.") + } + + stepRule.step.neoDeploy( + script: nullScript, + source: archiveName, + mtaExtensionDescriptors: extensions + ) + + assert checkedExtensionFiles.contains('myExtension1.yml') + assert checkedExtensionFiles.contains('myExtension2.yml') + + assertThat(shellRule.shell, + new CommandLineMatcher() + .hasProlog('neo.sh deploy-mta') + // some kind of creative usage for the single quotation check (... single quotes inside) + .hasSingleQuotedOption('extensions', 'myExtension1.yml\',\'myExtension2.yml')) + + } + + @Test + void extensionsForWrongDeployModeTest() { + + thrown.expect(AbortException) + thrown.expectMessage('Extensions are only supported for deploy mode \'MTA\'') + + StepAssertions.metaClass.static.assertFileExists = + { Script step, String filePath -> + if( ! [archiveName, 'myExtension.yml'].contains(filePath) ) + step.error("File ${filePath} cannot be found.") + } + + stepRule.step.neoDeploy( + script: nullScript, + source: archiveName, + deployMode: 'warParams', + mtaExtensionDescriptors: 'myExtension.yml', + neo: + [ + application: 'does', + runtime: 'not', + runtimeVersion: 'matter' + ], + ) + } + @Test void archivePathFromCPETest() { diff --git a/test/groovy/com/sap/piper/tools/neo/NeoCommandHelperTest.groovy b/test/groovy/com/sap/piper/tools/neo/NeoCommandHelperTest.groovy index d272c24cd..0af8783b0 100644 --- a/test/groovy/com/sap/piper/tools/neo/NeoCommandHelperTest.groovy +++ b/test/groovy/com/sap/piper/tools/neo/NeoCommandHelperTest.groovy @@ -17,7 +17,7 @@ class NeoCommandHelperTest extends BasePiperTest { .getCommonRules(this) .around(fileExistsRule) - NeoCommandHelper getTestFixture(DeployMode deployMode) { + NeoCommandHelper getTestFixture(DeployMode deployMode, Set extensions = []) { Map deploymentConfiguration = [ host : 'host_value', @@ -41,6 +41,7 @@ class NeoCommandHelperTest extends BasePiperTest { nullScript, deployMode, deploymentConfiguration, + extensions, username, password, source @@ -121,9 +122,9 @@ class NeoCommandHelperTest extends BasePiperTest { @Test void deployMta() { - String actual = getTestFixture(DeployMode.MTA).deployMta() + String actual = getTestFixture(DeployMode.MTA, (Set)['myExtension1.yml', 'myExtension2.yml']).deployMta() String expected = "neo.sh deploy-mta --synchronous --host 'host_value' --account 'account_value' " + - "--user 'username' --password 'password' --source 'file.mta'" + "--user 'username' --password 'password' --extensions 'myExtension1.yml','myExtension2.yml' --source 'file.mta'" Assert.assertEquals(expected, actual) } } diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index db7065a81..d3107b3cb 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -84,10 +84,15 @@ import static com.sap.piper.Prerequisites.checkScript * @see dockerExecute */ 'dockerOptions', + /** + * Extension files. Provided to the neo command via parameter `--extensions` (`-e`). + */ + 'mtaExtensionDescriptors', /** * The path to the archive for deployment to SAP CP. If not provided `mtarFilePath` from commom pipeline environment is used instead. */ - 'source' + 'source', + ]) @Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS.plus([ @@ -150,6 +155,17 @@ void call(parameters = [:]) { // since the map did not change, it is not required to replace the previous configuration map. .use() + Set extensionList + + if(configuration.mtaExtensionDescriptors == null) { + extensionList = [] + } else { + extensionList = configuration.mtaExtensionDescriptors in Collection ? configuration.mtaExtensionDescriptors : [configuration.mtaExtensionDescriptors] + } + + if(deployMode != DeployMode.MTA && ! extensionList.isEmpty()) + error "Extensions (${extensionList} found for deploy mode ${deployMode}. Extensions are only supported for deploy mode '${DeployMode.MTA}')" + utils.pushToSWA([ step: STEP_NAME, stepParamKey1: 'deployMode', @@ -177,10 +193,15 @@ void call(parameters = [:]) { StepAssertions.assertFileExists(this, configuration.source) + for(CharSequence extensionFile in extensionList) { + StepAssertions.assertFileExists(this, extensionFile) + } + NeoCommandHelper neoCommandHelper = new NeoCommandHelper( this, deployMode, configuration.neo, + extensionList, NEO_USERNAME, NEO_PASSWORD, configuration.source From a24c89ce129b046dfd8647c0cfc1720712933442 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 17 May 2019 14:52:27 +0200 Subject: [PATCH 10/67] fix code climate issues --- .../init.groovy.d/resolvePlugins.groovy | 2 +- resolvePlugins.groovy | 21 ++++++++-------- resolvePlugins.sh | 24 +++++++++---------- steps.groovy | 10 +++++--- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/jenkins_home_init/init.groovy.d/resolvePlugins.groovy b/jenkins_home_init/init.groovy.d/resolvePlugins.groovy index d38f82201..de5ad3086 100644 --- a/jenkins_home_init/init.groovy.d/resolvePlugins.groovy +++ b/jenkins_home_init/init.groovy.d/resolvePlugins.groovy @@ -39,7 +39,7 @@ def resolvePlugin(call) { for(def pd in pDescs) { if(pd.getSymbol() == call) - return pd.real.plugin?.shortName + return pd.real.plugin?.shortName } return null } diff --git a/resolvePlugins.groovy b/resolvePlugins.groovy index d3a6538da..5f0468037 100644 --- a/resolvePlugins.groovy +++ b/resolvePlugins.groovy @@ -7,15 +7,15 @@ def stepPluginMapping = [:] println "[INFO] Resolving plugins ..." for(def step in stepCallMapping) { - def resolvedPlugins = [:] - for(def call in step.value) { - def resolvedPlugin = resolvePlugin(call) - if (! resolvedPlugin) resolvedPlugin = 'UNIDENTIFIED' - if(resolvedPlugins[resolvedPlugin] == null) - resolvedPlugins[resolvedPlugin] = (Set)[] - resolvedPlugins[resolvedPlugin] << call - stepPluginMapping.put(step.key,resolvedPlugins) - } + def resolvedPlugins = [:] + for(def call in step.value) { + def resolvedPlugin = resolvePlugin(call) + if (! resolvedPlugin) resolvedPlugin = 'UNIDENTIFIED' + if(resolvedPlugins[resolvedPlugin] == null) + resolvedPlugins[resolvedPlugin] = (Set)[] + resolvedPlugins[resolvedPlugin] << call + stepPluginMapping.put(step.key,resolvedPlugins) + } } def result = System.getenv()['result'] @@ -35,8 +35,7 @@ def resolvePlugin(call) { for(def pd in pDescs) { if(pd.getSymbol() == call) - return pd.real.plugin?.shortName + return pd.real.plugin?.shortName } return null } - diff --git a/resolvePlugins.sh b/resolvePlugins.sh index 37a108ee5..2a328c273 100755 --- a/resolvePlugins.sh +++ b/resolvePlugins.sh @@ -5,26 +5,26 @@ groovy steps.groovy [ -d jenkins_home ] && rm -rf jenkins_home - cp -r jenkins_home_init jenkins_home +cp -r jenkins_home_init jenkins_home -CALLS="`pwd`/jenkins_home/piper/calls.json" +CALLS="$(pwd)/jenkins_home/piper/calls.json" -mkdir -p `dirname ${CALLS}` +mkdir -p $(dirname "${CALLS}") -mv target/performedCalls.json ${CALLS} +mv target/performedCalls.json "${CALLS}" -[ -f ${CALLS} ] || { echo "File \"${CALLS}\" does not exist." ; exit 1; } +[ -f "${CALLS}" ] || { echo "File \"${CALLS}\" does not exist." ; exit 1; } -cID=$(docker run -d -v `pwd`/jenkins_home:/var/jenkins_home --env calls=/var/jenkins_home/piper/calls.json --env result=/var/jenkins_home/piper/result.json ppiper/jenkins-master); -echo "ContainerId: ${cID}"; +cID="$(docker run -d -v `pwd`/jenkins_home:/var/jenkins_home --env calls=/var/jenkins_home/piper/calls.json --env result=/var/jenkins_home/piper/result.json ppiper/jenkins-master)" +echo "ContainerId: ${cID}" while true do - [ -f jenkins_home/piper/result.json ] && { docker rm -f ${cID}; break; } # normal ... - [ -f jenkins_home/piper/FAILURE ] && { docker rm -f ${cID}; break; } # executing of our init script failed - docker ps --no-trunc |grep -q ${cID} || break # docker container does not run anymore + [ -f jenkins_home/piper/result.json ] && { docker rm -f "${cID}"; break; } # normal ... + [ -f jenkins_home/piper/FAILURE ] && { docker rm -f "${cID}"; break; } # executing of our init script failed + docker ps --no-trunc |grep -q "${cID}"|| break # docker container does not run anymore echo "[INFO] waiting for results" sleep 10 done -RESULT="`pwd`/jenkins_home/piper/result.json" -[ -f ${RESULT} ] && cat jenkins_home/piper/result.json +RESULT="$(pwd)/jenkins_home/piper/result.json" +[ -f "${RESULT}" ] && cat jenkins_home/piper/result.json diff --git a/steps.groovy b/steps.groovy index ab25b6fd7..8a6efd4b4 100644 --- a/steps.groovy +++ b/steps.groovy @@ -18,7 +18,7 @@ _calls = null // Remove selfs calls.each { c -> c.value.remove(c.key) -} +} int counter=0 @@ -42,7 +42,11 @@ while(counter < 1600) { for (def calledStep in calledSteps) { - if (calledStep in Map) { + if(calledStep in Map) { + // After some time not working on this I have acually forgotten + // what needs to be done here ... In order not to forget that + // here is maybe something missing we emit a log message. + System.err << "[DEBUG] This is not handled yet.(${calledStep})\n" } else { if(calledStep in piperSteps) { toBeReplaced = calledStep @@ -50,7 +54,7 @@ while(counter < 1600) { break } } - } + } if(toBeReplaced) { def replacement = [:] replacement[toBeReplaced] = calls[toBeReplaced] as Set From 4cae7b9ace8d0570f45729e3273d089f33c1a91b Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 17 May 2019 15:41:00 +0200 Subject: [PATCH 11/67] Switch to jenkins file runner approach --- .../Jenkinsfile | 20 ++++++---- resolvePlugins.sh | 38 ++++++++++--------- 2 files changed, 33 insertions(+), 25 deletions(-) rename jenkins_home_init/init.groovy.d/resolvePlugins.groovy => jenkins_workspace/Jenkinsfile (81%) diff --git a/jenkins_home_init/init.groovy.d/resolvePlugins.groovy b/jenkins_workspace/Jenkinsfile similarity index 81% rename from jenkins_home_init/init.groovy.d/resolvePlugins.groovy rename to jenkins_workspace/Jenkinsfile index de5ad3086..0636fbf7b 100644 --- a/jenkins_home_init/init.groovy.d/resolvePlugins.groovy +++ b/jenkins_workspace/Jenkinsfile @@ -3,6 +3,18 @@ import groovy.json.JsonSlurper import jenkins.model.Jenkins +node() { + stage('Resolve Plugins') { + try { + resolvePlugins() + } catch(Exception e) { + def result = System.getenv()['result'] + new File(new File(result).getParentFile(), 'FAILURE').text = "${e.getMessage()}" + throw e + } + } +} + def resolvePlugins() { def stepCallMapping = new JsonSlurper().parseText(new File(System.getenv()['calls']).text) @@ -43,11 +55,3 @@ def resolvePlugin(call) { } return null } - -try { - resolvePlugins() -} catch(Exception e) { - def result = System.getenv()['result'] - new File(new File(result).getParentFile(), 'FAILURE').text = '' - throw e -} diff --git a/resolvePlugins.sh b/resolvePlugins.sh index 2a328c273..05d5db23f 100755 --- a/resolvePlugins.sh +++ b/resolvePlugins.sh @@ -3,28 +3,32 @@ mvn clean test groovy steps.groovy +WS_OUT="$(pwd)/jenkins_workspace" +WS_IN=/workspace -[ -d jenkins_home ] && rm -rf jenkins_home -cp -r jenkins_home_init jenkins_home +REL_CALLS=calls.json +REL_RESULT=result.json -CALLS="$(pwd)/jenkins_home/piper/calls.json" +CALLS="${WS_OUT}/${REL_CALLS}" +RESULT="${WS_OUT}/${REL_RESULT}" -mkdir -p $(dirname "${CALLS}") +for f in ${CALLS} ${RESULT} +do + [ -e "${f}" ] && rm -rf "${f}" +done -mv target/performedCalls.json "${CALLS}" +cp target/performedCalls.json "${CALLS}" [ -f "${CALLS}" ] || { echo "File \"${CALLS}\" does not exist." ; exit 1; } -cID="$(docker run -d -v `pwd`/jenkins_home:/var/jenkins_home --env calls=/var/jenkins_home/piper/calls.json --env result=/var/jenkins_home/piper/result.json ppiper/jenkins-master)" -echo "ContainerId: ${cID}" -while true -do - [ -f jenkins_home/piper/result.json ] && { docker rm -f "${cID}"; break; } # normal ... - [ -f jenkins_home/piper/FAILURE ] && { docker rm -f "${cID}"; break; } # executing of our init script failed - docker ps --no-trunc |grep -q "${cID}"|| break # docker container does not run anymore - echo "[INFO] waiting for results" - sleep 10 -done +docker run \ + -w "${WS_IN}" \ + --env calls="${WS_IN}/${REL_CALLS}" \ + --env result="${WS_IN}/${REL_RESULT}" \ + -v "${WS_OUT}:${WS_IN}" \ + ppiper/jenkinsfile-runner \ + -ns \ + -f Jenkinsfile \ + --runWorkspace /workspace -RESULT="$(pwd)/jenkins_home/piper/result.json" -[ -f "${RESULT}" ] && cat jenkins_home/piper/result.json +[ -f "${RESULT}" ] && cat "${RESULT}" From cf08f3c7c81b243114c36a6872c715e938e77541 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 17 May 2019 16:18:02 +0200 Subject: [PATCH 12/67] print the mapping via jq --- resolvePlugins.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resolvePlugins.sh b/resolvePlugins.sh index 05d5db23f..fb41c634e 100755 --- a/resolvePlugins.sh +++ b/resolvePlugins.sh @@ -31,4 +31,6 @@ docker run \ -f Jenkinsfile \ --runWorkspace /workspace -[ -f "${RESULT}" ] && cat "${RESULT}" +[ -f "${RESULT}" ] || { echo "Result file containing step to plugin mapping not found (${RESULT})."; exit 1; } + +which -s jq && jq 'keys[] as $k | .[$k] | keys as $v | $k, [$v]' "${RESULT}" From 41ee87d1471391a6c22828bffd726f0c2240311c Mon Sep 17 00:00:00 2001 From: Christopher Fenner Date: Fri, 17 May 2019 13:20:13 +0200 Subject: [PATCH 13/67] fix code climate issues II (#715) * fix code climate issues * fix code climate issues * fix code climate issues --- README.md | 4 +-- documentation/docs/configuration.md | 8 ++--- documentation/docs/css/extra.css | 2 +- .../docs/scenarios/changeManagement.md | 8 ++--- .../docs/steps/checkChangeInDevelopment.md | 19 +++++----- documentation/docs/steps/influxWriteData.md | 2 +- documentation/docs/steps/kanikoExecute.md | 2 +- .../docs/steps/transportRequestCreate.md | 3 +- .../docs/steps/transportRequestUploadFile.md | 36 ++++++++++--------- pom.xml | 6 ++-- src/com/sap/piper/MtaUtils.groovy | 1 - src/com/sap/piper/cm/ChangeManagement.groovy | 16 ++++----- src/com/sap/piper/cm/StepHelpers.groovy | 14 ++++---- vars/artifactSetVersion.groovy | 6 ++-- vars/transportRequestUploadFile.groovy | 6 ++-- 15 files changed, 69 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index fc413e63d..cf4087feb 100644 --- a/README.md +++ b/README.md @@ -71,8 +71,7 @@ To setup the shared library, you need to perform the following steps: 1. Login to your Jenkins instance with administration privileges. 1. Open the system configuration page (*Manage Jenkins > Configure System*). -1. Scroll down to section *Global Pipeline Libraries* and add a new Library by - clicking the *Add* button. +1. Scroll down to section *Global Pipeline Libraries* and add a new Library by clicking the *Add* button. 1. set *Library Name* to `piper-lib-os` 1. set *Default Version* to the branch or tag you want to consume (e.g. `master` or `v0.1`) 1. set *Retrieval Method* to `Modern SCM` @@ -102,6 +101,7 @@ Feel free to open new issues for feature requests, bugs or general feedback on the [GitHub issues page of this project][piper-library-issues]. Register to our [google group][google-group] in order to get updates or for asking questions. + # Contributing Read and understand our [contribution guidelines][piper-library-contribution] diff --git a/documentation/docs/configuration.md b/documentation/docs/configuration.md index d61db5fb5..5be9daafc 100644 --- a/documentation/docs/configuration.md +++ b/documentation/docs/configuration.md @@ -11,10 +11,10 @@ Your configuration inherits from the default configuration located at [https://g Configuration of the Piper steps as well the Piper templates can be done in a hierarchical manner. 1. Directly passed step parameters will always take precedence over other configuration values and defaults -2. Stage configuration parameters define a Jenkins pipeline stage dependent set of parameters (e.g. deployment options for the `Acceptance` stage) -3. Step configuration defines how steps behave in general (e.g. step `cloudFoundryDeploy`) -4. General configuration parameters define parameters which are available across step boundaries -5. Default configuration comes with the Piper library and is always available +1. Stage configuration parameters define a Jenkins pipeline stage dependent set of parameters (e.g. deployment options for the `Acceptance` stage) +1. Step configuration defines how steps behave in general (e.g. step `cloudFoundryDeploy`) +1. General configuration parameters define parameters which are available across step boundaries +1. Default configuration comes with the Piper library and is always available ![Piper Configuration](images/piper_config.png) diff --git a/documentation/docs/css/extra.css b/documentation/docs/css/extra.css index 05406242d..a23270bb3 100644 --- a/documentation/docs/css/extra.css +++ b/documentation/docs/css/extra.css @@ -4,4 +4,4 @@ .md-typeset a:not(.headerlink):hover { text-decoration: underline; -} +} diff --git a/documentation/docs/scenarios/changeManagement.md b/documentation/docs/scenarios/changeManagement.md index 4786772d0..11500ae76 100644 --- a/documentation/docs/scenarios/changeManagement.md +++ b/documentation/docs/scenarios/changeManagement.md @@ -33,10 +33,10 @@ The basic workflow is as follows: **Note:** The blank line between message header and message description is mandatory. -2. To communicate with SAP Solution Manager, the pipeline uses credentials that must be stored on Jenkins using the credential ID `CM`. For more information, see [checkChangeInDevelopment](https://sap.github.io/jenkins-library/steps/checkChangeInDevelopment/). -3. The required transport request is created on the fly. **Note:** The change document can contain various components (for example, UI and backend components). -4. The changes of your development team trigger the Jenkins pipeline. It builds and validates the changes and attaches them to the respective transport request. -5. As soon as the development process is completed, the change document in SAP Solution Manager can be set to status `to be tested` and all components can be transported to the test system. +1. To communicate with SAP Solution Manager, the pipeline uses credentials that must be stored on Jenkins using the credential ID `CM`. For more information, see [checkChangeInDevelopment](https://sap.github.io/jenkins-library/steps/checkChangeInDevelopment/). +1. The required transport request is created on the fly. **Note:** The change document can contain various components (for example, UI and backend components). +1. The changes of your development team trigger the Jenkins pipeline. It builds and validates the changes and attaches them to the respective transport request. +1. As soon as the development process is completed, the change document in SAP Solution Manager can be set to status `to be tested` and all components can be transported to the test system. ![Hybrid Application Development Workflow](../images/Scenario_SolMan.png "Hybrid Application Development Workflow") ###### Hybrid Application Development Workflow diff --git a/documentation/docs/steps/checkChangeInDevelopment.md b/documentation/docs/steps/checkChangeInDevelopment.md index a3e30d438..e3396e75e 100644 --- a/documentation/docs/steps/checkChangeInDevelopment.md +++ b/documentation/docs/steps/checkChangeInDevelopment.md @@ -32,8 +32,7 @@ resource in an custom shared library. // inside the shared lib denoted by 'foo' the additional configuration file // needs to be located under 'resources' ('resoures/myConfig.yml') -prepareDefaultValues script: this, - customDefaults: 'myConfig.yml' +prepareDefaultValues script: this, customDefaults: 'myConfig.yml' ``` Example content of `'resources/myConfig.yml'` in branch `'master'` of the repository denoted by @@ -79,11 +78,13 @@ The parameters can also be provided when the step is invoked: // explict endpoint provided, we search for changeDocumentId // starting at the previous commit (HEAD~1) rather than on // 'origin/master' (the default). - checkChangeInDevelopment script:this - changeManagement: [ - endpoint: 'https:example.org/cm' - git: [ - from: 'HEAD~1' - ] - ] + checkChangeInDevelopment( + script: this + changeManagement: [ + endpoint: 'https:example.org/cm' + git: [ + from: 'HEAD~1' + ] + ] + ) ``` diff --git a/documentation/docs/steps/influxWriteData.md b/documentation/docs/steps/influxWriteData.md index 3842e4fca..8e288d224 100644 --- a/documentation/docs/steps/influxWriteData.md +++ b/documentation/docs/steps/influxWriteData.md @@ -43,7 +43,7 @@ Once you have started both docker containers and Influx and Grafana are running To setup your Jenkins you need to do two configuration steps: 1. Configure Jenkins (via Manage Jenkins) -2. Adapt pipeline configuration +1. Adapt pipeline configuration ### Configure Jenkins diff --git a/documentation/docs/steps/kanikoExecute.md b/documentation/docs/steps/kanikoExecute.md index 947d35cd4..4a369e55e 100644 --- a/documentation/docs/steps/kanikoExecute.md +++ b/documentation/docs/steps/kanikoExecute.md @@ -10,7 +10,7 @@ Kaniko expects a Docker `config.json` file containing the credential information You can create it like explained in the Docker Success Center in the articale about [How to generate a new auth in the config.json file](https://success.docker.com/article/generate-new-auth-in-config-json-file). Please copy this file and upload it to your Jenkins for example
-via _Jenkins_ -> _Credentials_ -> _System_ -> _Global credentials (unrestricted)_ -> _ Add Credentials_ -> +via _Jenkins_ -> _Credentials_ -> _System_ -> _Global credentials (unrestricted)_ -> _Add Credentials_ -> * Kind: _Secret file_ * File: upload your `config.json` file diff --git a/documentation/docs/steps/transportRequestCreate.md b/documentation/docs/steps/transportRequestCreate.md index 8d9a1bc81..0768d4d01 100644 --- a/documentation/docs/steps/transportRequestCreate.md +++ b/documentation/docs/steps/transportRequestCreate.md @@ -23,8 +23,7 @@ resource in an custom shared library. // inside the shared lib denoted by 'foo' the additional configuration file // needs to be located under 'resources' ('resoures/myConfig.yml') -prepareDefaultValues script: this, - customDefaults: 'myConfig.yml' +prepareDefaultValues script: this, customDefaults: 'myConfig.yml' ``` Example content of `'resources/myConfig.yml'` in branch `'master'` of the repository denoted by diff --git a/documentation/docs/steps/transportRequestUploadFile.md b/documentation/docs/steps/transportRequestUploadFile.md index 66facda78..da937eb3f 100644 --- a/documentation/docs/steps/transportRequestUploadFile.md +++ b/documentation/docs/steps/transportRequestUploadFile.md @@ -74,21 +74,25 @@ The parameters can also be provided when the step is invoked. For examples see b ```groovy // SOLMAN -transportRequestUploadFile script:this, - changeDocumentId: '001', // typically provided via git commit history - transportRequestId: '001', // typically provided via git commit history - applicationId: '001', - filePath: '/path', - changeManagement:[ - type: 'SOLMAN' - endpoint: 'https://example.org/cm' - ] +transportRequestUploadFile( + script: this, + changeDocumentId: '001', // typically provided via git commit history + transportRequestId: '001', // typically provided via git commit history + applicationId: '001', + filePath: '/path', + changeManagement: [ + type: 'SOLMAN' + endpoint: 'https://example.org/cm' + ] +) // CTS -transportRequestUploadFile script:this, - transportRequestId: '001', // typically provided via git commit history - filePath: '/path', - changeManagement:[ - type: 'CTS' - endpoint: 'https://example.org/cm' - ] +transportRequestUploadFile( + script: this, + transportRequestId: '001', // typically provided via git commit history + filePath: '/path', + changeManagement: [ + type: 'CTS' + endpoint: 'https://example.org/cm' + ] +) ``` diff --git a/pom.xml b/pom.xml index 228bbd356..295691205 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,9 @@ - + org.jenkins-ci.plugins plugin diff --git a/src/com/sap/piper/MtaUtils.groovy b/src/com/sap/piper/MtaUtils.groovy index ea308be18..5c294a2de 100644 --- a/src/com/sap/piper/MtaUtils.groovy +++ b/src/com/sap/piper/MtaUtils.groovy @@ -37,4 +37,3 @@ class MtaUtils { if (!script.fileExists(targetMtaDescriptor)) throw new AbortException("'${targetMtaDescriptor}' has not been generated.") } } - diff --git a/src/com/sap/piper/cm/ChangeManagement.groovy b/src/com/sap/piper/cm/ChangeManagement.groovy index de41edc70..bcf9600b3 100644 --- a/src/com/sap/piper/cm/ChangeManagement.groovy +++ b/src/com/sap/piper/cm/ChangeManagement.groovy @@ -421,16 +421,16 @@ public class ChangeManagement implements Serializable { String clientOpts = '') { String cmCommandLine = '#!/bin/bash' if(clientOpts) { - cmCommandLine += """ - export CMCLIENT_OPTS="${clientOpts}" """ + cmCommandLine += """ + export CMCLIENT_OPTS="${clientOpts}" """ } cmCommandLine += """ - cmclient -e '$endpoint' \ - -u '$username' \ - -p '$password' \ - -t ${type} \ - ${command} ${(args as Iterable).join(' ')} - """ + cmclient -e '$endpoint' \ + -u '$username' \ + -p '$password' \ + -t ${type} \ + ${command} ${(args as Iterable).join(' ')} + """ return cmCommandLine } } diff --git a/src/com/sap/piper/cm/StepHelpers.groovy b/src/com/sap/piper/cm/StepHelpers.groovy index f48c29107..11542522b 100644 --- a/src/com/sap/piper/cm/StepHelpers.groovy +++ b/src/com/sap/piper/cm/StepHelpers.groovy @@ -23,7 +23,7 @@ public class StepHelpers { } script.echo "[INFO] Retrieving transport request id from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." + - " Searching for pattern '${configuration.changeManagement.transportRequestLabel}'. Searching with format '${configuration.changeManagement.git.format}'." + " Searching for pattern '${configuration.changeManagement.transportRequestLabel}'. Searching with format '${configuration.changeManagement.git.format}'." try { transportRequestId = cm.getTransportRequestId( @@ -62,7 +62,7 @@ public class StepHelpers { } script.echo "[INFO] Retrieving ChangeDocumentId from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." + - "Searching for pattern '${configuration.changeManagement.changeDocumentLabel}'. Searching with format '${configuration.changeManagement.git.format}'." + "Searching for pattern '${configuration.changeManagement.changeDocumentLabel}'. Searching with format '${configuration.changeManagement.git.format}'." try { changeDocumentId = cm.getChangeDocumentId( @@ -91,15 +91,15 @@ public class StepHelpers { backendType = configuration.changeManagement.type as BackendType } catch(IllegalArgumentException e) { script.error "Invalid backend type: '${configuration.changeManagement.type}'. " + - "Valid values: [${BackendType.values().join(', ')}]. " + - "Configuration: 'changeManagement/type'." + "Valid values: [${BackendType.values().join(', ')}]. " + + "Configuration: 'changeManagement/type'." } if (backendType == BackendType.NONE) { script.echo "[INFO] Change management integration intentionally switched off. " + - "In order to enable it provide 'changeManagement/type with one of " + - "[${BackendType.values().minus(BackendType.NONE).join(', ')}] and maintain " + - "other required properties like 'endpoint', 'credentialsId'." + "In order to enable it provide 'changeManagement/type with one of " + + "[${BackendType.values().minus(BackendType.NONE).join(', ')}] and maintain " + + "other required properties like 'endpoint', 'credentialsId'." } return backendType diff --git a/vars/artifactSetVersion.groovy b/vars/artifactSetVersion.groovy index 6bbc11a54..dd6139bec 100644 --- a/vars/artifactSetVersion.groovy +++ b/vars/artifactSetVersion.groovy @@ -169,9 +169,9 @@ void call(Map parameters = [:], Closure body = null) { try { sh """#!/bin/bash - git add . - git ${gitConfig} commit -m 'update version ${newVersion}' - git tag ${config.tagPrefix}${newVersion}""" + git add . + git ${gitConfig} commit -m 'update version ${newVersion}' + git tag ${config.tagPrefix}${newVersion}""" config.gitCommitId = gitUtils.getGitCommitIdOrNull() } catch (e) { error "[${STEP_NAME}]git commit and tag failed: ${e}" diff --git a/vars/transportRequestUploadFile.groovy b/vars/transportRequestUploadFile.groovy index 048ba93ab..657351177 100644 --- a/vars/transportRequestUploadFile.groovy +++ b/vars/transportRequestUploadFile.groovy @@ -177,9 +177,9 @@ void call(parameters = [:]) { "Change document id not provided (parameter: \'changeDocumentId\' or via commit history).") } configuration = configHelper - .withMandatoryProperty('transportRequestId', - "Transport request id not provided (parameter: \'transportRequestId\' or via commit history).") - .use() + .withMandatoryProperty('transportRequestId', + "Transport request id not provided (parameter: \'transportRequestId\' or via commit history).") + .use() def uploadingMessage = ['[INFO] Uploading file ' + "'${backendType == BackendType.RFC ? configuration.applicationUrl : configuration.filePath}' " + From d21dd9c87b51a2d9e801167c04d1c15b09c33a1c Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Mon, 20 May 2019 09:32:49 +0200 Subject: [PATCH 14/67] Dokumentation: Introduce Jenkins plugin dependencies --- documentation/bin/createDocu.groovy | 9 ++++++++- documentation/docs/steps/neoDeploy.md | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/documentation/bin/createDocu.groovy b/documentation/bin/createDocu.groovy index 7dfe920aa..c20c9901f 100644 --- a/documentation/bin/createDocu.groovy +++ b/documentation/bin/createDocu.groovy @@ -13,6 +13,12 @@ import com.sap.piper.MapUtils // class TemplateHelper { + static createDependencyList() { + def t = '' + t += 'The step depends on the following Jenkins plugins' + return t + } + static createParametersTable(Map parameters) { def t = '' @@ -525,7 +531,8 @@ void renderStep(stepName, stepProperties) { docGenStepName : stepName, docGenDescription : 'Description\n\n' + stepProperties.description, docGenParameters : 'Parameters\n\n' + TemplateHelper.createParametersSection(stepProperties.parameters), - docGenConfiguration : 'Step configuration\n\n' + TemplateHelper.createStepConfigurationSection(stepProperties.parameters) + docGenConfiguration : 'Step configuration\n\n' + TemplateHelper.createStepConfigurationSection(stepProperties.parameters), + docDependencies : 'Dependencies\n\n' + TemplateHelper.createDependencyList() ] def template = new StreamingTemplateEngine().createTemplate(theStepDocu.text) String text = template.make(binding) diff --git a/documentation/docs/steps/neoDeploy.md b/documentation/docs/steps/neoDeploy.md index 3fb095615..5b98e0ff8 100644 --- a/documentation/docs/steps/neoDeploy.md +++ b/documentation/docs/steps/neoDeploy.md @@ -14,6 +14,8 @@ * **Java 8 or compatible version** - needed by the *Neo-Java-Web-SDK*. Java environment needs to be properly configured (JAVA_HOME, java exectutable contained in path). +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} From 818297aef02e3a1f53bf3c89484362cdc3ed7c79 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Mon, 20 May 2019 11:16:59 +0200 Subject: [PATCH 15/67] wip --- documentation/bin/createDocu.groovy | 33 +++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/documentation/bin/createDocu.groovy b/documentation/bin/createDocu.groovy index c20c9901f..797cc4ce8 100644 --- a/documentation/bin/createDocu.groovy +++ b/documentation/bin/createDocu.groovy @@ -1,5 +1,6 @@ import groovy.io.FileType import groovy.json.JsonOutput +import groovy.json.JsonSlurper import org.yaml.snakeyaml.Yaml import org.codehaus.groovy.control.CompilerConfiguration import com.sap.piper.GenerateDocumentation @@ -13,9 +14,11 @@ import com.sap.piper.MapUtils // class TemplateHelper { - static createDependencyList() { + static createDependencyList(Set deps) { + System.err << "[DEBUG] rendering dependencies ${deps}\n" def t = '' - t += 'The step depends on the following Jenkins plugins' + t += 'The step depends on the following Jenkins plugins\n\n' + deps.each { dep -> t += "* ${dep}\n" } return t } @@ -527,13 +530,18 @@ void renderStep(stepName, stepProperties) { return } + System.err << "DEPS CLASS: ${stepProperties.dependencies}/${stepProperties.dependencies.class.name}\n" + def binding = [ docGenStepName : stepName, docGenDescription : 'Description\n\n' + stepProperties.description, docGenParameters : 'Parameters\n\n' + TemplateHelper.createParametersSection(stepProperties.parameters), docGenConfiguration : 'Step configuration\n\n' + TemplateHelper.createStepConfigurationSection(stepProperties.parameters), - docDependencies : 'Dependencies\n\n' + TemplateHelper.createDependencyList() + docDependencies : 'Dependencies\n\n' + TemplateHelper.createDependencyList(stepProperties.dependencies) ] + + System.err << "DEPS in BINDING ${binding.docDependencies} \n" + def template = new StreamingTemplateEngine().createTemplate(theStepDocu.text) String text = template.make(binding) @@ -568,6 +576,7 @@ def handleStep(stepName, prepareDefaultValuesStep, gse, customDefaults) { File theStep = new File(stepsDir, "${stepName}.groovy") File theStepDocu = new File(stepsDocuDir, "${stepName}.md") + File theStepDeps = new File('jenkins_workspace/result.json') if(!theStepDocu.exists()) { System.err << "[WARNING] step docu input file for step '${stepName}' is missing.\n" @@ -619,7 +628,23 @@ def handleStep(stepName, prepareDefaultValuesStep, gse, customDefaults) { // 'dependentConfig' is only present here for internal reasons and that entry is removed at // end of method. - def step = [parameters:[:], dependentConfig: [:]] + def step = [ + parameters:[:], + dependencies: (Set)[], + dependentConfig: [:] + ] + + // WWWWWWW + if(theStepDeps.exists()) { + def deps = new JsonSlurper().parse(theStepDeps) + System.err << "[DEBUG] Dependencies (${theStepDeps}) parsed.\n" + step.dependencies.addAll(deps[stepName].collect { k, v -> k }) + def _deps = deps[stepName].collect { k, v -> k } + System.err << "[DEBUG] DEPS: $step.dependencies}\n" + System.err << "[DEBUG] _DEPS: ${_deps}" + } else { + System.err << "[DEBUG] Dependencies (${theStepDeps}) not found.\n" + } // // START special handling for 'script' parameter From 0f8148a7cd5dd8e10227f8c7b27e81cb280c1ad4 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Mon, 20 May 2019 11:43:37 +0200 Subject: [PATCH 16/67] wip --- documentation/bin/createDocu.groovy | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/documentation/bin/createDocu.groovy b/documentation/bin/createDocu.groovy index 797cc4ce8..32aace93f 100644 --- a/documentation/bin/createDocu.groovy +++ b/documentation/bin/createDocu.groovy @@ -18,7 +18,15 @@ class TemplateHelper { System.err << "[DEBUG] rendering dependencies ${deps}\n" def t = '' t += 'The step depends on the following Jenkins plugins\n\n' - deps.each { dep -> t += "* ${dep}\n" } + def filteredDeps = deps.findAll { dep -> dep != 'UNIDENTIFIED' } + if(filteredDeps.isEmpty()) { + t += '* <none>\n' + } else { + filteredDeps + .sort() + .each { dep -> t += "* ${dep}\n" } + } + t += '\nTransitive dependencies are omitted.\n\nThis is a beta feature. The list might be incomplete.' return t } @@ -537,7 +545,7 @@ void renderStep(stepName, stepProperties) { docGenDescription : 'Description\n\n' + stepProperties.description, docGenParameters : 'Parameters\n\n' + TemplateHelper.createParametersSection(stepProperties.parameters), docGenConfiguration : 'Step configuration\n\n' + TemplateHelper.createStepConfigurationSection(stepProperties.parameters), - docDependencies : 'Dependencies\n\n' + TemplateHelper.createDependencyList(stepProperties.dependencies) + docDependencies : 'Dependencies (beta)\n\n' + TemplateHelper.createDependencyList(stepProperties.dependencies) ] System.err << "DEPS in BINDING ${binding.docDependencies} \n" From 955bd63495f30ab65ee6262639f70644de99a464 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Mon, 20 May 2019 11:45:28 +0200 Subject: [PATCH 17/67] remove syserrs and put comments --- documentation/bin/createDocu.groovy | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/documentation/bin/createDocu.groovy b/documentation/bin/createDocu.groovy index 32aace93f..966688a05 100644 --- a/documentation/bin/createDocu.groovy +++ b/documentation/bin/createDocu.groovy @@ -15,7 +15,6 @@ import com.sap.piper.MapUtils class TemplateHelper { static createDependencyList(Set deps) { - System.err << "[DEBUG] rendering dependencies ${deps}\n" def t = '' t += 'The step depends on the following Jenkins plugins\n\n' def filteredDeps = deps.findAll { dep -> dep != 'UNIDENTIFIED' } @@ -538,8 +537,6 @@ void renderStep(stepName, stepProperties) { return } - System.err << "DEPS CLASS: ${stepProperties.dependencies}/${stepProperties.dependencies.class.name}\n" - def binding = [ docGenStepName : stepName, docGenDescription : 'Description\n\n' + stepProperties.description, @@ -548,8 +545,6 @@ void renderStep(stepName, stepProperties) { docDependencies : 'Dependencies (beta)\n\n' + TemplateHelper.createDependencyList(stepProperties.dependencies) ] - System.err << "DEPS in BINDING ${binding.docDependencies} \n" - def template = new StreamingTemplateEngine().createTemplate(theStepDocu.text) String text = template.make(binding) @@ -642,16 +637,12 @@ def handleStep(stepName, prepareDefaultValuesStep, gse, customDefaults) { dependentConfig: [:] ] - // WWWWWWW + // + // provide dependencies to Jenkins plugins if(theStepDeps.exists()) { def deps = new JsonSlurper().parse(theStepDeps) - System.err << "[DEBUG] Dependencies (${theStepDeps}) parsed.\n" step.dependencies.addAll(deps[stepName].collect { k, v -> k }) def _deps = deps[stepName].collect { k, v -> k } - System.err << "[DEBUG] DEPS: $step.dependencies}\n" - System.err << "[DEBUG] _DEPS: ${_deps}" - } else { - System.err << "[DEBUG] Dependencies (${theStepDeps}) not found.\n" } // From 50a62c9b3e3bdcf4eb89d9e89df90b5cea8b65eb Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 09:51:27 +0200 Subject: [PATCH 18/67] Introduce label for Jenkins plugin dependencies --- documentation/docs/steps/artifactSetVersion.md | 2 ++ documentation/docs/steps/batsExecuteTests.md | 2 ++ documentation/docs/steps/checkChangeInDevelopment.md | 2 ++ documentation/docs/steps/checksPublishResults.md | 2 ++ documentation/docs/steps/cloudFoundryDeploy.md | 2 ++ documentation/docs/steps/containerExecuteStructureTests.md | 2 ++ documentation/docs/steps/detectExecuteScan.md | 2 ++ documentation/docs/steps/dockerExecute.md | 2 ++ documentation/docs/steps/dockerExecuteOnKubernetes.md | 2 ++ documentation/docs/steps/durationMeasure.md | 2 ++ documentation/docs/steps/gaugeExecuteTests.md | 2 ++ documentation/docs/steps/githubPublishRelease.md | 2 ++ documentation/docs/steps/handlePipelineStepErrors.md | 2 ++ documentation/docs/steps/healthExecuteCheck.md | 2 ++ documentation/docs/steps/influxWriteData.md | 2 ++ documentation/docs/steps/kanikoExecute.md | 2 ++ documentation/docs/steps/karmaExecuteTests.md | 2 ++ documentation/docs/steps/mailSendNotification.md | 2 ++ documentation/docs/steps/mavenExecute.md | 2 ++ documentation/docs/steps/mtaBuild.md | 2 ++ documentation/docs/steps/multicloudDeploy.md | 2 ++ documentation/docs/steps/neoDeploy.md | 2 ++ documentation/docs/steps/newmanExecute.md | 2 ++ documentation/docs/steps/npmExecute.md | 2 ++ documentation/docs/steps/pipelineExecute.md | 2 ++ documentation/docs/steps/pipelineRestartSteps.md | 2 ++ documentation/docs/steps/pipelineStashFiles.md | 2 ++ documentation/docs/steps/pipelineStashFilesAfterBuild.md | 2 ++ documentation/docs/steps/pipelineStashFilesBeforeBuild.md | 2 ++ documentation/docs/steps/piperPipelineStagePost.md | 2 ++ documentation/docs/steps/prepareDefaultValues.md | 2 ++ documentation/docs/steps/seleniumExecuteTests.md | 2 ++ documentation/docs/steps/setupCommonPipelineEnvironment.md | 2 ++ documentation/docs/steps/slackSendNotification.md | 2 ++ documentation/docs/steps/snykExecute.md | 2 ++ documentation/docs/steps/sonarExecuteScan.md | 2 ++ documentation/docs/steps/testsPublishResults.md | 2 ++ documentation/docs/steps/transportRequestCreate.md | 2 ++ documentation/docs/steps/transportRequestRelease.md | 2 ++ documentation/docs/steps/transportRequestUploadFile.md | 2 ++ documentation/docs/steps/uiVeri5ExecuteTests.md | 2 ++ documentation/docs/steps/whitesourceExecuteScan.md | 2 ++ 42 files changed, 84 insertions(+) diff --git a/documentation/docs/steps/artifactSetVersion.md b/documentation/docs/steps/artifactSetVersion.md index 1591df91b..cc4fcba01 100644 --- a/documentation/docs/steps/artifactSetVersion.md +++ b/documentation/docs/steps/artifactSetVersion.md @@ -6,6 +6,8 @@ none +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/batsExecuteTests.md b/documentation/docs/steps/batsExecuteTests.md index c144245b0..55d47a6fb 100644 --- a/documentation/docs/steps/batsExecuteTests.md +++ b/documentation/docs/steps/batsExecuteTests.md @@ -6,6 +6,8 @@ You need to have a Bats test file. By default you would put this into directory `src/test` within your source code repository. +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/checkChangeInDevelopment.md b/documentation/docs/steps/checkChangeInDevelopment.md index e3396e75e..abac3bf7f 100644 --- a/documentation/docs/steps/checkChangeInDevelopment.md +++ b/documentation/docs/steps/checkChangeInDevelopment.md @@ -6,6 +6,8 @@ * **[Change Management Client 2.0.0 or compatible version](http://central.maven.org/maven2/com/sap/devops/cmclient/dist.cli/)** - available for download on Maven Central. +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/checksPublishResults.md b/documentation/docs/steps/checksPublishResults.md index fc5fa9ba1..5c37fe49d 100644 --- a/documentation/docs/steps/checksPublishResults.md +++ b/documentation/docs/steps/checksPublishResults.md @@ -13,6 +13,8 @@ * [warnings](https://plugins.jenkins.io/warnings) * [core](https://plugins.jenkins.io/core) +## ${docDependencies} + ## ${docGenParameters} ### aggregation diff --git a/documentation/docs/steps/cloudFoundryDeploy.md b/documentation/docs/steps/cloudFoundryDeploy.md index aea6e46a8..f2c16fed6 100644 --- a/documentation/docs/steps/cloudFoundryDeploy.md +++ b/documentation/docs/steps/cloudFoundryDeploy.md @@ -9,6 +9,8 @@ ![Jenkins credentials configuration](../images/cf_credentials.png) +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/containerExecuteStructureTests.md b/documentation/docs/steps/containerExecuteStructureTests.md index 6fef19680..838a33f32 100644 --- a/documentation/docs/steps/containerExecuteStructureTests.md +++ b/documentation/docs/steps/containerExecuteStructureTests.md @@ -6,6 +6,8 @@ Test configuration is available. +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/detectExecuteScan.md b/documentation/docs/steps/detectExecuteScan.md index e92b1db5b..52553642b 100644 --- a/documentation/docs/steps/detectExecuteScan.md +++ b/documentation/docs/steps/detectExecuteScan.md @@ -9,6 +9,8 @@ You need to store the API token for the Detect service as _'Secret text'_ creden !!! note "minimum plugin requirement" This step requires [synopsys-detect-plugin](https://github.com/jenkinsci/synopsys-detect-plugin) with at least version `2.0.0`. +## ${docDependencies} + ## Example ```groovy diff --git a/documentation/docs/steps/dockerExecute.md b/documentation/docs/steps/dockerExecute.md index 9ed77b9a4..576718d1d 100644 --- a/documentation/docs/steps/dockerExecute.md +++ b/documentation/docs/steps/dockerExecute.md @@ -2,6 +2,8 @@ ## ${docGenDescription} +## ${docDependencies} + ## ${docGenParameters} ## Kubernetes support diff --git a/documentation/docs/steps/dockerExecuteOnKubernetes.md b/documentation/docs/steps/dockerExecuteOnKubernetes.md index 0c0ac7460..0ae2dbaf3 100644 --- a/documentation/docs/steps/dockerExecuteOnKubernetes.md +++ b/documentation/docs/steps/dockerExecuteOnKubernetes.md @@ -9,6 +9,8 @@ ![Jenkins environment variable configuration](../images/k8s_env.png) +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/durationMeasure.md b/documentation/docs/steps/durationMeasure.md index 87c7e35e1..8a6c0684c 100644 --- a/documentation/docs/steps/durationMeasure.md +++ b/documentation/docs/steps/durationMeasure.md @@ -2,6 +2,8 @@ ## ${docGenDescription} +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/gaugeExecuteTests.md b/documentation/docs/steps/gaugeExecuteTests.md index 05b7223e5..c654e1788 100644 --- a/documentation/docs/steps/gaugeExecuteTests.md +++ b/documentation/docs/steps/gaugeExecuteTests.md @@ -6,6 +6,8 @@ none +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/githubPublishRelease.md b/documentation/docs/steps/githubPublishRelease.md index 304eccce0..6c9e150d1 100644 --- a/documentation/docs/steps/githubPublishRelease.md +++ b/documentation/docs/steps/githubPublishRelease.md @@ -8,6 +8,8 @@ You need to create a personal access token within GitHub and add this to the Jen Please see [GitHub documentation for details about creating the personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/handlePipelineStepErrors.md b/documentation/docs/steps/handlePipelineStepErrors.md index 745c46bfa..59706f03b 100644 --- a/documentation/docs/steps/handlePipelineStepErrors.md +++ b/documentation/docs/steps/handlePipelineStepErrors.md @@ -6,6 +6,8 @@ none +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/healthExecuteCheck.md b/documentation/docs/steps/healthExecuteCheck.md index 828b96382..8547fec79 100644 --- a/documentation/docs/steps/healthExecuteCheck.md +++ b/documentation/docs/steps/healthExecuteCheck.md @@ -12,6 +12,8 @@ Endpoint for health check is configured. !!! tip If using Spring Boot framework, ideally the provided `/health` endpoint is used and extended by development. Further information can be found in the [Spring Boot documenation for Endpoints](http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html) +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/influxWriteData.md b/documentation/docs/steps/influxWriteData.md index 8e288d224..c7087cd9a 100644 --- a/documentation/docs/steps/influxWriteData.md +++ b/documentation/docs/steps/influxWriteData.md @@ -4,6 +4,8 @@ ## Prerequisites +## ${docDependencies} + ### Setting up InfluxDB with Grafana The easiest way to start with is using the available official docker images. diff --git a/documentation/docs/steps/kanikoExecute.md b/documentation/docs/steps/kanikoExecute.md index 4a369e55e..7f48a7580 100644 --- a/documentation/docs/steps/kanikoExecute.md +++ b/documentation/docs/steps/kanikoExecute.md @@ -16,6 +16,8 @@ via _Jenkins_ -> _Credentials_ -> _System_ -> _Global credentials (unrestricted) * File: upload your `config.json` file * ID: specify id which you then use for the configuration of `dockerConfigJsonCredentialsId` (see below) +## ${docDependencies} + ## Example ```groovy diff --git a/documentation/docs/steps/karmaExecuteTests.md b/documentation/docs/steps/karmaExecuteTests.md index f64a4a51b..fc0e60ebc 100644 --- a/documentation/docs/steps/karmaExecuteTests.md +++ b/documentation/docs/steps/karmaExecuteTests.md @@ -7,6 +7,8 @@ * **running Karma tests** - have a NPM module with running tests executed with Karma * **configured WebDriver** - have the [`karma-webdriver-launcher`](https://github.com/karma-runner/karma-webdriver-launcher) package installed and a custom, WebDriver-based browser configured in Karma +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/mailSendNotification.md b/documentation/docs/steps/mailSendNotification.md index 5db620256..d167ac42a 100644 --- a/documentation/docs/steps/mailSendNotification.md +++ b/documentation/docs/steps/mailSendNotification.md @@ -6,6 +6,8 @@ none +## ${docDependencies} + ## Example Usage of pipeline step: diff --git a/documentation/docs/steps/mavenExecute.md b/documentation/docs/steps/mavenExecute.md index a8231fac3..40f2544aa 100644 --- a/documentation/docs/steps/mavenExecute.md +++ b/documentation/docs/steps/mavenExecute.md @@ -2,6 +2,8 @@ ## ${docGenDescription} +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/mtaBuild.md b/documentation/docs/steps/mtaBuild.md index 3f614c58a..bd8e323fc 100644 --- a/documentation/docs/steps/mtaBuild.md +++ b/documentation/docs/steps/mtaBuild.md @@ -10,6 +10,8 @@ While using a custom docker file, ensure that the following tools are installed: * **Java 8 or compatible version** - necessary to run the *MTA Archive Builder* itself and to build Java modules. * **NodeJS installed** - the MTA Builder uses `npm` to download node module dependencies such as `grunt`. +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/multicloudDeploy.md b/documentation/docs/steps/multicloudDeploy.md index 403d4c87c..06ab7d695 100644 --- a/documentation/docs/steps/multicloudDeploy.md +++ b/documentation/docs/steps/multicloudDeploy.md @@ -2,6 +2,8 @@ ## ${docGenDescription} +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/neoDeploy.md b/documentation/docs/steps/neoDeploy.md index 5b98e0ff8..fecea0ab2 100644 --- a/documentation/docs/steps/neoDeploy.md +++ b/documentation/docs/steps/neoDeploy.md @@ -16,6 +16,8 @@ ## ${docDependencies} +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/newmanExecute.md b/documentation/docs/steps/newmanExecute.md index cb47c03f1..39fdc389a 100644 --- a/documentation/docs/steps/newmanExecute.md +++ b/documentation/docs/steps/newmanExecute.md @@ -6,6 +6,8 @@ * prepared Postman with a test collection +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/npmExecute.md b/documentation/docs/steps/npmExecute.md index 45d58ffb7..236c52106 100644 --- a/documentation/docs/steps/npmExecute.md +++ b/documentation/docs/steps/npmExecute.md @@ -3,6 +3,8 @@ ## ${docGenDescription} +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/pipelineExecute.md b/documentation/docs/steps/pipelineExecute.md index 4720400e9..fa33d2df9 100644 --- a/documentation/docs/steps/pipelineExecute.md +++ b/documentation/docs/steps/pipelineExecute.md @@ -6,6 +6,8 @@ none +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/pipelineRestartSteps.md b/documentation/docs/steps/pipelineRestartSteps.md index 682758496..dae4f3733 100644 --- a/documentation/docs/steps/pipelineRestartSteps.md +++ b/documentation/docs/steps/pipelineRestartSteps.md @@ -6,6 +6,8 @@ none +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/pipelineStashFiles.md b/documentation/docs/steps/pipelineStashFiles.md index eff7e57d5..816e83609 100644 --- a/documentation/docs/steps/pipelineStashFiles.md +++ b/documentation/docs/steps/pipelineStashFiles.md @@ -6,6 +6,8 @@ none +## ${docDependencies} + ## ${docGenParameters} Details: diff --git a/documentation/docs/steps/pipelineStashFilesAfterBuild.md b/documentation/docs/steps/pipelineStashFilesAfterBuild.md index ded5fb286..d461f3702 100644 --- a/documentation/docs/steps/pipelineStashFilesAfterBuild.md +++ b/documentation/docs/steps/pipelineStashFilesAfterBuild.md @@ -6,6 +6,8 @@ none +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/pipelineStashFilesBeforeBuild.md b/documentation/docs/steps/pipelineStashFilesBeforeBuild.md index ded5fb286..d461f3702 100644 --- a/documentation/docs/steps/pipelineStashFilesBeforeBuild.md +++ b/documentation/docs/steps/pipelineStashFilesBeforeBuild.md @@ -6,6 +6,8 @@ none +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/piperPipelineStagePost.md b/documentation/docs/steps/piperPipelineStagePost.md index 63991c134..1aaca01e0 100644 --- a/documentation/docs/steps/piperPipelineStagePost.md +++ b/documentation/docs/steps/piperPipelineStagePost.md @@ -2,6 +2,8 @@ ## ${docGenDescription} +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/prepareDefaultValues.md b/documentation/docs/steps/prepareDefaultValues.md index 4007fc2ab..fc41a5404 100644 --- a/documentation/docs/steps/prepareDefaultValues.md +++ b/documentation/docs/steps/prepareDefaultValues.md @@ -2,6 +2,8 @@ ## ${docGenDescription} +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/seleniumExecuteTests.md b/documentation/docs/steps/seleniumExecuteTests.md index 51fc4a057..5a9ea224c 100644 --- a/documentation/docs/steps/seleniumExecuteTests.md +++ b/documentation/docs/steps/seleniumExecuteTests.md @@ -6,6 +6,8 @@ none +## ${docDependencies} + ## Example ```groovy diff --git a/documentation/docs/steps/setupCommonPipelineEnvironment.md b/documentation/docs/steps/setupCommonPipelineEnvironment.md index 8f847a879..1b703f963 100644 --- a/documentation/docs/steps/setupCommonPipelineEnvironment.md +++ b/documentation/docs/steps/setupCommonPipelineEnvironment.md @@ -6,6 +6,8 @@ * A **configuration file** with properties. The property values are used as default values in many pipeline steps. +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/slackSendNotification.md b/documentation/docs/steps/slackSendNotification.md index 186617ec3..4342e4a09 100644 --- a/documentation/docs/steps/slackSendNotification.md +++ b/documentation/docs/steps/slackSendNotification.md @@ -8,6 +8,8 @@ * *secret text* Jenkins credentials with the Slack token * Installed and configured [Jenkins Slack plugin](https://github.com/jenkinsci/slack-plugin#install-instructions-for-slack). +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/snykExecute.md b/documentation/docs/steps/snykExecute.md index d6f977b57..2508ceb53 100644 --- a/documentation/docs/steps/snykExecute.md +++ b/documentation/docs/steps/snykExecute.md @@ -7,6 +7,8 @@ * **Snyk account** - have an account on snyk.io * **Snyk token** - have a Snyk user token +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/sonarExecuteScan.md b/documentation/docs/steps/sonarExecuteScan.md index 486ae3c17..c1a8e3043 100644 --- a/documentation/docs/steps/sonarExecuteScan.md +++ b/documentation/docs/steps/sonarExecuteScan.md @@ -7,6 +7,8 @@ - The project needs a `sonar-project.properties` file that describes the project and defines certain settings, see [here](https://docs.sonarqube.org/display/SCAN/Advanced+SonarQube+Scanner+Usages#AdvancedSonarQubeScannerUsages-Multi-moduleProjectStructure). - A SonarQube instance needs to be defined in the Jenkins. +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/testsPublishResults.md b/documentation/docs/steps/testsPublishResults.md index 7c6343621..2dca45ce5 100644 --- a/documentation/docs/steps/testsPublishResults.md +++ b/documentation/docs/steps/testsPublishResults.md @@ -11,6 +11,8 @@ * [cobertura](https://plugins.jenkins.io/cobertura) * [performance](https://plugins.jenkins.io/performance) +## ${docDependencies} + ## Pipeline configuration none diff --git a/documentation/docs/steps/transportRequestCreate.md b/documentation/docs/steps/transportRequestCreate.md index 0768d4d01..01904ceb9 100644 --- a/documentation/docs/steps/transportRequestCreate.md +++ b/documentation/docs/steps/transportRequestCreate.md @@ -7,6 +7,8 @@ * **[Change Management Client 2.0.0 or compatible version](http://central.maven.org/maven2/com/sap/devops/cmclient/dist.cli/)** - available for download on Maven Central. * Solution Manager version `ST720 SP08` or newer. +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/transportRequestRelease.md b/documentation/docs/steps/transportRequestRelease.md index 8902d603d..6b08edbd9 100644 --- a/documentation/docs/steps/transportRequestRelease.md +++ b/documentation/docs/steps/transportRequestRelease.md @@ -6,6 +6,8 @@ * **[Change Management Client 2.0.0 or compatible version](http://central.maven.org/maven2/com/sap/devops/cmclient/dist.cli/)** - available for download on Maven Central. +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/transportRequestUploadFile.md b/documentation/docs/steps/transportRequestUploadFile.md index da937eb3f..191ac8f52 100644 --- a/documentation/docs/steps/transportRequestUploadFile.md +++ b/documentation/docs/steps/transportRequestUploadFile.md @@ -6,6 +6,8 @@ * **[Change Management Client 2.0.0 or compatible version](http://central.maven.org/maven2/com/sap/devops/cmclient/dist.cli/)** - available for download on Maven Central. +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/uiVeri5ExecuteTests.md b/documentation/docs/steps/uiVeri5ExecuteTests.md index 9355e912e..9b18898d8 100644 --- a/documentation/docs/steps/uiVeri5ExecuteTests.md +++ b/documentation/docs/steps/uiVeri5ExecuteTests.md @@ -4,6 +4,8 @@ ## Prerequisites +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/whitesourceExecuteScan.md b/documentation/docs/steps/whitesourceExecuteScan.md index 1c92aedbd..53c33e4f9 100644 --- a/documentation/docs/steps/whitesourceExecuteScan.md +++ b/documentation/docs/steps/whitesourceExecuteScan.md @@ -8,6 +8,8 @@ Your company has registered an account with WhiteSource and you have enabled the access to your organization in WhiteSource via dedicated privileges. Scanning your products without adequate user level access protection imposed on the WhiteSource backend would simply allow access based on the organization token. +## ${docDependencies} + ## ${docGenParameters} ## ${docGenConfiguration} From 8c2820a045f1fb9d3d809a29d4939aa376b60a89 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 09:51:53 +0200 Subject: [PATCH 19/67] Include docu gen in resolve Plugins --- resolvePlugins.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resolvePlugins.sh b/resolvePlugins.sh index fb41c634e..959f59679 100755 --- a/resolvePlugins.sh +++ b/resolvePlugins.sh @@ -34,3 +34,6 @@ docker run \ [ -f "${RESULT}" ] || { echo "Result file containing step to plugin mapping not found (${RESULT})."; exit 1; } which -s jq && jq 'keys[] as $k | .[$k] | keys as $v | $k, [$v]' "${RESULT}" + +documentation/bin/createDocu.sh $* +docker run --rm -it -v `pwd`:/docs -w /docs/documentation squidfunk/mkdocs-material:3.0.4 build --clean --verbose --strict From 71cfae4409ed11b903a29c1c468d99146c979383 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 10:48:02 +0200 Subject: [PATCH 20/67] Resolved plugins as links --- documentation/bin/createDocu.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/bin/createDocu.groovy b/documentation/bin/createDocu.groovy index 966688a05..b7840f446 100644 --- a/documentation/bin/createDocu.groovy +++ b/documentation/bin/createDocu.groovy @@ -23,7 +23,7 @@ class TemplateHelper { } else { filteredDeps .sort() - .each { dep -> t += "* ${dep}\n" } + .each { dep -> t += "* [${dep}](https://plugins.jenkins.io/${dep})\n" } } t += '\nTransitive dependencies are omitted.\n\nThis is a beta feature. The list might be incomplete.' return t From 3ec785bf44a22a145ecb4b0c604825a225f54797 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 11:16:06 +0200 Subject: [PATCH 21/67] handle some calls via exception list --- jenkins_workspace/Jenkinsfile | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/jenkins_workspace/Jenkinsfile b/jenkins_workspace/Jenkinsfile index 0636fbf7b..7081ae5ff 100644 --- a/jenkins_workspace/Jenkinsfile +++ b/jenkins_workspace/Jenkinsfile @@ -3,6 +3,17 @@ import groovy.json.JsonSlurper import jenkins.model.Jenkins +unresolvableCalls = [ + podTemplate:'kubernetes', + container: 'kubernetes', + + docker: 'docker-plugin', + + usernamePassword: 'credentials-binding', + string: 'credentials-binding', + file: 'credentials-binding', +] + node() { stage('Resolve Plugins') { try { @@ -26,7 +37,10 @@ def resolvePlugins() { def resolvedPlugins = [:] for(def call in step.value) { def resolvedPlugin = resolvePlugin(call) - if (! resolvedPlugin) resolvedPlugin = 'UNIDENTIFIED' + if (! resolvedPlugin) { + resolvedPlugin = unresolvableCalls[call] + if(! resolvedPlugin) resolvedPlugin = 'UNIDENTIFIED' + } if(resolvedPlugins[resolvedPlugin] == null) resolvedPlugins[resolvedPlugin] = (Set)[] resolvedPlugins[resolvedPlugin] << call From a911cc400e9c5ade40ae097ef7d933c29f55fc10 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 11:53:10 +0200 Subject: [PATCH 22/67] run the tests (required for getting plugins deps) --- documentation/bin/createDocu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/bin/createDocu.sh b/documentation/bin/createDocu.sh index 3f20bbc34..ed8cd06a9 100755 --- a/documentation/bin/createDocu.sh +++ b/documentation/bin/createDocu.sh @@ -4,5 +4,5 @@ d=$(dirname "$0") [ ! -z "$d" ] && d="$d/" export CLASSPATH_FILE='target/cp.txt' -mvn compile dependency:build-classpath -Dmdep.outputFile=${CLASSPATH_FILE} > /dev/null 2>&1 +mvn clean test dependency:build-classpath -Dmdep.outputFile=${CLASSPATH_FILE} > /dev/null 2>&1 groovy -cp "target/classes:$(cat $CLASSPATH_FILE)" "${d}createDocu" "${@}" From 6b4ac4bffafe6bfec2fd551df3387bc739b5dc2e Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 11:53:33 +0200 Subject: [PATCH 23/67] input and output file as parameter --- resolvePlugins.sh | 2 +- steps.groovy | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/resolvePlugins.sh b/resolvePlugins.sh index 959f59679..2f270faf2 100755 --- a/resolvePlugins.sh +++ b/resolvePlugins.sh @@ -1,7 +1,7 @@ #!/bin/bash mvn clean test -groovy steps.groovy +groovy steps.groovy -in target/trackedCalls.json --out target/performedCalls.json WS_OUT="$(pwd)/jenkins_workspace" WS_IN=/workspace diff --git a/steps.groovy b/steps.groovy index 8a6efd4b4..4667999e6 100644 --- a/steps.groovy +++ b/steps.groovy @@ -1,6 +1,36 @@ import groovy.json.JsonSlurper -def steps = new JsonSlurper().parseText(new File('target/trackedCalls.json').text) +def cli = new CliBuilder( + usage: 'groovy createDocu []', + header: 'Options:', + footer: 'Copyright: SAP SE') + +cli.with { + i longOpt: 'in', args: 1, argName: 'file', 'The file containing the mapping as created by the unit tests..' + o longOpt: 'out', args: 1, argName: 'file', 'The file containing the condenced mappings.' + h longOpt: 'help', 'Prints this help.' +} + +def options = cli.parse(args) + +if(options.h) { + System.err << "Printing help.\n" + cli.usage() + return +} + +if(! options.i) { + System.err << "No input file" + cli.usage() + return +} +if(! options.o) { + System.err << "No output file" + cli.usage() + return +} + +def steps = new JsonSlurper().parseText(new File(options.i).text) def piperSteps = steps.piperSteps def calls = steps.calls @@ -76,7 +106,7 @@ for(def entry : calls.entrySet()) { piperStepCallMappings.put(entry.key, performedCalls) } -File performedCalls = new File('target/performedCalls.json') +File performedCalls = new File(options.o) if (performedCalls.exists()) performedCalls.delete() performedCalls << groovy.json.JsonOutput.toJson(piperStepCallMappings) From f31dd80cdb81643c457857213b2d9fb42c978d11 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 12:16:49 +0200 Subject: [PATCH 24/67] relocate steps.groovy --- steps.groovy => documentation/bin/steps.groovy | 0 resolvePlugins.sh | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename steps.groovy => documentation/bin/steps.groovy (100%) diff --git a/steps.groovy b/documentation/bin/steps.groovy similarity index 100% rename from steps.groovy rename to documentation/bin/steps.groovy diff --git a/resolvePlugins.sh b/resolvePlugins.sh index 2f270faf2..a27429692 100755 --- a/resolvePlugins.sh +++ b/resolvePlugins.sh @@ -1,7 +1,7 @@ #!/bin/bash mvn clean test -groovy steps.groovy -in target/trackedCalls.json --out target/performedCalls.json +groovy documentation/bin/steps.groovy -in target/trackedCalls.json --out target/performedCalls.json WS_OUT="$(pwd)/jenkins_workspace" WS_IN=/workspace From c4fb2445e5b3ed074536114ded041c537fda2ab9 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 12:19:32 +0200 Subject: [PATCH 25/67] run condence steps within createDocu --- documentation/bin/createDocu.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation/bin/createDocu.sh b/documentation/bin/createDocu.sh index ed8cd06a9..a0b1bf9fe 100755 --- a/documentation/bin/createDocu.sh +++ b/documentation/bin/createDocu.sh @@ -5,4 +5,5 @@ d=$(dirname "$0") export CLASSPATH_FILE='target/cp.txt' mvn clean test dependency:build-classpath -Dmdep.outputFile=${CLASSPATH_FILE} > /dev/null 2>&1 +groovy "${d}steps" -in target/trackedCalls.json --out target/performedCalls.json groovy -cp "target/classes:$(cat $CLASSPATH_FILE)" "${d}createDocu" "${@}" From cc5cd1d04754c9e7493fb08a8c33391acc52ebaf Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 12:32:49 +0200 Subject: [PATCH 26/67] resolve plugins before creating docu --- documentation/bin/createDocu.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/documentation/bin/createDocu.sh b/documentation/bin/createDocu.sh index a0b1bf9fe..ef4ba9161 100755 --- a/documentation/bin/createDocu.sh +++ b/documentation/bin/createDocu.sh @@ -6,4 +6,35 @@ d=$(dirname "$0") export CLASSPATH_FILE='target/cp.txt' mvn clean test dependency:build-classpath -Dmdep.outputFile=${CLASSPATH_FILE} > /dev/null 2>&1 groovy "${d}steps" -in target/trackedCalls.json --out target/performedCalls.json + +WS_OUT="$(pwd)/jenkins_workspace" +WS_IN=/workspace + +REL_CALLS=calls.json +REL_RESULT=result.json + +CALLS="${WS_OUT}/${REL_CALLS}" +RESULT="${WS_OUT}/${REL_RESULT}" + +for f in ${CALLS} ${RESULT} +do + [ -e "${f}" ] && rm -rf "${f}" +done + +cp target/performedCalls.json "${CALLS}" + +[ -f "${CALLS}" ] || { echo "File \"${CALLS}\" does not exist." ; exit 1; } + +docker run \ + -w "${WS_IN}" \ + --env calls="${WS_IN}/${REL_CALLS}" \ + --env result="${WS_IN}/${REL_RESULT}" \ + -v "${WS_OUT}:${WS_IN}" \ + ppiper/jenkinsfile-runner \ + -ns \ + -f Jenkinsfile \ + --runWorkspace /workspace + +[ -f "${RESULT}" ] || { echo "Result file containing step to plugin mapping not found (${RESULT})."; exit 1; } + groovy -cp "target/classes:$(cat $CLASSPATH_FILE)" "${d}createDocu" "${@}" From d0e6b1a8ed468d5e26c32db828f99cb326ff3ca2 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 12:45:46 +0200 Subject: [PATCH 27/67] wip --- documentation/bin/createDocu.groovy | 2 +- documentation/bin/createDocu.sh | 2 +- .../jenkins_workspace}/Jenkinsfile | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename {jenkins_workspace => documentation/jenkins_workspace}/Jenkinsfile (100%) diff --git a/documentation/bin/createDocu.groovy b/documentation/bin/createDocu.groovy index b7840f446..67b2b8a5e 100644 --- a/documentation/bin/createDocu.groovy +++ b/documentation/bin/createDocu.groovy @@ -579,7 +579,7 @@ def handleStep(stepName, prepareDefaultValuesStep, gse, customDefaults) { File theStep = new File(stepsDir, "${stepName}.groovy") File theStepDocu = new File(stepsDocuDir, "${stepName}.md") - File theStepDeps = new File('jenkins_workspace/result.json') + File theStepDeps = new File('documentation/jenkins_workspace/result.json') if(!theStepDocu.exists()) { System.err << "[WARNING] step docu input file for step '${stepName}' is missing.\n" diff --git a/documentation/bin/createDocu.sh b/documentation/bin/createDocu.sh index ef4ba9161..16a664bf5 100755 --- a/documentation/bin/createDocu.sh +++ b/documentation/bin/createDocu.sh @@ -7,7 +7,7 @@ export CLASSPATH_FILE='target/cp.txt' mvn clean test dependency:build-classpath -Dmdep.outputFile=${CLASSPATH_FILE} > /dev/null 2>&1 groovy "${d}steps" -in target/trackedCalls.json --out target/performedCalls.json -WS_OUT="$(pwd)/jenkins_workspace" +WS_OUT="$(pwd)/documentation/jenkins_workspace" WS_IN=/workspace REL_CALLS=calls.json diff --git a/jenkins_workspace/Jenkinsfile b/documentation/jenkins_workspace/Jenkinsfile similarity index 100% rename from jenkins_workspace/Jenkinsfile rename to documentation/jenkins_workspace/Jenkinsfile From 4fd253199dcaa0b422abab8cc233da008b7a51f4 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 13:50:16 +0200 Subject: [PATCH 28/67] docu --- documentation/bin/createDocu.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/documentation/bin/createDocu.sh b/documentation/bin/createDocu.sh index 16a664bf5..554258cf7 100755 --- a/documentation/bin/createDocu.sh +++ b/documentation/bin/createDocu.sh @@ -5,6 +5,14 @@ d=$(dirname "$0") export CLASSPATH_FILE='target/cp.txt' mvn clean test dependency:build-classpath -Dmdep.outputFile=${CLASSPATH_FILE} > /dev/null 2>&1 + +# --in: is created by the unit tests. It contains a mapping between the test case (name is +# already adjusted). +# --out: Contains a transformed version. The calls to other pipeline steps are resolved in a +# transitive manner. This allows us to report all Jenkins plugin calls (also the calls which +# are performed by other pipeline steps. E.g.: each step includes basically a call to +# handlePipelineStepErrors. The Plugin calls issues by handlePipelineStepErrors are also +# reported for the step calling that auxiliar step). groovy "${d}steps" -in target/trackedCalls.json --out target/performedCalls.json WS_OUT="$(pwd)/documentation/jenkins_workspace" From 600442c033611d42efce4ca7cb1bcc847941141f Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 13:59:40 +0200 Subject: [PATCH 29/67] streamline bash coding --- documentation/bin/createDocu.sh | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/documentation/bin/createDocu.sh b/documentation/bin/createDocu.sh index 554258cf7..903313358 100755 --- a/documentation/bin/createDocu.sh +++ b/documentation/bin/createDocu.sh @@ -3,18 +3,6 @@ d=$(dirname "$0") [ ! -z "$d" ] && d="$d/" -export CLASSPATH_FILE='target/cp.txt' -mvn clean test dependency:build-classpath -Dmdep.outputFile=${CLASSPATH_FILE} > /dev/null 2>&1 - -# --in: is created by the unit tests. It contains a mapping between the test case (name is -# already adjusted). -# --out: Contains a transformed version. The calls to other pipeline steps are resolved in a -# transitive manner. This allows us to report all Jenkins plugin calls (also the calls which -# are performed by other pipeline steps. E.g.: each step includes basically a call to -# handlePipelineStepErrors. The Plugin calls issues by handlePipelineStepErrors are also -# reported for the step calling that auxiliar step). -groovy "${d}steps" -in target/trackedCalls.json --out target/performedCalls.json - WS_OUT="$(pwd)/documentation/jenkins_workspace" WS_IN=/workspace @@ -29,7 +17,17 @@ do [ -e "${f}" ] && rm -rf "${f}" done -cp target/performedCalls.json "${CALLS}" +export CLASSPATH_FILE='target/cp.txt' +mvn clean test dependency:build-classpath -Dmdep.outputFile=${CLASSPATH_FILE} > /dev/null 2>&1 + +# --in: is created by the unit tests. It contains a mapping between the test case (name is +# already adjusted). +# --out: Contains a transformed version. The calls to other pipeline steps are resolved in a +# transitive manner. This allows us to report all Jenkins plugin calls (also the calls which +# are performed by other pipeline steps. E.g.: each step includes basically a call to +# handlePipelineStepErrors. The Plugin calls issues by handlePipelineStepErrors are also +# reported for the step calling that auxiliar step). +groovy "${d}steps" -in target/trackedCalls.json --out "${CALLS}" [ -f "${CALLS}" ] || { echo "File \"${CALLS}\" does not exist." ; exit 1; } From 931e84b29318f44c08a50668d77571ec4dabfbb7 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 14:01:43 +0200 Subject: [PATCH 30/67] steamline names in bash file --- documentation/bin/createDocu.groovy | 2 +- documentation/bin/createDocu.sh | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/documentation/bin/createDocu.groovy b/documentation/bin/createDocu.groovy index 67b2b8a5e..704893236 100644 --- a/documentation/bin/createDocu.groovy +++ b/documentation/bin/createDocu.groovy @@ -579,7 +579,7 @@ def handleStep(stepName, prepareDefaultValuesStep, gse, customDefaults) { File theStep = new File(stepsDir, "${stepName}.groovy") File theStepDocu = new File(stepsDocuDir, "${stepName}.md") - File theStepDeps = new File('documentation/jenkins_workspace/result.json') + File theStepDeps = new File('documentation/jenkins_workspace/plugin_mapping.json') if(!theStepDocu.exists()) { System.err << "[WARNING] step docu input file for step '${stepName}' is missing.\n" diff --git a/documentation/bin/createDocu.sh b/documentation/bin/createDocu.sh index 903313358..f1a5f2aa6 100755 --- a/documentation/bin/createDocu.sh +++ b/documentation/bin/createDocu.sh @@ -6,13 +6,13 @@ d=$(dirname "$0") WS_OUT="$(pwd)/documentation/jenkins_workspace" WS_IN=/workspace -REL_CALLS=calls.json -REL_RESULT=result.json +STEP_CALL_MAPPING_FILE_NAME=step_calls_mapping.json +PLUGIN_MAPPING_FILE_NAME=plugin_mapping.json -CALLS="${WS_OUT}/${REL_CALLS}" -RESULT="${WS_OUT}/${REL_RESULT}" +CALLS="${WS_OUT}/${STEP_CALL_MAPPING_FILE_NAME}" +PLUGIN_MAPPING="${WS_OUT}/${PLUGIN_MAPPING_FILE_NAME}" -for f in ${CALLS} ${RESULT} +for f in ${CALLS} ${PLUGIN_MAPPING} do [ -e "${f}" ] && rm -rf "${f}" done @@ -33,14 +33,14 @@ groovy "${d}steps" -in target/trackedCalls.json --out "${CALLS}" docker run \ -w "${WS_IN}" \ - --env calls="${WS_IN}/${REL_CALLS}" \ - --env result="${WS_IN}/${REL_RESULT}" \ + --env calls="${WS_IN}/${STEP_CALL_MAPPING_FILE_NAME}" \ + --env result="${WS_IN}/${PLUGIN_MAPPING_FILE_NAME}" \ -v "${WS_OUT}:${WS_IN}" \ ppiper/jenkinsfile-runner \ -ns \ -f Jenkinsfile \ --runWorkspace /workspace -[ -f "${RESULT}" ] || { echo "Result file containing step to plugin mapping not found (${RESULT})."; exit 1; } +[ -f "${PLUGIN_MAPPING}" ] || { echo "Result file containing step to plugin mapping not found (${PLUGIN_MAPPING})."; exit 1; } groovy -cp "target/classes:$(cat $CLASSPATH_FILE)" "${d}createDocu" "${@}" From 6b8197aac72be3f8368abcfeb557b5c9688dfd8a Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 14:22:13 +0200 Subject: [PATCH 31/67] explict initialization with null --- documentation/bin/steps.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/bin/steps.groovy b/documentation/bin/steps.groovy index 4667999e6..ff344e8b1 100644 --- a/documentation/bin/steps.groovy +++ b/documentation/bin/steps.groovy @@ -56,8 +56,8 @@ def alreadyHandled = [] while(counter < 1600) { - def hereWeNeedToReplace - def toBeReplaced + def hereWeNeedToReplace = null + def toBeReplaced = null if(alreadyHandled.size() == calls.size()) break From 5145cb326a4b1afe2bb9daa4935ba47267b06aab Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 14:36:19 +0200 Subject: [PATCH 32/67] streamline transitive plugin calls --- documentation/bin/steps.groovy | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/documentation/bin/steps.groovy b/documentation/bin/steps.groovy index ff344e8b1..ce52e40e5 100644 --- a/documentation/bin/steps.groovy +++ b/documentation/bin/steps.groovy @@ -54,12 +54,22 @@ int counter=0 def alreadyHandled = [] -while(counter < 1600) { +// +// in case we exceed the value we assume some cyclic call +// between plugin steps. +int MAX_LOOP = 1600 + +boolean done = false + +while(counter < MAX_LOOP) { def hereWeNeedToReplace = null def toBeReplaced = null - if(alreadyHandled.size() == calls.size()) break + if(alreadyHandled.size() == calls.size()) { + done = true + break + } for (def call in calls.entrySet()) { @@ -73,10 +83,10 @@ while(counter < 1600) { for (def calledStep in calledSteps) { if(calledStep in Map) { - // After some time not working on this I have acually forgotten - // what needs to be done here ... In order not to forget that - // here is maybe something missing we emit a log message. - System.err << "[DEBUG] This is not handled yet.(${calledStep})\n" + // After some time not working on this I have acually forgotten + // what needs to be done here ... In order not to forget that + // here is maybe something missing we emit a log message. + System.err << "[DEBUG] This is not handled yet.(${calledStep})\n" } else { if(calledStep in piperSteps) { toBeReplaced = calledStep @@ -98,6 +108,9 @@ while(counter < 1600) { } } +if(! done) { + throw new Exception('Unable to resolve transitive plugin calls.') +} piperStepCallMappings = [:] From 3680a11edcaca4224f7f5af023154a4e23a67fbe Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 14:41:23 +0200 Subject: [PATCH 33/67] improve groovy script file naming --- documentation/bin/createDocu.sh | 2 +- .../bin/{steps.groovy => resolveTransitiveCalls.groovy} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename documentation/bin/{steps.groovy => resolveTransitiveCalls.groovy} (100%) diff --git a/documentation/bin/createDocu.sh b/documentation/bin/createDocu.sh index f1a5f2aa6..ef5dc0b38 100755 --- a/documentation/bin/createDocu.sh +++ b/documentation/bin/createDocu.sh @@ -27,7 +27,7 @@ mvn clean test dependency:build-classpath -Dmdep.outputFile=${CLASSPATH_FILE} > # are performed by other pipeline steps. E.g.: each step includes basically a call to # handlePipelineStepErrors. The Plugin calls issues by handlePipelineStepErrors are also # reported for the step calling that auxiliar step). -groovy "${d}steps" -in target/trackedCalls.json --out "${CALLS}" +groovy "${d}resolveTransitiveCalls" -in target/trackedCalls.json --out "${CALLS}" [ -f "${CALLS}" ] || { echo "File \"${CALLS}\" does not exist." ; exit 1; } diff --git a/documentation/bin/steps.groovy b/documentation/bin/resolveTransitiveCalls.groovy similarity index 100% rename from documentation/bin/steps.groovy rename to documentation/bin/resolveTransitiveCalls.groovy From c954f048c9a23c6b482c7121963d9fdc2afd49f5 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 15:28:56 +0200 Subject: [PATCH 34/67] we do not need to handle maps when resolving calls. --- documentation/bin/resolveTransitiveCalls.groovy | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/documentation/bin/resolveTransitiveCalls.groovy b/documentation/bin/resolveTransitiveCalls.groovy index ce52e40e5..5731a9b7b 100644 --- a/documentation/bin/resolveTransitiveCalls.groovy +++ b/documentation/bin/resolveTransitiveCalls.groovy @@ -82,12 +82,12 @@ while(counter < MAX_LOOP) { for (def calledStep in calledSteps) { - if(calledStep in Map) { - // After some time not working on this I have acually forgotten - // what needs to be done here ... In order not to forget that - // here is maybe something missing we emit a log message. - System.err << "[DEBUG] This is not handled yet.(${calledStep})\n" - } else { + if(! ( calledStep in Map)) { + + // in case the calledStep is a map the map + // was introduced in an earlier loop. + // This means this entry is already handled. + if(calledStep in piperSteps) { toBeReplaced = calledStep hereWeNeedToReplace = calledSteps From a0381ac34b69b03624818bdfcceb6bc42dec74eb Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 17:04:18 +0200 Subject: [PATCH 35/67] Remark for kubernetes plugin --- documentation/bin/createDocu.groovy | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/documentation/bin/createDocu.groovy b/documentation/bin/createDocu.groovy index 704893236..00f06c981 100644 --- a/documentation/bin/createDocu.groovy +++ b/documentation/bin/createDocu.groovy @@ -25,6 +25,11 @@ class TemplateHelper { .sort() .each { dep -> t += "* [${dep}](https://plugins.jenkins.io/${dep})\n" } } + + if(filteredDeps.contains('kubernetes')) { + t += "\nThe kubernetes plugin is only used if running in a kubernetes environment." + } + t += '\nTransitive dependencies are omitted.\n\nThis is a beta feature. The list might be incomplete.' return t } From 6add8d023e4d8b6be9c1d27d9d86bdaaed173f3a Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 17:04:42 +0200 Subject: [PATCH 36/67] special bells and whistles for transport related steps --- .../bin/resolveTransitiveCalls.groovy | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/documentation/bin/resolveTransitiveCalls.groovy b/documentation/bin/resolveTransitiveCalls.groovy index 5731a9b7b..57875e53b 100644 --- a/documentation/bin/resolveTransitiveCalls.groovy +++ b/documentation/bin/resolveTransitiveCalls.groovy @@ -119,6 +119,27 @@ for(def entry : calls.entrySet()) { piperStepCallMappings.put(entry.key, performedCalls) } +// +// special handling since since changeManagement util class +// is separated from the steps itself +// +// should be improved in the future in order not to have +// that bells and whistles here. + +def cm = piperStepCallMappings.get('changeManagement') + +for (cmStepName in [ + 'checkChangeInDevelopment', + 'transportRequestCreate', + 'transportRequestUploadFile', + 'transportRequestRelease', +]) { + piperStepCallMappings.get(cmStepName).addAll(cm) +} + +// end of special handling +// + File performedCalls = new File(options.o) if (performedCalls.exists()) performedCalls.delete() performedCalls << groovy.json.JsonOutput.toJson(piperStepCallMappings) From f6b165052a38d74e2fe86e623aec209755652e1e Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Wed, 22 May 2019 08:11:28 +0200 Subject: [PATCH 37/67] Remove not needed test setup wrt file exists check --- test/groovy/NeoDeployTest.groovy | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/groovy/NeoDeployTest.groovy b/test/groovy/NeoDeployTest.groovy index 4a897f4b7..61d0c803e 100644 --- a/test/groovy/NeoDeployTest.groovy +++ b/test/groovy/NeoDeployTest.groovy @@ -213,12 +213,6 @@ class NeoDeployTest extends BasePiperTest { thrown.expect(AbortException) thrown.expectMessage('Extensions are only supported for deploy mode \'MTA\'') - StepAssertions.metaClass.static.assertFileExists = - { Script step, String filePath -> - if( ! [archiveName, 'myExtension.yml'].contains(filePath) ) - step.error("File ${filePath} cannot be found.") - } - stepRule.step.neoDeploy( script: nullScript, source: archiveName, From c59cb912dd7ce012d2226d08df10e04c30a7bbab Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Wed, 22 May 2019 08:24:14 +0200 Subject: [PATCH 38/67] docu: mtaExtensionDescriptors are only valid for deploy mode mta. --- vars/neoDeploy.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index d3107b3cb..21cdc7db5 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -85,7 +85,7 @@ import static com.sap.piper.Prerequisites.checkScript */ 'dockerOptions', /** - * Extension files. Provided to the neo command via parameter `--extensions` (`-e`). + * Extension files. Provided to the neo command via parameter `--extensions` (`-e`). Only valid for deploy mode `mta`. */ 'mtaExtensionDescriptors', /** From f87349e0fe3b512e581948ac1e9f391f35a7f0a4 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Wed, 22 May 2019 08:49:27 +0200 Subject: [PATCH 39/67] Condence dupliate code in test (file exists closure) --- test/groovy/NeoDeployTest.groovy | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/test/groovy/NeoDeployTest.groovy b/test/groovy/NeoDeployTest.groovy index 61d0c803e..95a3c49b2 100644 --- a/test/groovy/NeoDeployTest.groovy +++ b/test/groovy/NeoDeployTest.groovy @@ -138,11 +138,7 @@ class NeoDeployTest extends BasePiperTest { def checkedExtensionFiles = [] StepAssertions.metaClass.static.assertFileExists = - { Script step, String filePath -> - checkedExtensionFiles << filePath - if( ! [archiveName, 'myExtension.yml'].contains(filePath) ) - step.error("File ${filePath} cannot be found.") - } + getFileExistsCheck(checkedExtensionFiles, [archiveName, 'myExtension.yml']) stepRule.step.neoDeploy( script: nullScript, @@ -180,15 +176,7 @@ class NeoDeployTest extends BasePiperTest { def checkedExtensionFiles = [] StepAssertions.metaClass.static.assertFileExists = - { Script step, String filePath -> - checkedExtensionFiles << filePath - if( ! [ - archiveName, - 'myExtension1.yml', - 'myExtension2.yml', - ].contains(filePath) ) - step.error("File ${filePath} cannot be found.") - } + getFileExistsCheck(checkedExtensionFiles, [archiveName, 'myExtension1.yml', 'myExtension2.yml']) stepRule.step.neoDeploy( script: nullScript, @@ -207,6 +195,15 @@ class NeoDeployTest extends BasePiperTest { } + private static getFileExistsCheck(def checkedExtensionFiles, def fileNames) { + + { Script step, String filePath -> + checkedExtensionFiles << filePath + if( ! fileNames.contains(filePath) ) + step.error("File ${filePath} cannot be found.") + } + } + @Test void extensionsForWrongDeployModeTest() { From cd5d114d5201935b696df365504689f539583043 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Thu, 23 May 2019 09:10:30 +0200 Subject: [PATCH 40/67] Do not explict cast to Set since it is coersed to the type of the variable anyway. --- src/com/sap/piper/tools/neo/NeoCommandHelper.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/sap/piper/tools/neo/NeoCommandHelper.groovy b/src/com/sap/piper/tools/neo/NeoCommandHelper.groovy index 09ba4a28d..45a3389a5 100644 --- a/src/com/sap/piper/tools/neo/NeoCommandHelper.groovy +++ b/src/com/sap/piper/tools/neo/NeoCommandHelper.groovy @@ -23,7 +23,7 @@ class NeoCommandHelper { this.user = user this.password = password this.source = source - this.extensions = extensions ?: (Set)[] + this.extensions = extensions ?: [] } private String prolog() { From ed155ece63ecb8e1ee5cd7fa1424e653369900fe Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Thu, 23 May 2019 09:20:10 +0200 Subject: [PATCH 41/67] rename mtaExtensionDescriptos to extensions --- test/groovy/NeoDeployTest.groovy | 6 +++--- vars/neoDeploy.groovy | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/groovy/NeoDeployTest.groovy b/test/groovy/NeoDeployTest.groovy index 95a3c49b2..62bcba172 100644 --- a/test/groovy/NeoDeployTest.groovy +++ b/test/groovy/NeoDeployTest.groovy @@ -143,7 +143,7 @@ class NeoDeployTest extends BasePiperTest { stepRule.step.neoDeploy( script: nullScript, source: archiveName, - mtaExtensionDescriptors: 'myExtension.yml' + extensions: 'myExtension.yml' ) assert checkedExtensionFiles.contains('myExtension.yml') @@ -181,7 +181,7 @@ class NeoDeployTest extends BasePiperTest { stepRule.step.neoDeploy( script: nullScript, source: archiveName, - mtaExtensionDescriptors: extensions + extensions: extensions ) assert checkedExtensionFiles.contains('myExtension1.yml') @@ -214,7 +214,7 @@ class NeoDeployTest extends BasePiperTest { script: nullScript, source: archiveName, deployMode: 'warParams', - mtaExtensionDescriptors: 'myExtension.yml', + extensions: 'myExtension.yml', neo: [ application: 'does', diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index 21cdc7db5..7a6773cac 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -87,7 +87,7 @@ import static com.sap.piper.Prerequisites.checkScript /** * Extension files. Provided to the neo command via parameter `--extensions` (`-e`). Only valid for deploy mode `mta`. */ - 'mtaExtensionDescriptors', + 'extensions', /** * The path to the archive for deployment to SAP CP. If not provided `mtarFilePath` from commom pipeline environment is used instead. */ @@ -157,10 +157,10 @@ void call(parameters = [:]) { Set extensionList - if(configuration.mtaExtensionDescriptors == null) { + if(configuration.extensions == null) { extensionList = [] } else { - extensionList = configuration.mtaExtensionDescriptors in Collection ? configuration.mtaExtensionDescriptors : [configuration.mtaExtensionDescriptors] + extensionList = configuration.extensions in Collection ? configuration.extensions : [configuration.extensions] } if(deployMode != DeployMode.MTA && ! extensionList.isEmpty()) From 4b61f362d2ace221cd760414eaa91fea0cb4e019 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Thu, 23 May 2019 09:23:36 +0200 Subject: [PATCH 42/67] Removing syntactically not needed commas which helps keeping diff smaller --- test/groovy/NeoDeployTest.groovy | 2 +- vars/neoDeploy.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/groovy/NeoDeployTest.groovy b/test/groovy/NeoDeployTest.groovy index 62bcba172..65c1481fc 100644 --- a/test/groovy/NeoDeployTest.groovy +++ b/test/groovy/NeoDeployTest.groovy @@ -220,7 +220,7 @@ class NeoDeployTest extends BasePiperTest { application: 'does', runtime: 'not', runtimeVersion: 'matter' - ], + ] ) } diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index 7a6773cac..878514522 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -91,7 +91,7 @@ import static com.sap.piper.Prerequisites.checkScript /** * The path to the archive for deployment to SAP CP. If not provided `mtarFilePath` from commom pipeline environment is used instead. */ - 'source', + 'source' ]) From 7899f17b68324c32a00589c3ec52b9f29f9d9e5c Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Thu, 23 May 2019 10:19:49 +0200 Subject: [PATCH 43/67] [nameing] improve misleading variable name. --- vars/neoDeploy.groovy | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index 878514522..744809a05 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -155,16 +155,16 @@ void call(parameters = [:]) { // since the map did not change, it is not required to replace the previous configuration map. .use() - Set extensionList + Set extensionFileNames if(configuration.extensions == null) { - extensionList = [] + extensionFileNames = [] } else { - extensionList = configuration.extensions in Collection ? configuration.extensions : [configuration.extensions] + extensionFileNames = configuration.extensions in Collection ? configuration.extensions : [configuration.extensions] } - if(deployMode != DeployMode.MTA && ! extensionList.isEmpty()) - error "Extensions (${extensionList} found for deploy mode ${deployMode}. Extensions are only supported for deploy mode '${DeployMode.MTA}')" + if(deployMode != DeployMode.MTA && ! extensionFileNames.isEmpty()) + error "Extensions (${extensionFileNames} found for deploy mode ${deployMode}. Extensions are only supported for deploy mode '${DeployMode.MTA}')" utils.pushToSWA([ step: STEP_NAME, @@ -193,7 +193,7 @@ void call(parameters = [:]) { StepAssertions.assertFileExists(this, configuration.source) - for(CharSequence extensionFile in extensionList) { + for(CharSequence extensionFile in extensionFileNames) { StepAssertions.assertFileExists(this, extensionFile) } @@ -201,7 +201,7 @@ void call(parameters = [:]) { this, deployMode, configuration.neo, - extensionList, + extensionFileNames, NEO_USERNAME, NEO_PASSWORD, configuration.source From 79b79457f4a9b8005c4be12a09615768d26778ec Mon Sep 17 00:00:00 2001 From: Alejandra Ferreiro Vidal Date: Wed, 22 May 2019 16:05:34 +0200 Subject: [PATCH 44/67] remove !#groovy header --- template/StepTestTemplateTest.groovy | 1 - test/groovy/ArtifactSetVersionTest.groovy | 2 -- test/groovy/CloudFoundryDeployTest.groovy | 1 - test/groovy/DetectExecuteScanTest.groovy | 1 - test/groovy/DurationMeasureTest.groovy | 2 -- test/groovy/GaugeExecuteTestsTest.groovy | 1 - test/groovy/GithubPublishReleaseTest.groovy | 1 - test/groovy/HandlePipelineStepErrorsTest.groovy | 1 - test/groovy/HealthExecuteCheckTest.groovy | 1 - test/groovy/InfluxWriteDataTest.groovy | 1 - test/groovy/KanikoExecuteTest.groovy | 1 - test/groovy/KarmaExecuteTestsTest.groovy | 1 - test/groovy/MailSendNotificationTest.groovy | 1 - test/groovy/PipelineRestartStepsTest.groovy | 1 - test/groovy/PiperPipelineStageInitTest.groovy | 1 - test/groovy/PiperPipelineStagePostTest.groovy | 1 - test/groovy/PiperStageWrapperTest.groovy | 1 - test/groovy/SlackSendNotificationTest.groovy | 1 - test/groovy/UiVeri5ExecuteTestsTest.groovy | 2 -- test/groovy/WhitesourceExecuteScanTest.groovy | 1 - test/groovy/templates/PiperInitRunStageConfigurationTest.groovy | 1 - test/groovy/templates/PiperPipelineStageAcceptanceTest.groovy | 1 - .../templates/PiperPipelineStageAdditionalUnitTestsTest.groovy | 1 - test/groovy/templates/PiperPipelineStageBuildTest.groovy | 1 - test/groovy/templates/PiperPipelineStageComplianceTest.groovy | 1 - test/groovy/templates/PiperPipelineStageConfirmTest.groovy | 1 - test/groovy/templates/PiperPipelineStageInitTest.groovy | 1 - test/groovy/templates/PiperPipelineStageIntegrationTest.groovy | 1 - test/groovy/templates/PiperPipelineStagePRVotingTest.groovy | 1 - test/groovy/templates/PiperPipelineStagePerformanceTest.groovy | 1 - test/groovy/templates/PiperPipelineStagePromoteTest.groovy | 1 - test/groovy/templates/PiperPipelineStageReleaseTest.groovy | 1 - test/groovy/templates/PiperPipelineStageSecurityTest.groovy | 1 - test/groovy/templates/PiperPipelineTest.groovy | 1 - test/groovy/util/BasePiperTest.groovy | 2 -- test/groovy/util/BasePiperTestContext.groovy | 2 -- test/groovy/util/ProjectSource.groovy | 1 - 37 files changed, 42 deletions(-) diff --git a/template/StepTestTemplateTest.groovy b/template/StepTestTemplateTest.groovy index 8f2cb936f..fb004217d 100644 --- a/template/StepTestTemplateTest.groovy +++ b/template/StepTestTemplateTest.groovy @@ -1,4 +1,3 @@ -#!groovy import com.lesfurets.jenkins.unit.BasePipelineTest import static org.junit.Assert.assertEquals diff --git a/test/groovy/ArtifactSetVersionTest.groovy b/test/groovy/ArtifactSetVersionTest.groovy index 9e0fa8c42..13ab9b18d 100644 --- a/test/groovy/ArtifactSetVersionTest.groovy +++ b/test/groovy/ArtifactSetVersionTest.groovy @@ -1,5 +1,3 @@ -#!groovy - import org.junit.Before import org.junit.Rule import org.junit.Test diff --git a/test/groovy/CloudFoundryDeployTest.groovy b/test/groovy/CloudFoundryDeployTest.groovy index deb56fcce..d83d949df 100644 --- a/test/groovy/CloudFoundryDeployTest.groovy +++ b/test/groovy/CloudFoundryDeployTest.groovy @@ -1,4 +1,3 @@ -#!groovy import com.sap.piper.JenkinsUtils import org.junit.Before import org.junit.Rule diff --git a/test/groovy/DetectExecuteScanTest.groovy b/test/groovy/DetectExecuteScanTest.groovy index 800e68d35..489913b06 100644 --- a/test/groovy/DetectExecuteScanTest.groovy +++ b/test/groovy/DetectExecuteScanTest.groovy @@ -1,4 +1,3 @@ -#!groovy import org.junit.Before import org.junit.Rule import org.junit.Test diff --git a/test/groovy/DurationMeasureTest.groovy b/test/groovy/DurationMeasureTest.groovy index 1f7bc856c..029571048 100644 --- a/test/groovy/DurationMeasureTest.groovy +++ b/test/groovy/DurationMeasureTest.groovy @@ -1,5 +1,3 @@ -#!groovy - import com.sap.piper.analytics.InfluxData import org.junit.Rule diff --git a/test/groovy/GaugeExecuteTestsTest.groovy b/test/groovy/GaugeExecuteTestsTest.groovy index f369f37e5..2c61e0855 100644 --- a/test/groovy/GaugeExecuteTestsTest.groovy +++ b/test/groovy/GaugeExecuteTestsTest.groovy @@ -1,4 +1,3 @@ -#!groovy import org.junit.Before import org.junit.Rule import org.junit.Test diff --git a/test/groovy/GithubPublishReleaseTest.groovy b/test/groovy/GithubPublishReleaseTest.groovy index a6162676d..b37a96eb2 100644 --- a/test/groovy/GithubPublishReleaseTest.groovy +++ b/test/groovy/GithubPublishReleaseTest.groovy @@ -1,4 +1,3 @@ -#!groovy import groovy.json.JsonSlurperClassic import org.junit.Before import org.junit.Rule diff --git a/test/groovy/HandlePipelineStepErrorsTest.groovy b/test/groovy/HandlePipelineStepErrorsTest.groovy index dd29e5f94..f9b4ae678 100644 --- a/test/groovy/HandlePipelineStepErrorsTest.groovy +++ b/test/groovy/HandlePipelineStepErrorsTest.groovy @@ -1,4 +1,3 @@ -#!groovy import hudson.AbortException import static org.hamcrest.Matchers.is diff --git a/test/groovy/HealthExecuteCheckTest.groovy b/test/groovy/HealthExecuteCheckTest.groovy index 7ffb3793e..586f81506 100644 --- a/test/groovy/HealthExecuteCheckTest.groovy +++ b/test/groovy/HealthExecuteCheckTest.groovy @@ -1,4 +1,3 @@ -#!groovy import org.junit.Before import org.junit.Rule import org.junit.Test diff --git a/test/groovy/InfluxWriteDataTest.groovy b/test/groovy/InfluxWriteDataTest.groovy index 4456f99b1..7a82b4b52 100644 --- a/test/groovy/InfluxWriteDataTest.groovy +++ b/test/groovy/InfluxWriteDataTest.groovy @@ -1,4 +1,3 @@ -#!groovy import com.sap.piper.DefaultValueCache import com.sap.piper.analytics.InfluxData diff --git a/test/groovy/KanikoExecuteTest.groovy b/test/groovy/KanikoExecuteTest.groovy index 5853ca846..c620cb082 100644 --- a/test/groovy/KanikoExecuteTest.groovy +++ b/test/groovy/KanikoExecuteTest.groovy @@ -1,4 +1,3 @@ -#!groovy import org.junit.Before import org.junit.Rule import org.junit.Test diff --git a/test/groovy/KarmaExecuteTestsTest.groovy b/test/groovy/KarmaExecuteTestsTest.groovy index fcce88c4a..3b1e1fe74 100644 --- a/test/groovy/KarmaExecuteTestsTest.groovy +++ b/test/groovy/KarmaExecuteTestsTest.groovy @@ -1,4 +1,3 @@ -#!groovy import org.junit.Before import org.junit.Rule import org.junit.Test diff --git a/test/groovy/MailSendNotificationTest.groovy b/test/groovy/MailSendNotificationTest.groovy index 1647bff8b..1964f3570 100644 --- a/test/groovy/MailSendNotificationTest.groovy +++ b/test/groovy/MailSendNotificationTest.groovy @@ -1,4 +1,3 @@ -#!groovy import org.junit.Before import org.junit.Rule import org.junit.Test diff --git a/test/groovy/PipelineRestartStepsTest.groovy b/test/groovy/PipelineRestartStepsTest.groovy index 6d4c471fc..4fff88605 100644 --- a/test/groovy/PipelineRestartStepsTest.groovy +++ b/test/groovy/PipelineRestartStepsTest.groovy @@ -1,4 +1,3 @@ -#!groovy import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException import org.junit.Rule import org.junit.Test diff --git a/test/groovy/PiperPipelineStageInitTest.groovy b/test/groovy/PiperPipelineStageInitTest.groovy index b5e18b39f..be8e27781 100644 --- a/test/groovy/PiperPipelineStageInitTest.groovy +++ b/test/groovy/PiperPipelineStageInitTest.groovy @@ -1,4 +1,3 @@ -#!groovy package stages import org.junit.Before diff --git a/test/groovy/PiperPipelineStagePostTest.groovy b/test/groovy/PiperPipelineStagePostTest.groovy index b0266c7da..a3ddd2c1b 100644 --- a/test/groovy/PiperPipelineStagePostTest.groovy +++ b/test/groovy/PiperPipelineStagePostTest.groovy @@ -1,4 +1,3 @@ -#!groovy package stages import org.junit.Before diff --git a/test/groovy/PiperStageWrapperTest.groovy b/test/groovy/PiperStageWrapperTest.groovy index 9bd507cab..df7146148 100644 --- a/test/groovy/PiperStageWrapperTest.groovy +++ b/test/groovy/PiperStageWrapperTest.groovy @@ -1,4 +1,3 @@ -#!groovy import org.junit.Before import org.junit.Rule import org.junit.Test diff --git a/test/groovy/SlackSendNotificationTest.groovy b/test/groovy/SlackSendNotificationTest.groovy index c59f82b41..33a78173c 100644 --- a/test/groovy/SlackSendNotificationTest.groovy +++ b/test/groovy/SlackSendNotificationTest.groovy @@ -1,4 +1,3 @@ -#!groovy import org.junit.Before import org.junit.Rule import org.junit.Test diff --git a/test/groovy/UiVeri5ExecuteTestsTest.groovy b/test/groovy/UiVeri5ExecuteTestsTest.groovy index 2155ad6fb..97620ddfa 100644 --- a/test/groovy/UiVeri5ExecuteTestsTest.groovy +++ b/test/groovy/UiVeri5ExecuteTestsTest.groovy @@ -1,5 +1,3 @@ -#!groovy - import static org.hamcrest.Matchers.* import org.junit.Before diff --git a/test/groovy/WhitesourceExecuteScanTest.groovy b/test/groovy/WhitesourceExecuteScanTest.groovy index 8e9fa78a0..da933d4d2 100644 --- a/test/groovy/WhitesourceExecuteScanTest.groovy +++ b/test/groovy/WhitesourceExecuteScanTest.groovy @@ -1,4 +1,3 @@ -#!groovy import com.sap.piper.DescriptorUtils import com.sap.piper.JsonUtils import com.sap.piper.integration.WhitesourceOrgAdminRepository diff --git a/test/groovy/templates/PiperInitRunStageConfigurationTest.groovy b/test/groovy/templates/PiperInitRunStageConfigurationTest.groovy index b12ff1aae..9cda73fd3 100644 --- a/test/groovy/templates/PiperInitRunStageConfigurationTest.groovy +++ b/test/groovy/templates/PiperInitRunStageConfigurationTest.groovy @@ -1,4 +1,3 @@ -#!groovy package templates import org.junit.Before diff --git a/test/groovy/templates/PiperPipelineStageAcceptanceTest.groovy b/test/groovy/templates/PiperPipelineStageAcceptanceTest.groovy index d27ed7d27..85e0fcf66 100644 --- a/test/groovy/templates/PiperPipelineStageAcceptanceTest.groovy +++ b/test/groovy/templates/PiperPipelineStageAcceptanceTest.groovy @@ -1,4 +1,3 @@ -#!groovy package templates import org.junit.Before diff --git a/test/groovy/templates/PiperPipelineStageAdditionalUnitTestsTest.groovy b/test/groovy/templates/PiperPipelineStageAdditionalUnitTestsTest.groovy index 9b76e3a5d..311f2888f 100644 --- a/test/groovy/templates/PiperPipelineStageAdditionalUnitTestsTest.groovy +++ b/test/groovy/templates/PiperPipelineStageAdditionalUnitTestsTest.groovy @@ -1,4 +1,3 @@ -#!groovy package templates import org.junit.Before diff --git a/test/groovy/templates/PiperPipelineStageBuildTest.groovy b/test/groovy/templates/PiperPipelineStageBuildTest.groovy index 8bfcf1c6a..656a2db13 100644 --- a/test/groovy/templates/PiperPipelineStageBuildTest.groovy +++ b/test/groovy/templates/PiperPipelineStageBuildTest.groovy @@ -1,4 +1,3 @@ -#!groovy package templates import org.junit.Before diff --git a/test/groovy/templates/PiperPipelineStageComplianceTest.groovy b/test/groovy/templates/PiperPipelineStageComplianceTest.groovy index 5fed00021..0fe45e14d 100644 --- a/test/groovy/templates/PiperPipelineStageComplianceTest.groovy +++ b/test/groovy/templates/PiperPipelineStageComplianceTest.groovy @@ -1,4 +1,3 @@ -#!groovy package templates import org.junit.Before diff --git a/test/groovy/templates/PiperPipelineStageConfirmTest.groovy b/test/groovy/templates/PiperPipelineStageConfirmTest.groovy index 696f6e741..d6b07fd56 100644 --- a/test/groovy/templates/PiperPipelineStageConfirmTest.groovy +++ b/test/groovy/templates/PiperPipelineStageConfirmTest.groovy @@ -1,4 +1,3 @@ -#!groovy package templates import org.junit.Before diff --git a/test/groovy/templates/PiperPipelineStageInitTest.groovy b/test/groovy/templates/PiperPipelineStageInitTest.groovy index 12e7e63c3..861670121 100644 --- a/test/groovy/templates/PiperPipelineStageInitTest.groovy +++ b/test/groovy/templates/PiperPipelineStageInitTest.groovy @@ -1,4 +1,3 @@ -#!groovy package templates import org.junit.Before diff --git a/test/groovy/templates/PiperPipelineStageIntegrationTest.groovy b/test/groovy/templates/PiperPipelineStageIntegrationTest.groovy index 7b9591447..9dfadff60 100644 --- a/test/groovy/templates/PiperPipelineStageIntegrationTest.groovy +++ b/test/groovy/templates/PiperPipelineStageIntegrationTest.groovy @@ -1,4 +1,3 @@ -#!groovy package templates import org.junit.Before diff --git a/test/groovy/templates/PiperPipelineStagePRVotingTest.groovy b/test/groovy/templates/PiperPipelineStagePRVotingTest.groovy index 82e7c5b75..d71c68101 100644 --- a/test/groovy/templates/PiperPipelineStagePRVotingTest.groovy +++ b/test/groovy/templates/PiperPipelineStagePRVotingTest.groovy @@ -1,4 +1,3 @@ -#!groovy package templates import org.junit.Before diff --git a/test/groovy/templates/PiperPipelineStagePerformanceTest.groovy b/test/groovy/templates/PiperPipelineStagePerformanceTest.groovy index 64b73c860..00d2dde32 100644 --- a/test/groovy/templates/PiperPipelineStagePerformanceTest.groovy +++ b/test/groovy/templates/PiperPipelineStagePerformanceTest.groovy @@ -1,4 +1,3 @@ -#!groovy package templates import org.junit.Before diff --git a/test/groovy/templates/PiperPipelineStagePromoteTest.groovy b/test/groovy/templates/PiperPipelineStagePromoteTest.groovy index 9a84cf712..0f1244952 100644 --- a/test/groovy/templates/PiperPipelineStagePromoteTest.groovy +++ b/test/groovy/templates/PiperPipelineStagePromoteTest.groovy @@ -1,4 +1,3 @@ -#!groovy package templates import org.junit.Before diff --git a/test/groovy/templates/PiperPipelineStageReleaseTest.groovy b/test/groovy/templates/PiperPipelineStageReleaseTest.groovy index bf1f02d3e..2be2480ca 100644 --- a/test/groovy/templates/PiperPipelineStageReleaseTest.groovy +++ b/test/groovy/templates/PiperPipelineStageReleaseTest.groovy @@ -1,4 +1,3 @@ -#!groovy package templates import org.junit.Before diff --git a/test/groovy/templates/PiperPipelineStageSecurityTest.groovy b/test/groovy/templates/PiperPipelineStageSecurityTest.groovy index b172b2ff6..ddca692a9 100644 --- a/test/groovy/templates/PiperPipelineStageSecurityTest.groovy +++ b/test/groovy/templates/PiperPipelineStageSecurityTest.groovy @@ -1,4 +1,3 @@ -#!groovy package templates import org.junit.Before diff --git a/test/groovy/templates/PiperPipelineTest.groovy b/test/groovy/templates/PiperPipelineTest.groovy index 1d9295875..737cf57eb 100644 --- a/test/groovy/templates/PiperPipelineTest.groovy +++ b/test/groovy/templates/PiperPipelineTest.groovy @@ -1,4 +1,3 @@ -#!groovy package templates import org.junit.Before diff --git a/test/groovy/util/BasePiperTest.groovy b/test/groovy/util/BasePiperTest.groovy index 1e5604947..30f2546a6 100644 --- a/test/groovy/util/BasePiperTest.groovy +++ b/test/groovy/util/BasePiperTest.groovy @@ -1,5 +1,3 @@ -#!groovy - package util import com.lesfurets.jenkins.unit.BasePipelineTest diff --git a/test/groovy/util/BasePiperTestContext.groovy b/test/groovy/util/BasePiperTestContext.groovy index 290bc502a..24109f371 100644 --- a/test/groovy/util/BasePiperTestContext.groovy +++ b/test/groovy/util/BasePiperTestContext.groovy @@ -1,5 +1,3 @@ -#!groovy - package util import com.sap.piper.DescriptorUtils diff --git a/test/groovy/util/ProjectSource.groovy b/test/groovy/util/ProjectSource.groovy index 2861f2fa0..a446a9a91 100644 --- a/test/groovy/util/ProjectSource.groovy +++ b/test/groovy/util/ProjectSource.groovy @@ -1,4 +1,3 @@ -#!groovy package util import com.lesfurets.jenkins.unit.global.lib.SourceRetriever From c21a4a6a3e0b5cc40392cc33e36bfe0eb385458b Mon Sep 17 00:00:00 2001 From: Alejandra Ferreiro Vidal Date: Wed, 22 May 2019 16:56:50 +0200 Subject: [PATCH 45/67] remove semikolons --- src/com/sap/piper/cm/BackendType.groovy | 2 +- src/com/sap/piper/cm/ChangeManagementException.groovy | 2 +- src/com/sap/piper/cm/StepHelpers.groovy | 2 +- src/com/sap/piper/tools/neo/DeployMode.groovy | 2 +- src/com/sap/piper/tools/neo/NeoCommandHelper.groovy | 2 +- src/com/sap/piper/tools/neo/WarAction.groovy | 2 +- test/groovy/CommonStepsTest.groovy | 4 ++-- test/groovy/DockerExecuteOnKubernetesTest.groovy | 2 +- test/groovy/PrepareDefaultValuesTest.groovy | 6 +++--- test/groovy/com/sap/piper/MapUtilsTest.groovy | 2 +- test/groovy/com/sap/piper/MtaUtilsTest.groovy | 2 +- test/groovy/com/sap/piper/k8s/SystemEnvTest.groovy | 2 +- test/groovy/util/JenkinsLoggingRule.groovy | 2 +- test/groovy/util/JenkinsShellCallRule.groovy | 4 ++-- test/groovy/util/PipelineWhenException.groovy | 2 +- test/groovy/util/StepHelper.groovy | 4 ++-- vars/mailSendNotification.groovy | 2 +- vars/sonarExecuteScan.groovy | 2 +- 18 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/com/sap/piper/cm/BackendType.groovy b/src/com/sap/piper/cm/BackendType.groovy index 1ab4ccb3b..1f1bdd04b 100644 --- a/src/com/sap/piper/cm/BackendType.groovy +++ b/src/com/sap/piper/cm/BackendType.groovy @@ -1,4 +1,4 @@ -package com.sap.piper.cm; +package com.sap.piper.cm public enum BackendType { SOLMAN, CTS, RFC, NONE diff --git a/src/com/sap/piper/cm/ChangeManagementException.groovy b/src/com/sap/piper/cm/ChangeManagementException.groovy index 455f8953a..d80c2b352 100644 --- a/src/com/sap/piper/cm/ChangeManagementException.groovy +++ b/src/com/sap/piper/cm/ChangeManagementException.groovy @@ -1,4 +1,4 @@ -package com.sap.piper.cm; +package com.sap.piper.cm public class ChangeManagementException extends RuntimeException { diff --git a/src/com/sap/piper/cm/StepHelpers.groovy b/src/com/sap/piper/cm/StepHelpers.groovy index 11542522b..3f2e73681 100644 --- a/src/com/sap/piper/cm/StepHelpers.groovy +++ b/src/com/sap/piper/cm/StepHelpers.groovy @@ -1,4 +1,4 @@ -package com.sap.piper.cm; +package com.sap.piper.cm import com.cloudbees.groovy.cps.NonCPS diff --git a/src/com/sap/piper/tools/neo/DeployMode.groovy b/src/com/sap/piper/tools/neo/DeployMode.groovy index a4abc3811..fc7bfb5b7 100644 --- a/src/com/sap/piper/tools/neo/DeployMode.groovy +++ b/src/com/sap/piper/tools/neo/DeployMode.groovy @@ -24,6 +24,6 @@ enum DeployMode { throw new IllegalArgumentException("${value} is not in the list of possible values ${stringValues()}") } - return enumValue; + return enumValue } } diff --git a/src/com/sap/piper/tools/neo/NeoCommandHelper.groovy b/src/com/sap/piper/tools/neo/NeoCommandHelper.groovy index 8f883c939..86b71ed8b 100644 --- a/src/com/sap/piper/tools/neo/NeoCommandHelper.groovy +++ b/src/com/sap/piper/tools/neo/NeoCommandHelper.groovy @@ -123,7 +123,7 @@ class NeoCommandHelper { def environment = deploymentConfiguration.environment if (!(environment in Map)) { - step.error("The environment variables for the deployment to Neo have to be defined as a map."); + step.error("The environment variables for the deployment to Neo have to be defined as a map.") } def keys = environment.keySet() diff --git a/src/com/sap/piper/tools/neo/WarAction.groovy b/src/com/sap/piper/tools/neo/WarAction.groovy index 03c8e13ae..68fbd70aa 100644 --- a/src/com/sap/piper/tools/neo/WarAction.groovy +++ b/src/com/sap/piper/tools/neo/WarAction.groovy @@ -21,6 +21,6 @@ enum WarAction { throw new IllegalArgumentException("${value} is not in the list of possible values ${stringValues()}") } - return enumValue; + return enumValue } } diff --git a/test/groovy/CommonStepsTest.groovy b/test/groovy/CommonStepsTest.groovy index d684c7c19..04602e7ca 100644 --- a/test/groovy/CommonStepsTest.groovy +++ b/test/groovy/CommonStepsTest.groovy @@ -6,7 +6,7 @@ import static org.junit.Assert.assertThat import static org.junit.Assert.fail import static util.StepHelper.getSteps -import java.io.File; +import java.io.File import java.util.stream.Collectors import java.lang.reflect.Field @@ -193,7 +193,7 @@ public class CommonStepsTest extends BasePiperTest{ continue } - boolean notAccessible = false; + boolean notAccessible = false def fieldName if(!stepNameField.isAccessible()) { diff --git a/test/groovy/DockerExecuteOnKubernetesTest.groovy b/test/groovy/DockerExecuteOnKubernetesTest.groovy index bdd2620fa..aa49ea395 100644 --- a/test/groovy/DockerExecuteOnKubernetesTest.groovy +++ b/test/groovy/DockerExecuteOnKubernetesTest.groovy @@ -207,7 +207,7 @@ class DockerExecuteOnKubernetesTest extends BasePiperTest { @Test void testDockerExecuteOnKubernetesEmptyContainerMapNoDockerImage() throws Exception { - exception.expect(IllegalArgumentException.class); + exception.expect(IllegalArgumentException.class) stepRule.step.dockerExecuteOnKubernetes( script: nullScript, juStabUtils: utils, diff --git a/test/groovy/PrepareDefaultValuesTest.groovy b/test/groovy/PrepareDefaultValuesTest.groovy index 3b4386b1e..4136ae6e1 100644 --- a/test/groovy/PrepareDefaultValuesTest.groovy +++ b/test/groovy/PrepareDefaultValuesTest.groovy @@ -1,15 +1,15 @@ import org.junit.Before -import org.junit.Rule; +import org.junit.Rule import org.junit.Test import org.junit.rules.ExpectedException -import org.junit.rules.RuleChain; +import org.junit.rules.RuleChain import com.sap.piper.DefaultValueCache import util.BasePiperTest import util.JenkinsLoggingRule import util.JenkinsReadYamlRule import util.JenkinsShellCallRule -import util.JenkinsStepRule; +import util.JenkinsStepRule import util.Rules diff --git a/test/groovy/com/sap/piper/MapUtilsTest.groovy b/test/groovy/com/sap/piper/MapUtilsTest.groovy index a7b0415ef..1ef0ec518 100644 --- a/test/groovy/com/sap/piper/MapUtilsTest.groovy +++ b/test/groovy/com/sap/piper/MapUtilsTest.groovy @@ -22,7 +22,7 @@ class MapUtilsTest { c: [d: '1', e: '2']], b = [b: '2', - c: [d: 'x']]; + c: [d: 'x']] Map merged = MapUtils.merge(a, b) diff --git a/test/groovy/com/sap/piper/MtaUtilsTest.groovy b/test/groovy/com/sap/piper/MtaUtilsTest.groovy index a1da44d66..3c1c1b7c8 100644 --- a/test/groovy/com/sap/piper/MtaUtilsTest.groovy +++ b/test/groovy/com/sap/piper/MtaUtilsTest.groovy @@ -25,7 +25,7 @@ class MtaUtilsTest extends BasePiperTest { private File badJson private mtaUtils - private ExpectedException thrown= ExpectedException.none(); + private ExpectedException thrown= ExpectedException.none() @ClassRule public static TemporaryFolder tmp = new TemporaryFolder() diff --git a/test/groovy/com/sap/piper/k8s/SystemEnvTest.groovy b/test/groovy/com/sap/piper/k8s/SystemEnvTest.groovy index 0ff64acc7..2e52490c1 100644 --- a/test/groovy/com/sap/piper/k8s/SystemEnvTest.groovy +++ b/test/groovy/com/sap/piper/k8s/SystemEnvTest.groovy @@ -8,7 +8,7 @@ import static org.junit.Assert.assertEquals import static org.junit.Assert.assertNotNull class SystemEnvTest { - SystemEnv env = null; + SystemEnv env = null Map systemEnvironmentMock = [:] @Before void setUp() { diff --git a/test/groovy/util/JenkinsLoggingRule.groovy b/test/groovy/util/JenkinsLoggingRule.groovy index ed0ef0048..f4a4f3d92 100644 --- a/test/groovy/util/JenkinsLoggingRule.groovy +++ b/test/groovy/util/JenkinsLoggingRule.groovy @@ -8,7 +8,7 @@ import org.junit.runner.Description import org.junit.runners.model.Statement import static org.hamcrest.Matchers.containsString -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertThat import org.hamcrest.Matchers diff --git a/test/groovy/util/JenkinsShellCallRule.groovy b/test/groovy/util/JenkinsShellCallRule.groovy index 6209d9341..6b65baccc 100644 --- a/test/groovy/util/JenkinsShellCallRule.groovy +++ b/test/groovy/util/JenkinsShellCallRule.groovy @@ -31,8 +31,8 @@ class JenkinsShellCallRule implements TestRule { @Override public boolean equals(Object obj) { - if (obj == null || !obj instanceof Command) return false; - Command other = (Command) obj; + if (obj == null || !obj instanceof Command) return false + Command other = (Command) obj return type == other.type && script == other.script } } diff --git a/test/groovy/util/PipelineWhenException.groovy b/test/groovy/util/PipelineWhenException.groovy index 7a22607f9..a6f4215b2 100644 --- a/test/groovy/util/PipelineWhenException.groovy +++ b/test/groovy/util/PipelineWhenException.groovy @@ -5,6 +5,6 @@ import hudson.AbortException class PipelineWhenException extends AbortException{ public PipelineWhenException(String message) { - super(message); + super(message) } } diff --git a/test/groovy/util/StepHelper.groovy b/test/groovy/util/StepHelper.groovy index 59fb311e5..9571e3062 100644 --- a/test/groovy/util/StepHelper.groovy +++ b/test/groovy/util/StepHelper.groovy @@ -1,6 +1,6 @@ -package util; +package util -import java.util.List; +import java.util.List import groovy.io.FileType diff --git a/vars/mailSendNotification.groovy b/vars/mailSendNotification.groovy index d20c259f2..1c898b636 100644 --- a/vars/mailSendNotification.groovy +++ b/vars/mailSendNotification.groovy @@ -197,7 +197,7 @@ def getCulprits(config, branch, numberOfCommits) { ignoreMissing: true ) { def pullRequestID = branch.replaceAll('PR-', '') - def localBranchName = "pr" + pullRequestID; + def localBranchName = "pr" + pullRequestID sh """git init git fetch ${config.gitUrl} pull/${pullRequestID}/head:${localBranchName} > /dev/null 2>&1 git checkout -f ${localBranchName} > /dev/null 2>&1 diff --git a/vars/sonarExecuteScan.groovy b/vars/sonarExecuteScan.groovy index e843fb8f3..ecd2fc03c 100644 --- a/vars/sonarExecuteScan.groovy +++ b/vars/sonarExecuteScan.groovy @@ -160,7 +160,7 @@ void call(Map parameters = [:]) { switch(config.pullRequestProvider){ case 'github': config.options.add("sonar.pullrequest.github.repository=${config.githubOrg}/${config.githubRepo}") - break; + break default: error "Pull-Request provider '${config.pullRequestProvider}' is not supported!" } workerForGithubAuth(config) From 71edb2aaac261ad2f5a8e9665594a679836c889b Mon Sep 17 00:00:00 2001 From: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com> Date: Thu, 23 May 2019 17:37:47 +0200 Subject: [PATCH 46/67] Doc generator - allow generation of stage documentation (#713) * Doc generator - allow generation of stage documentation --- documentation/bin/createDocu.groovy | 243 ++++++++++++++++++++++++++- documentation/docs/stages/confirm.md | 13 ++ 2 files changed, 250 insertions(+), 6 deletions(-) create mode 100644 documentation/docs/stages/confirm.md diff --git a/documentation/bin/createDocu.groovy b/documentation/bin/createDocu.groovy index 5bbf33c23..648d4828a 100644 --- a/documentation/bin/createDocu.groovy +++ b/documentation/bin/createDocu.groovy @@ -3,6 +3,7 @@ import groovy.json.JsonOutput import org.yaml.snakeyaml.Yaml import org.codehaus.groovy.control.CompilerConfiguration import com.sap.piper.GenerateDocumentation +import com.sap.piper.GenerateStageDocumentation import java.util.regex.Matcher import groovy.text.StreamingTemplateEngine @@ -23,8 +24,7 @@ class TemplateHelper { def props = parameters.get(it) - def defaultValue = isComplexDefault(props.defaultValue) ? renderComplexDefaultValue(props.defaultValue) : - props.defaultValue != null ? "`${props.defaultValue}`" : '' + def defaultValue = isComplexDefault(props.defaultValue) ? renderComplexDefaultValue(props.defaultValue) : renderSimpleDefaultValue(props.defaultValue) t += "| `${it}` | ${props.mandatory ?: props.required ? 'yes' : 'no'} | ${defaultValue} | ${props.value ?: ''} |\n" } @@ -49,6 +49,11 @@ class TemplateHelper { .join('
') } + private static renderSimpleDefaultValue(def _default) { + if (_default == null) return '' + return "`${_default}`" + } + static createParameterDescriptionSection(Map parameters) { def t = '' parameters.keySet().toSorted().each { @@ -79,6 +84,98 @@ class TemplateHelper { t.trim() } + + static createStageContentSection(Map stageDescriptions) { + def t = 'This stage comprises following steps which are activated depending on your use-case/configuration:\n\n' + + t += '| step | step description |\n' + t += '| ---- | ---------------- |\n' + + stageDescriptions.each {step, description -> + t += "| [${step}](../steps/${step}.md) | ${description.trim()} |\n" + } + + return t + } + + static createStageActivationSection() { + def t = '''This stage will be active if any one of the following conditions is met: + +* Stage configuration in [config.yml file](../configuration.md) contains entries for this stage. +* Any of the conditions are met which are explained in the section [Step Activation](#step-activation). +''' + return t.trim() + } + + static createStepActivationSection(Map configConditions) { + if (!configConditions) return 'For this stage no conditions are assigned to steps.' + def t = 'Certain steps will be activated automatically depending on following conditions:\n\n' + + + t += '| step | config key | config value | file pattern |\n' + t += '| ---- | ---------- | ------------ | ------------ |\n' + + configConditions?.each {stepName, conditions -> + t += "| ${stepName} " + t += "| ${renderValueList(conditions?.configKeys)} " + t += "| ${renderValueList(mapToValueList(conditions?.config))} " + + List filePatterns = [] + if (conditions?.filePattern) filePatterns.add(conditions?.filePattern) + if (conditions?.filePatternFromConfig) filePatterns.add(conditions?.filePatternFromConfig) + t += "| ${renderValueList(filePatterns)} |\n" + } + + t += ''' +!!! info "Step condition details" + There are currently several conditions which can be checked.
This is done in the [Init stage](init.md) of the pipeline shortly after checkout of the source code repository.
+ **Important: It will be sufficient that any one condition per step is met.** + + * `config key`: Checks if a defined configuration parameter is set. + * `config value`: Checks if a configuration parameter has a defined value. + * `file pattern`: Checks if files according a defined pattern exist in the project. Either the pattern is speficified direcly or it is retrieved from a configuration parameter. + + +!!! note "Overruling step activation conditions" + It is possible to overrule the automatically detected step activation status.
+ Just add to your stage configuration `: false`, for example `deployToKubernetes: false`. + +For details about the configuration options, please see [Configuration of Piper](../configuration.md). +''' + + return t + } + + private static renderValueList(List valueList) { + if (!valueList) return '' + if (valueList.size() > 1) { + List quotedList = [] + valueList.each {listItem -> + quotedList.add("-`${listItem}`") + } + return quotedList.join('
') + } else { + return "`${valueList[0]}`" + } + } + + private static mapToValueList(Map map) { + List valueList = [] + map?.each {key, value -> + if (value instanceof List) { + value.each {listItem -> + valueList.add("${key}: ${listItem}") + } + } else { + valueList.add("${key}: ${value}") + } + } + return valueList + } + + static createStageConfigurationSection() { + return 'The stage parameters need to be defined in the section `stages` of [config.yml file](../configuration.md).' + } } // @@ -119,6 +216,11 @@ class Helper { prepareDefaultValuesStep } + static Map getYamlResource(String resource) { + def ymlContent = new File(projectRoot,"resources/${resource}").text + return new Yaml().load(ymlContent) + } + static getDummyScript(def prepareDefaultValuesStep, def stepName, Map prepareDefaultValuesStepParams) { def _prepareDefaultValuesStep = prepareDefaultValuesStep @@ -347,6 +449,15 @@ class Helper { return params } + static getStageStepKeys(def script) { + try { + return script.STAGE_STEP_KEYS ?: [] + } catch (groovy.lang.MissingPropertyException ex) { + System.err << "[INFO] STAGE_STEP_KEYS not set for: ${script.STEP_NAME}.\n" + return [] + } + } + static getRequiredParameters(File f) { def params = [] as Set f.eachLine { @@ -387,7 +498,7 @@ class Helper { def scriptName = (it =~ /vars\${File.separator}(.*)\.groovy/)[0][1] def stepScript = gse.createScript("${scriptName}.groovy", new Binding()) for (def method in stepScript.getClass().getMethods()) { - if(method.getName() == 'call' && method.getAnnotation(GenerateDocumentation) != null) { + if(method.getName() == 'call' && (method.getAnnotation(GenerateDocumentation) != null || method.getAnnotation(GenerateStageDocumentation) != null)) { docuRelevantSteps << scriptName break } @@ -396,6 +507,26 @@ class Helper { } docuRelevantSteps } + + static resolveDocuRelevantStages(GroovyScriptEngine gse, File stepsDir) { + + def docuRelevantStages = [:] + + stepsDir.traverse(type: FileType.FILES, maxDepth: 0) { + if(it.getName().endsWith('.groovy')) { + def scriptName = (it =~ /vars\${File.separator}(.*)\.groovy/)[0][1] + def stepScript = gse.createScript("${scriptName}.groovy", new Binding()) + for (def method in stepScript.getClass().getMethods()) { + GenerateStageDocumentation stageDocsAnnotation = method.getAnnotation(GenerateStageDocumentation) + if(method.getName() == 'call' && stageDocsAnnotation != null) { + docuRelevantStages[scriptName] = stageDocsAnnotation.defaultStageName() + break + } + } + } + } + docuRelevantStages + } } roots = [ @@ -405,7 +536,8 @@ roots = [ stepsDir = null stepsDocuDir = null -String customDefaults = null +stagesDocuDir = null +customDefaults = null steps = [] @@ -421,7 +553,9 @@ def cli = new CliBuilder( cli.with { s longOpt: 'stepsDir', args: 1, argName: 'dir', 'The directory containing the steps. Defaults to \'vars\'.' d longOpt: 'docuDir', args: 1, argName: 'dir', 'The directory containing the docu stubs. Defaults to \'documentation/docs/steps\'.' + p longOpt: 'docuDirStages', args: 1, argName: 'dir', 'The directory containing the docu stubs for pipeline stages. Defaults to \'documentation/docs/stages\'.' c longOpt: 'customDefaults', args: 1, argName: 'file', 'Additional custom default configuration' + i longOpt: 'stageInitFile', args: 1, argName: 'file', 'The file containing initialization data for step piperInitRunStageConfiguration' h longOpt: 'help', 'Prints this help.' } @@ -433,17 +567,30 @@ if(options.h) { return } -if(options.s) +if(options.s){ + System.err << "[INFO] Using custom step root: ${options.s}.\n" stepsDir = new File(Helper.projectRoot, options.s) +} + stepsDir = stepsDir ?: new File(Helper.projectRoot, "vars") -if(options.d) +if(options.d) { + System.err << "[INFO] Using custom doc dir for steps: ${options.d}.\n" stepsDocuDir = new File(Helper.projectRoot, options.d) +} stepsDocuDir = stepsDocuDir ?: new File(Helper.projectRoot, "documentation/docs/steps") +if(options.p) { + System.err << "[INFO] Using custom doc dir for stages: ${options.p}.\n" + stagesDocuDir = new File(Helper.projectRoot, options.p) +} + +stagesDocuDir = stagesDocuDir ?: new File(Helper.projectRoot, "documentation/docs/stages") + if(options.c) { + System.err << "[INFO] Using custom defaults: ${options.c}.\n" customDefaults = options.c } @@ -478,6 +625,16 @@ if( ! steps) { System.err << "[INFO] Generating docu only for step ${steps.size > 1 ? 's' : ''} ${steps}.\n" } +// find all the stages that we have to document +Map stages = Helper.resolveDocuRelevantStages(gse, stepsDir) + +// retrieve default conditions for steps +//ToDo: allow passing config file name via parameter +Map stageConfig +if (options.s) { + stageConfig = Helper.getYamlResource(options.s) +} + def prepareDefaultValuesStep = Helper.getPrepareDefaultValuesStep(gse) boolean exceptionCaught = false @@ -507,6 +664,39 @@ for(step in stepDescriptors) { } } +//update stepDescriptors: remove stages and put into separate stageDescriptors map +def stageDescriptors = [:] +stages.each {key, value -> + System.err << "[INFO] Processing stage '${key}' ...\n" + stageDescriptors."${key}" = [:] << stepDescriptors."${key}" + stepDescriptors.remove(key) + + //add stage name to stageDescriptors + stageDescriptors."${key}".name = value + + //add stepCondition informmation to stageDescriptors + stageDescriptors."${key}".configConditions = stageConfig?.stages?.get(value)?.stepConditions + + //identify step keys in stages + def stageStepKeys = Helper.getStageStepKeys(gse.createScript( "${key}.groovy", new Binding() )) + + // prepare step descriptions + stageDescriptors."${key}".stepDescriptions = [:] + stageDescriptors."${key}".parameters.each {paramKey, paramValue -> + + if (paramKey in stageStepKeys) { + stageDescriptors."${key}".stepDescriptions."${paramKey}" = "${paramValue.docu ?: ''}\n" + } + } + + //remove details from parameter map + stageStepKeys.each {stepKey -> + stageDescriptors."${key}".parameters.remove(stepKey) + } + + +} + for(step in stepDescriptors) { try { renderStep(step.key, step.value) @@ -517,6 +707,16 @@ for(step in stepDescriptors) { } } +for (stage in stageDescriptors) { + try { + renderStage(stage.key, stage.value) + System.err << "[INFO] Stage '${stage.key}' has been rendered.\n" + } catch(Exception e) { + exceptionCaught = true + System.err << "${e.getClass().getName()} caught while rendering stage '${stage}': ${e.getMessage()}.\n" + } +} + if(exceptionCaught) { System.err << "[ERROR] Exception caught during generating documentation. Check earlier log for details.\n" System.exit(1) @@ -549,6 +749,31 @@ void renderStep(stepName, stepProperties) { theStepDocu.withWriter { w -> w.write text } } +void renderStage(stageName, stageProperties) { + + def stageFileName = stageName.indexOf('Stage') != -1 ? stageName.split('Stage')[1].toLowerCase() : stageFileName + File theStageDocu = new File(stagesDocuDir, "${stageFileName}.md") + + if(!theStageDocu.exists()) { + System.err << "[WARNING] stage docu input file for stage '${stageName}' is missing.\n" + return + } + + def binding = [ + docGenStageName : stageProperties.name, + docGenDescription : stageProperties.description, + docGenStageContent : 'Stage Content\n\n' + TemplateHelper.createStageContentSection(stageProperties.stepDescriptions), + docGenStageActivation: 'Stage Activation\n\n' + TemplateHelper.createStageActivationSection(), + docGenStepActivation: 'Step Activation\n\n' + TemplateHelper.createStepActivationSection(stageProperties.configConditions), + docGenStageParameters : 'Additional Stage Parameters\n\n' + TemplateHelper.createParametersSection(stageProperties.parameters), + docGenStageConfiguration : 'Configuration of Additional Stage Parameters\n\n' + TemplateHelper.createStageConfigurationSection() + ] + def template = new StreamingTemplateEngine().createTemplate(theStageDocu.text) + String text = template.make(binding) + + theStageDocu.withWriter { w -> w.write text } +} + def fetchTextFrom(def step, def parameterName, def steps) { try { def docuFromOtherStep = steps[step]?.parameters[parameterName]?.docu @@ -578,6 +803,12 @@ def handleStep(stepName, prepareDefaultValuesStep, gse, customDefaults) { File theStep = new File(stepsDir, "${stepName}.groovy") File theStepDocu = new File(stepsDocuDir, "${stepName}.md") + if (!theStepDocu.exists() && stepName.indexOf('Stage') != -1) { + //try to get a corresponding stage documentation + def stageName = stepName.split('Stage')[1].toLowerCase() + theStepDocu = new File(stagesDocuDir,"${stageName}.md" ) + } + if(!theStepDocu.exists()) { System.err << "[WARNING] step docu input file for step '${stepName}' is missing.\n" return diff --git a/documentation/docs/stages/confirm.md b/documentation/docs/stages/confirm.md new file mode 100644 index 000000000..2c346e824 --- /dev/null +++ b/documentation/docs/stages/confirm.md @@ -0,0 +1,13 @@ +# ${docGenStageName} + +${docGenDescription} + +## ${docGenStageContent} + +## ${docGenStageActivation} + +## ${docGenStepActivation} + +## ${docGenStageParameters} + +## ${docGenStageConfiguration} From 927f199660f95651bdec836dafea7948116f6531 Mon Sep 17 00:00:00 2001 From: Alejandra Ferreiro Vidal Date: Wed, 22 May 2019 17:11:15 +0200 Subject: [PATCH 47/67] minor change in slackSendNotification documentation --- documentation/docs/steps/slackSendNotification.md | 2 +- vars/slackSendNotification.groovy | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/documentation/docs/steps/slackSendNotification.md b/documentation/docs/steps/slackSendNotification.md index 186617ec3..dc8545af9 100644 --- a/documentation/docs/steps/slackSendNotification.md +++ b/documentation/docs/steps/slackSendNotification.md @@ -6,7 +6,7 @@ * Installed and configured [Slack JenkinsCI integration](https://my.slack.com/services/new/jenkins-ci) * *secret text* Jenkins credentials with the Slack token -* Installed and configured [Jenkins Slack plugin](https://github.com/jenkinsci/slack-plugin#install-instructions-for-slack). +* Installed and configured [Jenkins Slack plugin](https://github.com/jenkinsci/slack-plugin#install-instructions-for-slack) ## ${docGenParameters} diff --git a/vars/slackSendNotification.groovy b/vars/slackSendNotification.groovy index 5cce4b158..50153740c 100644 --- a/vars/slackSendNotification.groovy +++ b/vars/slackSendNotification.groovy @@ -40,12 +40,12 @@ import groovy.text.SimpleTemplateEngine * * Notification contains: * - * * Build status; - * * Repo Owner; - * * Repo Name; - * * Branch Name; - * * Jenkins Build Number; - * * Jenkins Build URL. + * * Build status + * * Repo Owner + * * Repo Name + * * Branch Name + * * Jenkins Build Number + * * Jenkins Build URL */ @GenerateDocumentation void call(Map parameters = [:]) { From 952c6bbe88807afb747098aee326a71d5baac559 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 24 May 2019 09:22:16 +0200 Subject: [PATCH 48/67] remove empty line --- vars/neoDeploy.groovy | 1 - 1 file changed, 1 deletion(-) diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index 744809a05..e731fac3b 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -92,7 +92,6 @@ import static com.sap.piper.Prerequisites.checkScript * The path to the archive for deployment to SAP CP. If not provided `mtarFilePath` from commom pipeline environment is used instead. */ 'source' - ]) @Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS.plus([ From 35e76fca9bf5d74d7d3459d55d4a10a1dda634cc Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 24 May 2019 12:24:25 +0200 Subject: [PATCH 49/67] provide default for extensions in default config yml --- resources/default_pipeline_environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/default_pipeline_environment.yml b/resources/default_pipeline_environment.yml index 71f11f6d1..46332b98a 100644 --- a/resources/default_pipeline_environment.yml +++ b/resources/default_pipeline_environment.yml @@ -305,6 +305,7 @@ steps: neoDeploy: dockerImage: 's4sdk/docker-neo-cli' deployMode: 'mta' + extensions: [] warAction: 'deploy' neo: size: 'lite' From c053dbca17222712bd8b86e593e698629acee016 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 24 May 2019 12:32:13 +0200 Subject: [PATCH 50/67] Add test null provided via signatur for extensions (also inside collection) --- resources/default_pipeline_environment.yml | 1 - test/groovy/NeoDeployTest.groovy | 60 ++++++++++++++++++++++ vars/neoDeploy.groovy | 3 ++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/resources/default_pipeline_environment.yml b/resources/default_pipeline_environment.yml index 46332b98a..71f11f6d1 100644 --- a/resources/default_pipeline_environment.yml +++ b/resources/default_pipeline_environment.yml @@ -305,7 +305,6 @@ steps: neoDeploy: dockerImage: 's4sdk/docker-neo-cli' deployMode: 'mta' - extensions: [] warAction: 'deploy' neo: size: 'lite' diff --git a/test/groovy/NeoDeployTest.groovy b/test/groovy/NeoDeployTest.groovy index 65c1481fc..8dade10f7 100644 --- a/test/groovy/NeoDeployTest.groovy +++ b/test/groovy/NeoDeployTest.groovy @@ -154,17 +154,77 @@ class NeoDeployTest extends BasePiperTest { .hasSingleQuotedOption('extensions', 'myExtension.yml')) } + @Test + void extensionsAsEmptyString() { + + thrown.expect(AbortException) + thrown.expectMessage('extension file name was null or empty') + + stepRule.step.neoDeploy( + script: nullScript, + source: archiveName, + extensions: '' + ) + } + @Test void extensionsAsSetTest() { Set extensions= ['myExtension1.yml' ,'myExtension2.yml'] extensionsAsCollectionTest(extensions) } + @Test + void extensionsAsCollectionWithEmptyStringTest() { + + thrown.expect(AbortException) + thrown.expectMessage('extension file name was null or empty') + + stepRule.step.neoDeploy( + script: nullScript, + source: archiveName, + extensions: ['myExtension1.yml' ,'']) + } + + @Test + void extensionsNullTest() { + + stepRule.step.neoDeploy( + script: nullScript, + source: archiveName, + extensions: null) + + assert shellRule.shell.find { c -> c.startsWith('neo.sh deploy-mta') && ! c.contains('--extensions') } + } + + @Test + void extensionsAsEmptyCollectionTest() { + + stepRule.step.neoDeploy( + script: nullScript, + source: archiveName, + extensions: []) + + assert shellRule.shell.find { c -> c.startsWith('neo.sh deploy-mta') && ! c.contains('--extensions') } + } + + @Test + void extensionsAsCollectionsWithNullEntrySetTest() { + + thrown.expect(AbortException) + thrown.expectMessage('extension file name was null or empty') + + stepRule.step.neoDeploy( + script: nullScript, + source: archiveName, + extensions: [null]) + } + @Test void extensionsAsListTest() { List extensions= ['myExtension1.yml' ,'myExtension2.yml'] extensionsAsCollectionTest(extensions) } + @Test void sameExtensionProvidedTwiceTest() { List extensions= ['myExtension1.yml' ,'myExtension2.yml', 'myExtension1.yml'] diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index e731fac3b..6316c1fd6 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -162,6 +162,9 @@ void call(parameters = [:]) { extensionFileNames = configuration.extensions in Collection ? configuration.extensions : [configuration.extensions] } + if( ! extensionFileNames.findAll { it == null || it.isEmpty() }.isEmpty() ) + error "At least one extension file name was null or empty: ${extensionFileNames}." + if(deployMode != DeployMode.MTA && ! extensionFileNames.isEmpty()) error "Extensions (${extensionFileNames} found for deploy mode ${deployMode}. Extensions are only supported for deploy mode '${DeployMode.MTA}')" From 4cb80f9c6d019ab229ae40629b190c31f944d65d Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 24 May 2019 14:25:26 +0200 Subject: [PATCH 51/67] Add default for extensions for neo deploy in piper default config --- resources/default_pipeline_environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/default_pipeline_environment.yml b/resources/default_pipeline_environment.yml index 71f11f6d1..5f00afa0b 100644 --- a/resources/default_pipeline_environment.yml +++ b/resources/default_pipeline_environment.yml @@ -306,6 +306,7 @@ steps: dockerImage: 's4sdk/docker-neo-cli' deployMode: 'mta' warAction: 'deploy' + extensions: [] neo: size: 'lite' credentialsId: 'CI_CREDENTIALS_ID' From ef294eba71acf944ae7daa3cec548a0fc3b5f21f Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 24 May 2019 15:09:21 +0200 Subject: [PATCH 52/67] Add reference to docker plugin if kubernetes is present --- documentation/bin/createDocu.groovy | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/documentation/bin/createDocu.groovy b/documentation/bin/createDocu.groovy index 704e3ddca..b8560f8b8 100644 --- a/documentation/bin/createDocu.groovy +++ b/documentation/bin/createDocu.groovy @@ -18,6 +18,15 @@ class TemplateHelper { def t = '' t += 'The step depends on the following Jenkins plugins\n\n' def filteredDeps = deps.findAll { dep -> dep != 'UNIDENTIFIED' } + + if(filteredDeps.contains('kubernetes')) { + // The docker plugin is not detected by the tests since it is not + // handled via step call, but it is added to the environment. + // Hovever kubernetes plugin and docker plugin are closely related, + // hence adding docker if kubernetes is present. + filteredDeps.add('docker') + } + if(filteredDeps.isEmpty()) { t += '* <none>\n' } else { From e538db7ac530df79f58cd528c97d0d28aff746c1 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 24 May 2019 15:12:32 +0200 Subject: [PATCH 53/67] resolvePlugins.groovy is obsolete. Handled via Jenkinsfile in the meantime. --- resolvePlugins.groovy | 41 ----------------------------------------- resolvePlugins.sh | 39 --------------------------------------- 2 files changed, 80 deletions(-) delete mode 100644 resolvePlugins.groovy delete mode 100755 resolvePlugins.sh diff --git a/resolvePlugins.groovy b/resolvePlugins.groovy deleted file mode 100644 index 5f0468037..000000000 --- a/resolvePlugins.groovy +++ /dev/null @@ -1,41 +0,0 @@ -import jenkins.model.Jenkins - -def stepCallMapping = new groovy.json.JsonSlurper().parseText(new File(System.getenv()['calls']).text) - -def stepPluginMapping = [:] - -println "[INFO] Resolving plugins ..." - -for(def step in stepCallMapping) { - def resolvedPlugins = [:] - for(def call in step.value) { - def resolvedPlugin = resolvePlugin(call) - if (! resolvedPlugin) resolvedPlugin = 'UNIDENTIFIED' - if(resolvedPlugins[resolvedPlugin] == null) - resolvedPlugins[resolvedPlugin] = (Set)[] - resolvedPlugins[resolvedPlugin] << call - stepPluginMapping.put(step.key,resolvedPlugins) - } -} - -def result = System.getenv()['result'] -new File(result).write(new groovy.json.JsonOutput().toJson(stepPluginMapping)) - -println "[INFO] plugins resolved. Result: ${result}." - - -def resolvePlugin(call) { - - def plugins = Jenkins.get().pluginManager.getPlugins() - - def s = new org.jenkinsci.plugins.workflow.cps.Snippetizer() - - def pDescs = s.getQuasiDescriptors(false) - - - for(def pd in pDescs) { - if(pd.getSymbol() == call) - return pd.real.plugin?.shortName - } - return null -} diff --git a/resolvePlugins.sh b/resolvePlugins.sh deleted file mode 100755 index a27429692..000000000 --- a/resolvePlugins.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -mvn clean test -groovy documentation/bin/steps.groovy -in target/trackedCalls.json --out target/performedCalls.json - -WS_OUT="$(pwd)/jenkins_workspace" -WS_IN=/workspace - -REL_CALLS=calls.json -REL_RESULT=result.json - -CALLS="${WS_OUT}/${REL_CALLS}" -RESULT="${WS_OUT}/${REL_RESULT}" - -for f in ${CALLS} ${RESULT} -do - [ -e "${f}" ] && rm -rf "${f}" -done - -cp target/performedCalls.json "${CALLS}" - -[ -f "${CALLS}" ] || { echo "File \"${CALLS}\" does not exist." ; exit 1; } - -docker run \ - -w "${WS_IN}" \ - --env calls="${WS_IN}/${REL_CALLS}" \ - --env result="${WS_IN}/${REL_RESULT}" \ - -v "${WS_OUT}:${WS_IN}" \ - ppiper/jenkinsfile-runner \ - -ns \ - -f Jenkinsfile \ - --runWorkspace /workspace - -[ -f "${RESULT}" ] || { echo "Result file containing step to plugin mapping not found (${RESULT})."; exit 1; } - -which -s jq && jq 'keys[] as $k | .[$k] | keys as $v | $k, [$v]' "${RESULT}" - -documentation/bin/createDocu.sh $* -docker run --rm -it -v `pwd`:/docs -w /docs/documentation squidfunk/mkdocs-material:3.0.4 build --clean --verbose --strict From ca4e75631799f6183f505da3fb849b258921b8e3 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 24 May 2019 15:41:49 +0200 Subject: [PATCH 54/67] Relocated dependency docu --- documentation/docs/steps/artifactSetVersion.md | 4 ++-- documentation/docs/steps/batsExecuteTests.md | 4 ++-- documentation/docs/steps/checkChangeInDevelopment.md | 4 ++-- documentation/docs/steps/checksPublishResults.md | 4 ++-- documentation/docs/steps/cloudFoundryDeploy.md | 4 ++-- documentation/docs/steps/containerExecuteStructureTests.md | 4 ++-- documentation/docs/steps/dockerExecute.md | 4 ++-- documentation/docs/steps/dockerExecuteOnKubernetes.md | 4 ++-- documentation/docs/steps/durationMeasure.md | 4 ++-- documentation/docs/steps/gaugeExecuteTests.md | 4 ++-- documentation/docs/steps/githubPublishRelease.md | 4 ++-- documentation/docs/steps/handlePipelineStepErrors.md | 4 ++-- documentation/docs/steps/healthExecuteCheck.md | 4 ++-- documentation/docs/steps/influxWriteData.md | 4 ++-- documentation/docs/steps/mailSendNotification.md | 4 ++-- documentation/docs/steps/mavenExecute.md | 4 ++-- documentation/docs/steps/mtaBuild.md | 4 ++-- documentation/docs/steps/multicloudDeploy.md | 4 ++-- documentation/docs/steps/neoDeploy.md | 6 ++---- documentation/docs/steps/newmanExecute.md | 4 ++-- documentation/docs/steps/npmExecute.md | 4 ++-- documentation/docs/steps/pipelineExecute.md | 4 ++-- documentation/docs/steps/pipelineRestartSteps.md | 4 ++-- documentation/docs/steps/pipelineStashFiles.md | 4 ++-- documentation/docs/steps/pipelineStashFilesAfterBuild.md | 5 +++-- documentation/docs/steps/pipelineStashFilesBeforeBuild.md | 5 +++-- documentation/docs/steps/piperPipelineStagePost.md | 4 ++-- documentation/docs/steps/prepareDefaultValues.md | 4 ++-- documentation/docs/steps/seleniumExecuteTests.md | 4 ++-- documentation/docs/steps/setupCommonPipelineEnvironment.md | 4 ++-- documentation/docs/steps/slackSendNotification.md | 4 ++-- documentation/docs/steps/snykExecute.md | 4 ++-- documentation/docs/steps/sonarExecuteScan.md | 4 ++-- documentation/docs/steps/testsPublishResults.md | 4 ++-- documentation/docs/steps/transportRequestCreate.md | 4 ++-- documentation/docs/steps/transportRequestRelease.md | 4 ++-- documentation/docs/steps/transportRequestUploadFile.md | 4 ++-- documentation/docs/steps/uiVeri5ExecuteTests.md | 4 ++-- documentation/docs/steps/whitesourceExecuteScan.md | 4 ++-- 39 files changed, 80 insertions(+), 80 deletions(-) diff --git a/documentation/docs/steps/artifactSetVersion.md b/documentation/docs/steps/artifactSetVersion.md index cc4fcba01..0479c65e2 100644 --- a/documentation/docs/steps/artifactSetVersion.md +++ b/documentation/docs/steps/artifactSetVersion.md @@ -6,12 +6,12 @@ none -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Example ```groovy diff --git a/documentation/docs/steps/batsExecuteTests.md b/documentation/docs/steps/batsExecuteTests.md index 55d47a6fb..8bec79b32 100644 --- a/documentation/docs/steps/batsExecuteTests.md +++ b/documentation/docs/steps/batsExecuteTests.md @@ -6,12 +6,12 @@ You need to have a Bats test file. By default you would put this into directory `src/test` within your source code repository. -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Example ```groovy diff --git a/documentation/docs/steps/checkChangeInDevelopment.md b/documentation/docs/steps/checkChangeInDevelopment.md index abac3bf7f..ca72f691d 100644 --- a/documentation/docs/steps/checkChangeInDevelopment.md +++ b/documentation/docs/steps/checkChangeInDevelopment.md @@ -6,12 +6,12 @@ * **[Change Management Client 2.0.0 or compatible version](http://central.maven.org/maven2/com/sap/devops/cmclient/dist.cli/)** - available for download on Maven Central. -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Exceptions * `AbortException`: diff --git a/documentation/docs/steps/checksPublishResults.md b/documentation/docs/steps/checksPublishResults.md index 5c37fe49d..276759766 100644 --- a/documentation/docs/steps/checksPublishResults.md +++ b/documentation/docs/steps/checksPublishResults.md @@ -13,8 +13,6 @@ * [warnings](https://plugins.jenkins.io/warnings) * [core](https://plugins.jenkins.io/core) -## ${docDependencies} - ## ${docGenParameters} ### aggregation @@ -84,6 +82,8 @@ ## ${docGenConfiguration} +## ${docDependencies} + ### Thresholds It is possible to define thresholds to fail the build on a certain count of findings. To achive this, just define your thresholds a followed for the specific check tool: diff --git a/documentation/docs/steps/cloudFoundryDeploy.md b/documentation/docs/steps/cloudFoundryDeploy.md index f2c16fed6..1d19514c9 100644 --- a/documentation/docs/steps/cloudFoundryDeploy.md +++ b/documentation/docs/steps/cloudFoundryDeploy.md @@ -9,12 +9,12 @@ ![Jenkins credentials configuration](../images/cf_credentials.png) -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Example ```groovy diff --git a/documentation/docs/steps/containerExecuteStructureTests.md b/documentation/docs/steps/containerExecuteStructureTests.md index 838a33f32..338ece538 100644 --- a/documentation/docs/steps/containerExecuteStructureTests.md +++ b/documentation/docs/steps/containerExecuteStructureTests.md @@ -6,12 +6,12 @@ Test configuration is available. -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Example ``` diff --git a/documentation/docs/steps/dockerExecute.md b/documentation/docs/steps/dockerExecute.md index 576718d1d..9e3d88f21 100644 --- a/documentation/docs/steps/dockerExecute.md +++ b/documentation/docs/steps/dockerExecute.md @@ -2,8 +2,6 @@ ## ${docGenDescription} -## ${docDependencies} - ## ${docGenParameters} ## Kubernetes support @@ -12,6 +10,8 @@ If the Jenkins is setup on a Kubernetes cluster, then you can execute the closur ## ${docGenConfiguration} +## ${docDependencies} + ## Side effects none diff --git a/documentation/docs/steps/dockerExecuteOnKubernetes.md b/documentation/docs/steps/dockerExecuteOnKubernetes.md index 0ae2dbaf3..e1d7b443d 100644 --- a/documentation/docs/steps/dockerExecuteOnKubernetes.md +++ b/documentation/docs/steps/dockerExecuteOnKubernetes.md @@ -9,12 +9,12 @@ ![Jenkins environment variable configuration](../images/k8s_env.png) -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Side effects none diff --git a/documentation/docs/steps/durationMeasure.md b/documentation/docs/steps/durationMeasure.md index 8a6c0684c..afae2f189 100644 --- a/documentation/docs/steps/durationMeasure.md +++ b/documentation/docs/steps/durationMeasure.md @@ -2,12 +2,12 @@ ## ${docGenDescription} -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Example ```groovy diff --git a/documentation/docs/steps/gaugeExecuteTests.md b/documentation/docs/steps/gaugeExecuteTests.md index c654e1788..2adef1920 100644 --- a/documentation/docs/steps/gaugeExecuteTests.md +++ b/documentation/docs/steps/gaugeExecuteTests.md @@ -6,14 +6,14 @@ none -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} We recommend to define values of step parameters via [config.yml file](../configuration.md). +## ${docDependencies} + ## Example Pipeline step: diff --git a/documentation/docs/steps/githubPublishRelease.md b/documentation/docs/steps/githubPublishRelease.md index 6c9e150d1..0fe05cc8c 100644 --- a/documentation/docs/steps/githubPublishRelease.md +++ b/documentation/docs/steps/githubPublishRelease.md @@ -1,7 +1,5 @@ # ${docGenStepName} -## ${docGenDescription} - ## Prerequisites You need to create a personal access token within GitHub and add this to the Jenkins credentials store. @@ -14,6 +12,8 @@ Please see [GitHub documentation for details about creating the personal access ## ${docGenConfiguration} +## ${docGenDescription} + ## Example Usage of pipeline step: diff --git a/documentation/docs/steps/handlePipelineStepErrors.md b/documentation/docs/steps/handlePipelineStepErrors.md index 59706f03b..18f90fb37 100644 --- a/documentation/docs/steps/handlePipelineStepErrors.md +++ b/documentation/docs/steps/handlePipelineStepErrors.md @@ -6,12 +6,12 @@ none -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Example ```groovy diff --git a/documentation/docs/steps/healthExecuteCheck.md b/documentation/docs/steps/healthExecuteCheck.md index 8547fec79..9df27328d 100644 --- a/documentation/docs/steps/healthExecuteCheck.md +++ b/documentation/docs/steps/healthExecuteCheck.md @@ -12,12 +12,12 @@ Endpoint for health check is configured. !!! tip If using Spring Boot framework, ideally the provided `/health` endpoint is used and extended by development. Further information can be found in the [Spring Boot documenation for Endpoints](http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html) -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Example Pipeline step: diff --git a/documentation/docs/steps/influxWriteData.md b/documentation/docs/steps/influxWriteData.md index c7087cd9a..c5c74ff5c 100644 --- a/documentation/docs/steps/influxWriteData.md +++ b/documentation/docs/steps/influxWriteData.md @@ -4,8 +4,6 @@ ## Prerequisites -## ${docDependencies} - ### Setting up InfluxDB with Grafana The easiest way to start with is using the available official docker images. @@ -69,6 +67,8 @@ influxDBServer=jenkins ## ${docGenConfiguration} +## ${docDependencies} + ## Example ```groovy diff --git a/documentation/docs/steps/mailSendNotification.md b/documentation/docs/steps/mailSendNotification.md index d167ac42a..b5f2cac32 100644 --- a/documentation/docs/steps/mailSendNotification.md +++ b/documentation/docs/steps/mailSendNotification.md @@ -6,8 +6,6 @@ none -## ${docDependencies} - ## Example Usage of pipeline step: @@ -20,6 +18,8 @@ mailSendNotification script: this ## ${docGenConfiguration} +## ${docDependencies} + ## Side effects none diff --git a/documentation/docs/steps/mavenExecute.md b/documentation/docs/steps/mavenExecute.md index 40f2544aa..b87488475 100644 --- a/documentation/docs/steps/mavenExecute.md +++ b/documentation/docs/steps/mavenExecute.md @@ -2,12 +2,12 @@ ## ${docGenDescription} -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Exceptions None diff --git a/documentation/docs/steps/mtaBuild.md b/documentation/docs/steps/mtaBuild.md index bd8e323fc..3c73d2ef3 100644 --- a/documentation/docs/steps/mtaBuild.md +++ b/documentation/docs/steps/mtaBuild.md @@ -10,12 +10,12 @@ While using a custom docker file, ensure that the following tools are installed: * **Java 8 or compatible version** - necessary to run the *MTA Archive Builder* itself and to build Java modules. * **NodeJS installed** - the MTA Builder uses `npm` to download node module dependencies such as `grunt`. -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Side effects 1. The file name of the resulting archive is written to the `commonPipelineEnvironment` with variable name `mtarFileName`. diff --git a/documentation/docs/steps/multicloudDeploy.md b/documentation/docs/steps/multicloudDeploy.md index 06ab7d695..0f3f70c46 100644 --- a/documentation/docs/steps/multicloudDeploy.md +++ b/documentation/docs/steps/multicloudDeploy.md @@ -1,13 +1,13 @@ # ${docGenStepName} -## ${docGenDescription} - ## ${docDependencies} ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Examples ```groovy diff --git a/documentation/docs/steps/neoDeploy.md b/documentation/docs/steps/neoDeploy.md index fecea0ab2..836aa9571 100644 --- a/documentation/docs/steps/neoDeploy.md +++ b/documentation/docs/steps/neoDeploy.md @@ -14,14 +14,12 @@ * **Java 8 or compatible version** - needed by the *Neo-Java-Web-SDK*. Java environment needs to be properly configured (JAVA_HOME, java exectutable contained in path). -## ${docDependencies} - -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Side effects none diff --git a/documentation/docs/steps/newmanExecute.md b/documentation/docs/steps/newmanExecute.md index 39fdc389a..67dd65a0c 100644 --- a/documentation/docs/steps/newmanExecute.md +++ b/documentation/docs/steps/newmanExecute.md @@ -6,8 +6,6 @@ * prepared Postman with a test collection -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} @@ -16,6 +14,8 @@ Step uses `dockerExecute` inside. +## ${docDependencies} + ## Exceptions none diff --git a/documentation/docs/steps/npmExecute.md b/documentation/docs/steps/npmExecute.md index 236c52106..b9f0856e6 100644 --- a/documentation/docs/steps/npmExecute.md +++ b/documentation/docs/steps/npmExecute.md @@ -1,14 +1,14 @@ # ${docGenStepName} -## ${docGenDescription} - ## ${docDependencies} ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Exceptions None diff --git a/documentation/docs/steps/pipelineExecute.md b/documentation/docs/steps/pipelineExecute.md index fa33d2df9..580584ded 100644 --- a/documentation/docs/steps/pipelineExecute.md +++ b/documentation/docs/steps/pipelineExecute.md @@ -6,12 +6,12 @@ none -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Side effects none diff --git a/documentation/docs/steps/pipelineRestartSteps.md b/documentation/docs/steps/pipelineRestartSteps.md index dae4f3733..fe31237b0 100644 --- a/documentation/docs/steps/pipelineRestartSteps.md +++ b/documentation/docs/steps/pipelineRestartSteps.md @@ -6,8 +6,6 @@ none -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} @@ -33,6 +31,8 @@ pipelineRestartSteps (script: this) { none +## ${docDependencies} + ## Exceptions none diff --git a/documentation/docs/steps/pipelineStashFiles.md b/documentation/docs/steps/pipelineStashFiles.md index 816e83609..70a17d02a 100644 --- a/documentation/docs/steps/pipelineStashFiles.md +++ b/documentation/docs/steps/pipelineStashFiles.md @@ -6,8 +6,6 @@ none -## ${docDependencies} - ## ${docGenParameters} Details: @@ -36,6 +34,8 @@ The step is stashing files before and after the build. This is due to the fact, ## ${docGenConfiguration} +## ${docDependencies} + ## Explanation of pipeline step Usage of pipeline step: diff --git a/documentation/docs/steps/pipelineStashFilesAfterBuild.md b/documentation/docs/steps/pipelineStashFilesAfterBuild.md index d461f3702..251204aed 100644 --- a/documentation/docs/steps/pipelineStashFilesAfterBuild.md +++ b/documentation/docs/steps/pipelineStashFilesAfterBuild.md @@ -1,7 +1,5 @@ # ${docGenStepName} -## ${docGenDescription} - ## Prerequsites none @@ -11,3 +9,6 @@ none ## ${docGenParameters} ## ${docGenConfiguration} + +## ${docDependencies} + diff --git a/documentation/docs/steps/pipelineStashFilesBeforeBuild.md b/documentation/docs/steps/pipelineStashFilesBeforeBuild.md index d461f3702..09b294d8a 100644 --- a/documentation/docs/steps/pipelineStashFilesBeforeBuild.md +++ b/documentation/docs/steps/pipelineStashFilesBeforeBuild.md @@ -6,8 +6,9 @@ none -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} + +## ${docDependencies} + diff --git a/documentation/docs/steps/piperPipelineStagePost.md b/documentation/docs/steps/piperPipelineStagePost.md index 1aaca01e0..4b8162443 100644 --- a/documentation/docs/steps/piperPipelineStagePost.md +++ b/documentation/docs/steps/piperPipelineStagePost.md @@ -2,8 +2,8 @@ ## ${docGenDescription} -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} + +## ${docDependencies} diff --git a/documentation/docs/steps/prepareDefaultValues.md b/documentation/docs/steps/prepareDefaultValues.md index fc41a5404..8b4c76258 100644 --- a/documentation/docs/steps/prepareDefaultValues.md +++ b/documentation/docs/steps/prepareDefaultValues.md @@ -2,8 +2,6 @@ ## ${docGenDescription} -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} @@ -12,6 +10,8 @@ None +## ${docDependencies} + ## Example ```groovy diff --git a/documentation/docs/steps/seleniumExecuteTests.md b/documentation/docs/steps/seleniumExecuteTests.md index 5a9ea224c..21539026c 100644 --- a/documentation/docs/steps/seleniumExecuteTests.md +++ b/documentation/docs/steps/seleniumExecuteTests.md @@ -6,8 +6,6 @@ none -## ${docDependencies} - ## Example ```groovy @@ -70,6 +68,8 @@ webdriverio ## ${docGenConfiguration} +## ${docDependencies} + ## Side effects none diff --git a/documentation/docs/steps/setupCommonPipelineEnvironment.md b/documentation/docs/steps/setupCommonPipelineEnvironment.md index 1b703f963..4c437659c 100644 --- a/documentation/docs/steps/setupCommonPipelineEnvironment.md +++ b/documentation/docs/steps/setupCommonPipelineEnvironment.md @@ -6,12 +6,12 @@ * A **configuration file** with properties. The property values are used as default values in many pipeline steps. -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Side effects none diff --git a/documentation/docs/steps/slackSendNotification.md b/documentation/docs/steps/slackSendNotification.md index 4342e4a09..40c851382 100644 --- a/documentation/docs/steps/slackSendNotification.md +++ b/documentation/docs/steps/slackSendNotification.md @@ -8,12 +8,12 @@ * *secret text* Jenkins credentials with the Slack token * Installed and configured [Jenkins Slack plugin](https://github.com/jenkinsci/slack-plugin#install-instructions-for-slack). -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Example Usage of pipeline step: diff --git a/documentation/docs/steps/snykExecute.md b/documentation/docs/steps/snykExecute.md index 2508ceb53..2bd1e1994 100644 --- a/documentation/docs/steps/snykExecute.md +++ b/documentation/docs/steps/snykExecute.md @@ -7,12 +7,12 @@ * **Snyk account** - have an account on snyk.io * **Snyk token** - have a Snyk user token -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Side effects Step uses `dockerExecute` inside. diff --git a/documentation/docs/steps/sonarExecuteScan.md b/documentation/docs/steps/sonarExecuteScan.md index c1a8e3043..22f064225 100644 --- a/documentation/docs/steps/sonarExecuteScan.md +++ b/documentation/docs/steps/sonarExecuteScan.md @@ -7,12 +7,12 @@ - The project needs a `sonar-project.properties` file that describes the project and defines certain settings, see [here](https://docs.sonarqube.org/display/SCAN/Advanced+SonarQube+Scanner+Usages#AdvancedSonarQubeScannerUsages-Multi-moduleProjectStructure). - A SonarQube instance needs to be defined in the Jenkins. -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Exceptions none diff --git a/documentation/docs/steps/testsPublishResults.md b/documentation/docs/steps/testsPublishResults.md index 2dca45ce5..54b6c5f5c 100644 --- a/documentation/docs/steps/testsPublishResults.md +++ b/documentation/docs/steps/testsPublishResults.md @@ -11,8 +11,6 @@ * [cobertura](https://plugins.jenkins.io/cobertura) * [performance](https://plugins.jenkins.io/performance) -## ${docDependencies} - ## Pipeline configuration none @@ -81,6 +79,8 @@ testsPublishResults( ## ${docGenConfiguration} +## ${docDependencies} + ## Side effects none diff --git a/documentation/docs/steps/transportRequestCreate.md b/documentation/docs/steps/transportRequestCreate.md index 01904ceb9..ec72d5c80 100644 --- a/documentation/docs/steps/transportRequestCreate.md +++ b/documentation/docs/steps/transportRequestCreate.md @@ -7,12 +7,12 @@ * **[Change Management Client 2.0.0 or compatible version](http://central.maven.org/maven2/com/sap/devops/cmclient/dist.cli/)** - available for download on Maven Central. * Solution Manager version `ST720 SP08` or newer. -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + The step is configured using a customer configuration file provided as resource in an custom shared library. diff --git a/documentation/docs/steps/transportRequestRelease.md b/documentation/docs/steps/transportRequestRelease.md index 6b08edbd9..7434c6979 100644 --- a/documentation/docs/steps/transportRequestRelease.md +++ b/documentation/docs/steps/transportRequestRelease.md @@ -6,12 +6,12 @@ * **[Change Management Client 2.0.0 or compatible version](http://central.maven.org/maven2/com/sap/devops/cmclient/dist.cli/)** - available for download on Maven Central. -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + The step is configured using a customer configuration file provided as resource in an custom shared library. diff --git a/documentation/docs/steps/transportRequestUploadFile.md b/documentation/docs/steps/transportRequestUploadFile.md index 191ac8f52..331444d09 100644 --- a/documentation/docs/steps/transportRequestUploadFile.md +++ b/documentation/docs/steps/transportRequestUploadFile.md @@ -6,12 +6,12 @@ * **[Change Management Client 2.0.0 or compatible version](http://central.maven.org/maven2/com/sap/devops/cmclient/dist.cli/)** - available for download on Maven Central. -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + The step is configured using a customer configuration file provided as resource in an custom shared library. diff --git a/documentation/docs/steps/uiVeri5ExecuteTests.md b/documentation/docs/steps/uiVeri5ExecuteTests.md index 9b18898d8..2f27d4621 100644 --- a/documentation/docs/steps/uiVeri5ExecuteTests.md +++ b/documentation/docs/steps/uiVeri5ExecuteTests.md @@ -4,12 +4,12 @@ ## Prerequisites -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Exceptions If you see an error like `fatal: Not a git repository (or any parent up to mount point /home/jenkins)` it is likely that your test description cannot be found.
diff --git a/documentation/docs/steps/whitesourceExecuteScan.md b/documentation/docs/steps/whitesourceExecuteScan.md index 53c33e4f9..40889e75c 100644 --- a/documentation/docs/steps/whitesourceExecuteScan.md +++ b/documentation/docs/steps/whitesourceExecuteScan.md @@ -8,12 +8,12 @@ Your company has registered an account with WhiteSource and you have enabled the access to your organization in WhiteSource via dedicated privileges. Scanning your products without adequate user level access protection imposed on the WhiteSource backend would simply allow access based on the organization token. -## ${docDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} +## ${docDependencies} + ## Exceptions None From fcc470271c5759945cb733a82285a694c004cb44 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 24 May 2019 15:44:31 +0200 Subject: [PATCH 55/67] More speaking name in doc wrt jenkins plugin deps --- documentation/bin/createDocu.groovy | 2 +- documentation/docs/steps/artifactSetVersion.md | 2 +- documentation/docs/steps/batsExecuteTests.md | 2 +- documentation/docs/steps/checkChangeInDevelopment.md | 2 +- documentation/docs/steps/checksPublishResults.md | 2 +- documentation/docs/steps/cloudFoundryDeploy.md | 2 +- documentation/docs/steps/containerExecuteStructureTests.md | 2 +- documentation/docs/steps/detectExecuteScan.md | 2 +- documentation/docs/steps/dockerExecute.md | 2 +- documentation/docs/steps/dockerExecuteOnKubernetes.md | 2 +- documentation/docs/steps/durationMeasure.md | 2 +- documentation/docs/steps/gaugeExecuteTests.md | 2 +- documentation/docs/steps/githubPublishRelease.md | 2 +- documentation/docs/steps/handlePipelineStepErrors.md | 2 +- documentation/docs/steps/healthExecuteCheck.md | 2 +- documentation/docs/steps/influxWriteData.md | 2 +- documentation/docs/steps/kanikoExecute.md | 2 +- documentation/docs/steps/karmaExecuteTests.md | 2 +- documentation/docs/steps/mailSendNotification.md | 2 +- documentation/docs/steps/mavenExecute.md | 2 +- documentation/docs/steps/mtaBuild.md | 2 +- documentation/docs/steps/multicloudDeploy.md | 4 ++-- documentation/docs/steps/neoDeploy.md | 2 +- documentation/docs/steps/newmanExecute.md | 2 +- documentation/docs/steps/npmExecute.md | 4 ++-- documentation/docs/steps/pipelineExecute.md | 2 +- documentation/docs/steps/pipelineRestartSteps.md | 2 +- documentation/docs/steps/pipelineStashFiles.md | 2 +- documentation/docs/steps/pipelineStashFilesAfterBuild.md | 4 ++-- documentation/docs/steps/pipelineStashFilesBeforeBuild.md | 2 +- documentation/docs/steps/piperPipelineStagePost.md | 2 +- documentation/docs/steps/prepareDefaultValues.md | 2 +- documentation/docs/steps/seleniumExecuteTests.md | 2 +- documentation/docs/steps/setupCommonPipelineEnvironment.md | 2 +- documentation/docs/steps/slackSendNotification.md | 2 +- documentation/docs/steps/snykExecute.md | 2 +- documentation/docs/steps/sonarExecuteScan.md | 2 +- documentation/docs/steps/testsPublishResults.md | 2 +- documentation/docs/steps/transportRequestCreate.md | 2 +- documentation/docs/steps/transportRequestRelease.md | 2 +- documentation/docs/steps/transportRequestUploadFile.md | 2 +- documentation/docs/steps/uiVeri5ExecuteTests.md | 2 +- documentation/docs/steps/whitesourceExecuteScan.md | 2 +- 43 files changed, 46 insertions(+), 46 deletions(-) diff --git a/documentation/bin/createDocu.groovy b/documentation/bin/createDocu.groovy index b8560f8b8..16b66891a 100644 --- a/documentation/bin/createDocu.groovy +++ b/documentation/bin/createDocu.groovy @@ -572,7 +572,7 @@ void renderStep(stepName, stepProperties) { docGenDescription : 'Description\n\n' + stepProperties.description, docGenParameters : 'Parameters\n\n' + TemplateHelper.createParametersSection(stepProperties.parameters), docGenConfiguration : 'Step configuration\n\n' + TemplateHelper.createStepConfigurationSection(stepProperties.parameters), - docDependencies : 'Dependencies (beta)\n\n' + TemplateHelper.createDependencyList(stepProperties.dependencies) + docJenkinsPluginDependencies : 'Dependencies (beta)\n\n' + TemplateHelper.createDependencyList(stepProperties.dependencies) ] def template = new StreamingTemplateEngine().createTemplate(theStepDocu.text) diff --git a/documentation/docs/steps/artifactSetVersion.md b/documentation/docs/steps/artifactSetVersion.md index 0479c65e2..ec97349b7 100644 --- a/documentation/docs/steps/artifactSetVersion.md +++ b/documentation/docs/steps/artifactSetVersion.md @@ -10,7 +10,7 @@ none ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Example diff --git a/documentation/docs/steps/batsExecuteTests.md b/documentation/docs/steps/batsExecuteTests.md index 8bec79b32..39f5acfac 100644 --- a/documentation/docs/steps/batsExecuteTests.md +++ b/documentation/docs/steps/batsExecuteTests.md @@ -10,7 +10,7 @@ You need to have a Bats test file. By default you would put this into directory ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Example diff --git a/documentation/docs/steps/checkChangeInDevelopment.md b/documentation/docs/steps/checkChangeInDevelopment.md index ca72f691d..b79406a5b 100644 --- a/documentation/docs/steps/checkChangeInDevelopment.md +++ b/documentation/docs/steps/checkChangeInDevelopment.md @@ -10,7 +10,7 @@ ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Exceptions diff --git a/documentation/docs/steps/checksPublishResults.md b/documentation/docs/steps/checksPublishResults.md index 276759766..f2e4b8838 100644 --- a/documentation/docs/steps/checksPublishResults.md +++ b/documentation/docs/steps/checksPublishResults.md @@ -82,7 +82,7 @@ ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ### Thresholds diff --git a/documentation/docs/steps/cloudFoundryDeploy.md b/documentation/docs/steps/cloudFoundryDeploy.md index 1d19514c9..5318b37a0 100644 --- a/documentation/docs/steps/cloudFoundryDeploy.md +++ b/documentation/docs/steps/cloudFoundryDeploy.md @@ -13,7 +13,7 @@ ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Example diff --git a/documentation/docs/steps/containerExecuteStructureTests.md b/documentation/docs/steps/containerExecuteStructureTests.md index 338ece538..8cf4656c0 100644 --- a/documentation/docs/steps/containerExecuteStructureTests.md +++ b/documentation/docs/steps/containerExecuteStructureTests.md @@ -10,7 +10,7 @@ Test configuration is available. ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Example diff --git a/documentation/docs/steps/detectExecuteScan.md b/documentation/docs/steps/detectExecuteScan.md index 52553642b..aa371fac9 100644 --- a/documentation/docs/steps/detectExecuteScan.md +++ b/documentation/docs/steps/detectExecuteScan.md @@ -9,7 +9,7 @@ You need to store the API token for the Detect service as _'Secret text'_ creden !!! note "minimum plugin requirement" This step requires [synopsys-detect-plugin](https://github.com/jenkinsci/synopsys-detect-plugin) with at least version `2.0.0`. -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Example diff --git a/documentation/docs/steps/dockerExecute.md b/documentation/docs/steps/dockerExecute.md index 9e3d88f21..d0e3f46e0 100644 --- a/documentation/docs/steps/dockerExecute.md +++ b/documentation/docs/steps/dockerExecute.md @@ -10,7 +10,7 @@ If the Jenkins is setup on a Kubernetes cluster, then you can execute the closur ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Side effects diff --git a/documentation/docs/steps/dockerExecuteOnKubernetes.md b/documentation/docs/steps/dockerExecuteOnKubernetes.md index e1d7b443d..b64aaac16 100644 --- a/documentation/docs/steps/dockerExecuteOnKubernetes.md +++ b/documentation/docs/steps/dockerExecuteOnKubernetes.md @@ -13,7 +13,7 @@ ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Side effects diff --git a/documentation/docs/steps/durationMeasure.md b/documentation/docs/steps/durationMeasure.md index afae2f189..6427e01bd 100644 --- a/documentation/docs/steps/durationMeasure.md +++ b/documentation/docs/steps/durationMeasure.md @@ -6,7 +6,7 @@ ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Example diff --git a/documentation/docs/steps/gaugeExecuteTests.md b/documentation/docs/steps/gaugeExecuteTests.md index 2adef1920..162c283d7 100644 --- a/documentation/docs/steps/gaugeExecuteTests.md +++ b/documentation/docs/steps/gaugeExecuteTests.md @@ -12,7 +12,7 @@ none We recommend to define values of step parameters via [config.yml file](../configuration.md). -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Example diff --git a/documentation/docs/steps/githubPublishRelease.md b/documentation/docs/steps/githubPublishRelease.md index 0fe05cc8c..959e37981 100644 --- a/documentation/docs/steps/githubPublishRelease.md +++ b/documentation/docs/steps/githubPublishRelease.md @@ -6,7 +6,7 @@ You need to create a personal access token within GitHub and add this to the Jen Please see [GitHub documentation for details about creating the personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## ${docGenParameters} diff --git a/documentation/docs/steps/handlePipelineStepErrors.md b/documentation/docs/steps/handlePipelineStepErrors.md index 18f90fb37..84f4d6f3b 100644 --- a/documentation/docs/steps/handlePipelineStepErrors.md +++ b/documentation/docs/steps/handlePipelineStepErrors.md @@ -10,7 +10,7 @@ none ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Example diff --git a/documentation/docs/steps/healthExecuteCheck.md b/documentation/docs/steps/healthExecuteCheck.md index 9df27328d..896f02b43 100644 --- a/documentation/docs/steps/healthExecuteCheck.md +++ b/documentation/docs/steps/healthExecuteCheck.md @@ -16,7 +16,7 @@ Endpoint for health check is configured. ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Example diff --git a/documentation/docs/steps/influxWriteData.md b/documentation/docs/steps/influxWriteData.md index c5c74ff5c..c5a6af5ef 100644 --- a/documentation/docs/steps/influxWriteData.md +++ b/documentation/docs/steps/influxWriteData.md @@ -67,7 +67,7 @@ influxDBServer=jenkins ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Example diff --git a/documentation/docs/steps/kanikoExecute.md b/documentation/docs/steps/kanikoExecute.md index 7f48a7580..f098cb2ce 100644 --- a/documentation/docs/steps/kanikoExecute.md +++ b/documentation/docs/steps/kanikoExecute.md @@ -16,7 +16,7 @@ via _Jenkins_ -> _Credentials_ -> _System_ -> _Global credentials (unrestricted) * File: upload your `config.json` file * ID: specify id which you then use for the configuration of `dockerConfigJsonCredentialsId` (see below) -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Example diff --git a/documentation/docs/steps/karmaExecuteTests.md b/documentation/docs/steps/karmaExecuteTests.md index fc0e60ebc..e30764461 100644 --- a/documentation/docs/steps/karmaExecuteTests.md +++ b/documentation/docs/steps/karmaExecuteTests.md @@ -7,7 +7,7 @@ * **running Karma tests** - have a NPM module with running tests executed with Karma * **configured WebDriver** - have the [`karma-webdriver-launcher`](https://github.com/karma-runner/karma-webdriver-launcher) package installed and a custom, WebDriver-based browser configured in Karma -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## ${docGenParameters} diff --git a/documentation/docs/steps/mailSendNotification.md b/documentation/docs/steps/mailSendNotification.md index b5f2cac32..5405b5aca 100644 --- a/documentation/docs/steps/mailSendNotification.md +++ b/documentation/docs/steps/mailSendNotification.md @@ -18,7 +18,7 @@ mailSendNotification script: this ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Side effects diff --git a/documentation/docs/steps/mavenExecute.md b/documentation/docs/steps/mavenExecute.md index b87488475..ab8438cc1 100644 --- a/documentation/docs/steps/mavenExecute.md +++ b/documentation/docs/steps/mavenExecute.md @@ -6,7 +6,7 @@ ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Exceptions diff --git a/documentation/docs/steps/mtaBuild.md b/documentation/docs/steps/mtaBuild.md index 3c73d2ef3..54a4a0f95 100644 --- a/documentation/docs/steps/mtaBuild.md +++ b/documentation/docs/steps/mtaBuild.md @@ -14,7 +14,7 @@ While using a custom docker file, ensure that the following tools are installed: ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Side effects diff --git a/documentation/docs/steps/multicloudDeploy.md b/documentation/docs/steps/multicloudDeploy.md index 0f3f70c46..da75e47a6 100644 --- a/documentation/docs/steps/multicloudDeploy.md +++ b/documentation/docs/steps/multicloudDeploy.md @@ -1,12 +1,12 @@ # ${docGenStepName} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## ${docGenParameters} ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Examples diff --git a/documentation/docs/steps/neoDeploy.md b/documentation/docs/steps/neoDeploy.md index 836aa9571..70f8a4cb6 100644 --- a/documentation/docs/steps/neoDeploy.md +++ b/documentation/docs/steps/neoDeploy.md @@ -18,7 +18,7 @@ ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Side effects diff --git a/documentation/docs/steps/newmanExecute.md b/documentation/docs/steps/newmanExecute.md index 67dd65a0c..e744d5df4 100644 --- a/documentation/docs/steps/newmanExecute.md +++ b/documentation/docs/steps/newmanExecute.md @@ -14,7 +14,7 @@ Step uses `dockerExecute` inside. -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Exceptions diff --git a/documentation/docs/steps/npmExecute.md b/documentation/docs/steps/npmExecute.md index b9f0856e6..fb17c70ee 100644 --- a/documentation/docs/steps/npmExecute.md +++ b/documentation/docs/steps/npmExecute.md @@ -1,13 +1,13 @@ # ${docGenStepName} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## ${docGenParameters} ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Exceptions diff --git a/documentation/docs/steps/pipelineExecute.md b/documentation/docs/steps/pipelineExecute.md index 580584ded..68d474ea9 100644 --- a/documentation/docs/steps/pipelineExecute.md +++ b/documentation/docs/steps/pipelineExecute.md @@ -10,7 +10,7 @@ none ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Side effects diff --git a/documentation/docs/steps/pipelineRestartSteps.md b/documentation/docs/steps/pipelineRestartSteps.md index fe31237b0..dbe8b5749 100644 --- a/documentation/docs/steps/pipelineRestartSteps.md +++ b/documentation/docs/steps/pipelineRestartSteps.md @@ -31,7 +31,7 @@ pipelineRestartSteps (script: this) { none -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Exceptions diff --git a/documentation/docs/steps/pipelineStashFiles.md b/documentation/docs/steps/pipelineStashFiles.md index 70a17d02a..1c2a690e5 100644 --- a/documentation/docs/steps/pipelineStashFiles.md +++ b/documentation/docs/steps/pipelineStashFiles.md @@ -34,7 +34,7 @@ The step is stashing files before and after the build. This is due to the fact, ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Explanation of pipeline step diff --git a/documentation/docs/steps/pipelineStashFilesAfterBuild.md b/documentation/docs/steps/pipelineStashFilesAfterBuild.md index 251204aed..114ac9d0e 100644 --- a/documentation/docs/steps/pipelineStashFilesAfterBuild.md +++ b/documentation/docs/steps/pipelineStashFilesAfterBuild.md @@ -4,11 +4,11 @@ none -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## ${docGenParameters} ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} diff --git a/documentation/docs/steps/pipelineStashFilesBeforeBuild.md b/documentation/docs/steps/pipelineStashFilesBeforeBuild.md index 09b294d8a..c6cf93df4 100644 --- a/documentation/docs/steps/pipelineStashFilesBeforeBuild.md +++ b/documentation/docs/steps/pipelineStashFilesBeforeBuild.md @@ -10,5 +10,5 @@ none ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} diff --git a/documentation/docs/steps/piperPipelineStagePost.md b/documentation/docs/steps/piperPipelineStagePost.md index 4b8162443..3d8f3171a 100644 --- a/documentation/docs/steps/piperPipelineStagePost.md +++ b/documentation/docs/steps/piperPipelineStagePost.md @@ -6,4 +6,4 @@ ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} diff --git a/documentation/docs/steps/prepareDefaultValues.md b/documentation/docs/steps/prepareDefaultValues.md index 8b4c76258..552c96065 100644 --- a/documentation/docs/steps/prepareDefaultValues.md +++ b/documentation/docs/steps/prepareDefaultValues.md @@ -10,7 +10,7 @@ None -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Example diff --git a/documentation/docs/steps/seleniumExecuteTests.md b/documentation/docs/steps/seleniumExecuteTests.md index 21539026c..b6070d962 100644 --- a/documentation/docs/steps/seleniumExecuteTests.md +++ b/documentation/docs/steps/seleniumExecuteTests.md @@ -68,7 +68,7 @@ webdriverio ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Side effects diff --git a/documentation/docs/steps/setupCommonPipelineEnvironment.md b/documentation/docs/steps/setupCommonPipelineEnvironment.md index 4c437659c..aa32b3216 100644 --- a/documentation/docs/steps/setupCommonPipelineEnvironment.md +++ b/documentation/docs/steps/setupCommonPipelineEnvironment.md @@ -10,7 +10,7 @@ ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Side effects diff --git a/documentation/docs/steps/slackSendNotification.md b/documentation/docs/steps/slackSendNotification.md index 40c851382..6aaa5ec2d 100644 --- a/documentation/docs/steps/slackSendNotification.md +++ b/documentation/docs/steps/slackSendNotification.md @@ -12,7 +12,7 @@ ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Example diff --git a/documentation/docs/steps/snykExecute.md b/documentation/docs/steps/snykExecute.md index 2bd1e1994..239fda8ac 100644 --- a/documentation/docs/steps/snykExecute.md +++ b/documentation/docs/steps/snykExecute.md @@ -11,7 +11,7 @@ ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Side effects diff --git a/documentation/docs/steps/sonarExecuteScan.md b/documentation/docs/steps/sonarExecuteScan.md index 22f064225..968f2a6be 100644 --- a/documentation/docs/steps/sonarExecuteScan.md +++ b/documentation/docs/steps/sonarExecuteScan.md @@ -11,7 +11,7 @@ ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Exceptions diff --git a/documentation/docs/steps/testsPublishResults.md b/documentation/docs/steps/testsPublishResults.md index 54b6c5f5c..a614a5ac4 100644 --- a/documentation/docs/steps/testsPublishResults.md +++ b/documentation/docs/steps/testsPublishResults.md @@ -79,7 +79,7 @@ testsPublishResults( ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Side effects diff --git a/documentation/docs/steps/transportRequestCreate.md b/documentation/docs/steps/transportRequestCreate.md index ec72d5c80..bcd69d0b1 100644 --- a/documentation/docs/steps/transportRequestCreate.md +++ b/documentation/docs/steps/transportRequestCreate.md @@ -11,7 +11,7 @@ ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} The step is configured using a customer configuration file provided as resource in an custom shared library. diff --git a/documentation/docs/steps/transportRequestRelease.md b/documentation/docs/steps/transportRequestRelease.md index 7434c6979..d38b95b0f 100644 --- a/documentation/docs/steps/transportRequestRelease.md +++ b/documentation/docs/steps/transportRequestRelease.md @@ -10,7 +10,7 @@ ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} The step is configured using a customer configuration file provided as resource in an custom shared library. diff --git a/documentation/docs/steps/transportRequestUploadFile.md b/documentation/docs/steps/transportRequestUploadFile.md index 331444d09..63b9ac7cb 100644 --- a/documentation/docs/steps/transportRequestUploadFile.md +++ b/documentation/docs/steps/transportRequestUploadFile.md @@ -10,7 +10,7 @@ ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} The step is configured using a customer configuration file provided as resource in an custom shared library. diff --git a/documentation/docs/steps/uiVeri5ExecuteTests.md b/documentation/docs/steps/uiVeri5ExecuteTests.md index 2f27d4621..24942174e 100644 --- a/documentation/docs/steps/uiVeri5ExecuteTests.md +++ b/documentation/docs/steps/uiVeri5ExecuteTests.md @@ -8,7 +8,7 @@ ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Exceptions diff --git a/documentation/docs/steps/whitesourceExecuteScan.md b/documentation/docs/steps/whitesourceExecuteScan.md index 40889e75c..6255c72dc 100644 --- a/documentation/docs/steps/whitesourceExecuteScan.md +++ b/documentation/docs/steps/whitesourceExecuteScan.md @@ -12,7 +12,7 @@ access protection imposed on the WhiteSource backend would simply allow access b ## ${docGenConfiguration} -## ${docDependencies} +## ${docJenkinsPluginDependencies} ## Exceptions From bcc2c34a87d4435260db53afd95cff2022bfe8c9 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 24 May 2019 15:50:30 +0200 Subject: [PATCH 56/67] No 'beta' anymore --- documentation/bin/createDocu.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/bin/createDocu.groovy b/documentation/bin/createDocu.groovy index 16b66891a..a0eb91376 100644 --- a/documentation/bin/createDocu.groovy +++ b/documentation/bin/createDocu.groovy @@ -39,7 +39,7 @@ class TemplateHelper { t += "\nThe kubernetes plugin is only used if running in a kubernetes environment." } - t += '\nTransitive dependencies are omitted.\n\nThis is a beta feature. The list might be incomplete.' + t += '\nTransitive dependencies are omitted.\n\nThe list might be incomplete.' return t } @@ -572,7 +572,7 @@ void renderStep(stepName, stepProperties) { docGenDescription : 'Description\n\n' + stepProperties.description, docGenParameters : 'Parameters\n\n' + TemplateHelper.createParametersSection(stepProperties.parameters), docGenConfiguration : 'Step configuration\n\n' + TemplateHelper.createStepConfigurationSection(stepProperties.parameters), - docJenkinsPluginDependencies : 'Dependencies (beta)\n\n' + TemplateHelper.createDependencyList(stepProperties.dependencies) + docJenkinsPluginDependencies : 'Dependencies\n\n' + TemplateHelper.createDependencyList(stepProperties.dependencies) ] def template = new StreamingTemplateEngine().createTemplate(theStepDocu.text) From 0c2ccb26b410723f6c8339c3bc2a04648f9949c6 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 24 May 2019 16:12:20 +0200 Subject: [PATCH 57/67] Advertize jenkins-master image --- documentation/bin/createDocu.groovy | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/documentation/bin/createDocu.groovy b/documentation/bin/createDocu.groovy index a0eb91376..9c3020f2a 100644 --- a/documentation/bin/createDocu.groovy +++ b/documentation/bin/createDocu.groovy @@ -39,7 +39,14 @@ class TemplateHelper { t += "\nThe kubernetes plugin is only used if running in a kubernetes environment." } - t += '\nTransitive dependencies are omitted.\n\nThe list might be incomplete.' + t += '''| + |Transitive dependencies are omitted. + | + |The list might be incomplete. + | + |Consider using the [ppiper/jenkins-master](https://cloud.docker.com/u/ppiper/repository/docker/ppiper/jenkins-master) + |docker image. This images comes with preinstalled plugins. + |'''.stripMargin() return t } From c66a02ca68b29081f57b63b9241372e6ccc99ea1 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 24 May 2019 16:18:45 +0200 Subject: [PATCH 58/67] Fix code climate issues --- documentation/docs/steps/multicloudDeploy.md | 2 -- documentation/docs/steps/npmExecute.md | 2 -- documentation/docs/steps/pipelineStashFilesAfterBuild.md | 3 --- documentation/docs/steps/pipelineStashFilesBeforeBuild.md | 1 - 4 files changed, 8 deletions(-) diff --git a/documentation/docs/steps/multicloudDeploy.md b/documentation/docs/steps/multicloudDeploy.md index da75e47a6..de34c67a7 100644 --- a/documentation/docs/steps/multicloudDeploy.md +++ b/documentation/docs/steps/multicloudDeploy.md @@ -1,7 +1,5 @@ # ${docGenStepName} -## ${docJenkinsPluginDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/npmExecute.md b/documentation/docs/steps/npmExecute.md index fb17c70ee..5438766a8 100644 --- a/documentation/docs/steps/npmExecute.md +++ b/documentation/docs/steps/npmExecute.md @@ -1,8 +1,6 @@ # ${docGenStepName} -## ${docJenkinsPluginDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/documentation/docs/steps/pipelineStashFilesAfterBuild.md b/documentation/docs/steps/pipelineStashFilesAfterBuild.md index 114ac9d0e..e0f50882c 100644 --- a/documentation/docs/steps/pipelineStashFilesAfterBuild.md +++ b/documentation/docs/steps/pipelineStashFilesAfterBuild.md @@ -4,11 +4,8 @@ none -## ${docJenkinsPluginDependencies} - ## ${docGenParameters} ## ${docGenConfiguration} ## ${docJenkinsPluginDependencies} - diff --git a/documentation/docs/steps/pipelineStashFilesBeforeBuild.md b/documentation/docs/steps/pipelineStashFilesBeforeBuild.md index c6cf93df4..8df1a02b1 100644 --- a/documentation/docs/steps/pipelineStashFilesBeforeBuild.md +++ b/documentation/docs/steps/pipelineStashFilesBeforeBuild.md @@ -11,4 +11,3 @@ none ## ${docGenConfiguration} ## ${docJenkinsPluginDependencies} - From 6d95b031ce7d37f59547d2002c4c009498f82da4 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 24 May 2019 16:40:31 +0200 Subject: [PATCH 59/67] Review feedback --- documentation/bin/createDocu.groovy | 13 ++++++------- documentation/bin/resolveTransitiveCalls.groovy | 10 ++++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/documentation/bin/createDocu.groovy b/documentation/bin/createDocu.groovy index 5c21c48f8..756e5dad0 100644 --- a/documentation/bin/createDocu.groovy +++ b/documentation/bin/createDocu.groovy @@ -900,17 +900,16 @@ def handleStep(stepName, prepareDefaultValuesStep, gse, customDefaults) { // 'dependentConfig' is only present here for internal reasons and that entry is removed at // end of method. def step = [ - parameters:[:], - dependencies: (Set)[], - dependentConfig: [:] - ] + parameters:[:], + dependencies: (Set)[], + dependentConfig: [:] + ] // // provide dependencies to Jenkins plugins if(theStepDeps.exists()) { - def deps = new JsonSlurper().parse(theStepDeps) - step.dependencies.addAll(deps[stepName].collect { k, v -> k }) - def _deps = deps[stepName].collect { k, v -> k } + def pluginDependencies = new JsonSlurper().parse(theStepDeps) + step.dependencies.addAll(pluginDependencies[stepName].collect { k, v -> k }) } // diff --git a/documentation/bin/resolveTransitiveCalls.groovy b/documentation/bin/resolveTransitiveCalls.groovy index 57875e53b..22de61d21 100644 --- a/documentation/bin/resolveTransitiveCalls.groovy +++ b/documentation/bin/resolveTransitiveCalls.groovy @@ -35,15 +35,17 @@ def steps = new JsonSlurper().parseText(new File(options.i).text) def piperSteps = steps.piperSteps def calls = steps.calls -def _calls = [:] +// only temporary in order to avoid manipulating the map during +// iterating over it. +def tmpCalls = [:] // Adjust naming calls.each { c -> - _calls.put(retrieveStepName(c.key), c.value as Set) + tmpCalls.put(retrieveStepName(c.key), c.value as Set) } -calls = _calls -_calls = null +calls = tmpCalls +tmpCalls = null // Remove selfs calls.each { c -> From 309f79d5b725e934245afd00ccff13683d50fb56 Mon Sep 17 00:00:00 2001 From: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com> Date: Wed, 29 May 2019 12:40:56 +0200 Subject: [PATCH 60/67] bump version (#735) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 295691205..8d748f05c 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ 4.0.0 com.sap.cp.jenkins jenkins-library - 0.10 + 0.11 SAP CP Piper Library Shared library containing steps and utilities to set up continuous deployment processes for SAP technologies. From f171f88b13707df1ada68c5d86ff2d7a64ba92fc Mon Sep 17 00:00:00 2001 From: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com> Date: Wed, 29 May 2019 13:22:16 +0200 Subject: [PATCH 61/67] whiteSourceExecuteScan - allow passing projects via cpe (#734) --- .../CommonPipelineEnvironmentTest.groovy | 37 ++++++++++++++++ test/groovy/WhitesourceExecuteScanTest.groovy | 44 +++++++++++++++++++ vars/whitesourceExecuteScan.groovy | 9 ++++ 3 files changed, 90 insertions(+) create mode 100644 test/groovy/CommonPipelineEnvironmentTest.groovy diff --git a/test/groovy/CommonPipelineEnvironmentTest.groovy b/test/groovy/CommonPipelineEnvironmentTest.groovy new file mode 100644 index 000000000..93811289d --- /dev/null +++ b/test/groovy/CommonPipelineEnvironmentTest.groovy @@ -0,0 +1,37 @@ +import org.junit.Rule +import org.junit.Test +import org.junit.rules.RuleChain +import util.BasePiperTest +import util.JenkinsReadYamlRule +import util.Rules + +import static org.hamcrest.CoreMatchers.is +import static org.hamcrest.Matchers.hasItem +import static org.junit.Assert.assertThat + +class CommonPipelineEnvironmentTest extends BasePiperTest { + + @Rule + public RuleChain rules = Rules + .getCommonRules(this) + .around(new JenkinsReadYamlRule(this) + ) + + @Test + void testCustomValueList() { + nullScript.commonPipelineEnvironment.setValue('myList', []) + nullScript.commonPipelineEnvironment.getValue('myList').add('item1') + nullScript.commonPipelineEnvironment.getValue('myList').add('item2') + assertThat(nullScript.commonPipelineEnvironment.getValue('myList'), hasItem('item1')) + assertThat(nullScript.commonPipelineEnvironment.getValue('myList'), hasItem('item2')) + } + + @Test + void testCustomValueMap() { + nullScript.commonPipelineEnvironment.setValue('myList', [:]) + nullScript.commonPipelineEnvironment.getValue('myList').key1 = 'val1' + nullScript.commonPipelineEnvironment.getValue('myList').key2 = 'val2' + assertThat(nullScript.commonPipelineEnvironment.getValue('myList').key1, is('val1')) + assertThat(nullScript.commonPipelineEnvironment.getValue('myList').key2, is('val2')) + } +} diff --git a/test/groovy/WhitesourceExecuteScanTest.groovy b/test/groovy/WhitesourceExecuteScanTest.groovy index da933d4d2..1aa3bc5c5 100644 --- a/test/groovy/WhitesourceExecuteScanTest.groovy +++ b/test/groovy/WhitesourceExecuteScanTest.groovy @@ -746,6 +746,50 @@ class WhitesourceExecuteScanTest extends BasePiperTest { } @Test + void testPassProjectNamesToCPE() { + helper.registerAllowedMethod("findFiles", [Map.class], { map -> + if (map.glob == "**${File.separator}pom.xml") { + return [new File('maven1/pom.xml'), new File('maven2/pom.xml')].toArray() + } + if (map.glob == "**${File.separator}package.json") { + return [new File('npm1/package.json'), new File('npm2/package.json'), new File('npm3/package.json'), new File('npm4/package.json')].toArray() + } + return [].toArray() + }) + + helper.registerAllowedMethod("parallel", [Map.class], { map -> + map.each {m -> + if (m.key != 'failFast') { + m.value() + } + } + }) + + helper.registerAllowedMethod("readProperties", [Map], { + def result = new Properties() + return result + }) + + //need to use call due to mock above + stepRule.step.call([ + script : nullScript, + descriptorUtilsStub : descriptorUtilsStub, + whitesourceRepositoryStub : whitesourceStub, + whitesourceOrgAdminRepositoryStub: whitesourceOrgAdminRepositoryStub, + scanType : 'mta', + productName : 'SHC - Piper', + buildDescriptorExcludeList : ["maven2${File.separator}pom.xml".toString()], + juStabUtils : utils, + orgToken : 'b39d1328-52e2-42e3-98f0-932709daf3f0' + ]) + + assertThat(nullScript.commonPipelineEnvironment.getValue('whitesourceProjectNames'), hasItem('com.sap.maven.test-java - 1')) + assertThat(nullScript.commonPipelineEnvironment.getValue('whitesourceProjectNames'), hasItem('com.sap.node.test-node - 1')) + + + } + + @Test void testNPMStatusCheckScanException() { thrown.expect(AbortException.class) stepRule.step.checkStatus(-1 & 0xFF, [whitesource:[licensingVulnerabilities: true]]) diff --git a/vars/whitesourceExecuteScan.groovy b/vars/whitesourceExecuteScan.groovy index 26f5e97aa..8f2e36884 100644 --- a/vars/whitesourceExecuteScan.groovy +++ b/vars/whitesourceExecuteScan.groovy @@ -227,6 +227,11 @@ void call(Map parameters = [:]) { def descriptorUtils = parameters.descriptorUtilsStub ?: new DescriptorUtils() def statusCode = 1 + //initialize CPE for passing whiteSourceProjects + if(script.commonPipelineEnvironment.getValue('whitesourceProjectNames') == null) { + script.commonPipelineEnvironment.setValue('whitesourceProjectNames', []) + } + // load default & individual configuration Map config = ConfigurationHelper.newInstance(this) .loadStepDefaults(CONFIG_KEY_COMPATIBILITY) @@ -358,6 +363,10 @@ private def triggerWhitesourceScanWithUserKey(script, config, utils, descriptorU if(!config.whitesource['projectNames'].contains(projectName)) config.whitesource['projectNames'].add(projectName) + //share projectNames with other steps + if(!script.commonPipelineEnvironment.getValue('whitesourceProjectNames').contains(projectName)) + script.commonPipelineEnvironment.getValue('whitesourceProjectNames').add(projectName) + WhitesourceConfigurationHelper.extendUAConfigurationFile(script, utils, config, path) dockerExecute(script: script, dockerImage: config.dockerImage, dockerWorkspace: config.dockerWorkspace, stashContent: config.stashContent) { if (config.whitesource.agentDownloadUrl) { From 111080cbfe855eabb0625c9c8acbde99686cb5ce Mon Sep 17 00:00:00 2001 From: Sven Merk <33895725+nevskrem@users.noreply.github.com> Date: Tue, 4 Jun 2019 08:01:43 +0200 Subject: [PATCH 62/67] Add new step for Dockerfile linting (#723) * Add new step for Dockerfile linting * Add documentation template file * Remove newlines * Remove internal URL * Rephrase comment * Ammend stash * Fix test * move dockerImage to general * use explicit curl options * small changes * small changes * skip GIT blame * First comments * Also add remark to URL parameter * Second set of comments * Fix return code handling * Switch type to set * Revert unrelated changes * Avoid modification of config * add quality gate defaults * Update hadolintExecute.groovy * fix code climate issue --- documentation/docs/steps/hadolintExecute.md | 17 ++++ resources/default_pipeline_environment.yml | 15 ++- test/groovy/HadolintExecuteTest.groovy | 67 +++++++++++++ vars/hadolintExecute.groovy | 104 ++++++++++++++++++++ 4 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 documentation/docs/steps/hadolintExecute.md create mode 100644 test/groovy/HadolintExecuteTest.groovy create mode 100644 vars/hadolintExecute.groovy diff --git a/documentation/docs/steps/hadolintExecute.md b/documentation/docs/steps/hadolintExecute.md new file mode 100644 index 000000000..eb062cddb --- /dev/null +++ b/documentation/docs/steps/hadolintExecute.md @@ -0,0 +1,17 @@ +# ${docGenStepName} + +## ${docGenDescription} + +## ${docGenParameters} + +## ${docGenConfiguration} + +## Exceptions + +None + +## Examples + +```groovy +hadolintExecute script: this +``` diff --git a/resources/default_pipeline_environment.yml b/resources/default_pipeline_environment.yml index 32e782382..6a128649f 100644 --- a/resources/default_pipeline_environment.yml +++ b/resources/default_pipeline_environment.yml @@ -251,6 +251,19 @@ steps: languageRunner: 'ruby' runCommand: 'bundle install && bundle exec gauge run' testOptions: 'specs' + hadolintExecute: + configurationFile: '.hadolint.yaml' + configurationUrl: '' + dockerFile: './Dockerfile' + dockerImage: 'hadolint/hadolint:latest-debian' + qualityGates: + - threshold: 1 + type: 'TOTAL_ERROR' + unstable: false + reportFile: 'hadolint.xml' + reportName: 'HaDoLint' + stashContent: + - 'buildDescriptor' handlePipelineStepErrors: echoDetails: true failOnError: true @@ -408,7 +421,7 @@ steps: noDefaultExludes: [] pipelineStashFilesBeforeBuild: stashIncludes: - buildDescriptor: '**/pom.xml, **/.mvn/**, **/assembly.xml, **/.swagger-codegen-ignore, **/package.json, **/requirements.txt, **/setup.py, **/mta*.y*ml, **/.npmrc, Dockerfile, **/VERSION, **/version.txt, **/Gopkg.*, **/build.sbt, **/sbtDescriptor.json, **/project/*' + buildDescriptor: '**/pom.xml, **/.mvn/**, **/assembly.xml, **/.swagger-codegen-ignore, **/package.json, **/requirements.txt, **/setup.py, **/mta*.y*ml, **/.npmrc, Dockerfile, .hadolint.yaml, **/VERSION, **/version.txt, **/Gopkg.*, **/build.sbt, **/sbtDescriptor.json, **/project/*' deployDescriptor: '**/manifest*.y*ml, **/*.mtaext.y*ml, **/*.mtaext, **/xs-app.json, helm/**, *.y*ml' git: '.git/**' opa5: '**/*.*' diff --git a/test/groovy/HadolintExecuteTest.groovy b/test/groovy/HadolintExecuteTest.groovy new file mode 100644 index 000000000..852ee28a6 --- /dev/null +++ b/test/groovy/HadolintExecuteTest.groovy @@ -0,0 +1,67 @@ +import hudson.AbortException + +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.rules.ExpectedException +import org.junit.rules.RuleChain +import util.BasePiperTest +import util.JenkinsDockerExecuteRule +import util.JenkinsLoggingRule +import util.JenkinsReadYamlRule +import util.JenkinsShellCallRule +import util.JenkinsStepRule +import util.Rules + +import static org.junit.Assert.assertThat +import static org.hamcrest.Matchers.* + +class HadolintExecuteTest extends BasePiperTest { + + private ExpectedException thrown = new ExpectedException().none() + private JenkinsShellCallRule shellRule = new JenkinsShellCallRule(this) + private JenkinsDockerExecuteRule dockerExecuteRule = new JenkinsDockerExecuteRule(this) + private JenkinsStepRule stepRule = new JenkinsStepRule(this) + private JenkinsReadYamlRule yamlRule = new JenkinsReadYamlRule(this) + private JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this) + + @Rule + public RuleChain ruleChain = Rules + .getCommonRules(this) + .around(thrown) + .around(yamlRule) + .around(dockerExecuteRule) + .around(shellRule) + .around(stepRule) + .around(loggingRule) + + @Before + void init() { + helper.registerAllowedMethod 'stash', [String, String], { name, includes -> assertThat(name, is('hadolintConfiguration')); assertThat(includes, is('.hadolint.yaml')) } + helper.registerAllowedMethod 'fileExists', [String], { s -> s == './Dockerfile' } + helper.registerAllowedMethod 'checkStyle', [Map], { m -> assertThat(m.pattern, is('hadolint.xml')); return 'checkstyle' } + helper.registerAllowedMethod 'recordIssues', [Map], { m -> assertThat(m.tools, hasItem('checkstyle')) } + helper.registerAllowedMethod 'archiveArtifacts', [String], { String p -> assertThat('hadolint.xml', is(p)) } + } + + @Test + void testHadolintExecute() { + stepRule.step.hadolintExecute(script: nullScript, juStabUtils: utils, dockerImage: 'hadolint/hadolint:latest-debian', configurationUrl: 'https://github.wdf.sap.corp/raw/SGS/Hadolint-Dockerfile/master/.hadolint.yaml') + assertThat(dockerExecuteRule.dockerParams.dockerImage, is('hadolint/hadolint:latest-debian')) + assertThat(loggingRule.log, containsString("Unstash content: buildDescriptor")) + assertThat(shellRule.shell, + hasItems( + "curl --fail --location --output .hadolint.yaml https://github.wdf.sap.corp/raw/SGS/Hadolint-Dockerfile/master/.hadolint.yaml", + "hadolint ./Dockerfile --config .hadolint.yaml --format checkstyle > hadolint.xml" + ) + ) + } + + @Test + void testNoDockerfile() { + helper.registerAllowedMethod 'fileExists', [String], { false } + thrown.expect AbortException + thrown.expectMessage '[hadolintExecute] Dockerfile \'./Dockerfile\' is not found.' + stepRule.step.hadolintExecute(script: nullScript, juStabUtils: utils, dockerImage: 'hadolint/hadolint:latest-debian') + } +} diff --git a/vars/hadolintExecute.groovy b/vars/hadolintExecute.groovy new file mode 100644 index 000000000..33201e393 --- /dev/null +++ b/vars/hadolintExecute.groovy @@ -0,0 +1,104 @@ +import static com.sap.piper.Prerequisites.checkScript +import com.sap.piper.GenerateDocumentation +import com.sap.piper.ConfigurationHelper +import com.sap.piper.Utils +import groovy.transform.Field + +@Field def STEP_NAME = getClass().getName() +@Field Set GENERAL_CONFIG_KEYS = [ + /** + * Dockerfile to be used for the assessment. + */ + 'dockerFile', + /** + * Name of the docker image that should be used, in which node should be installed and configured. Default value is 'hadolint/hadolint:latest-debian'. + */ + 'dockerImage' +] +@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus([ + /** + * Name of the configuration file used locally within the step. If a file with this name is detected as part of your repo downloading the central configuration via `configurationUrl` will be skipped. If you change the file's name make sure your stashing configuration also reflects this. + */ + 'configurationFile', + /** + * URL pointing to the .hadolint.yaml exclude configuration to be used for linting. Also have a look at `configurationFile` which could avoid central configuration download in case the file is part of your repository. + */ + 'configurationUrl', + /** + * Docker options to be set when starting the container. + */ + 'dockerOptions', + /** + * Quality Gates to fail the build, see [warnings-ng plugin documentation](https://github.com/jenkinsci/warnings-plugin/blob/master/doc/Documentation.md#quality-gate-configuration). + */ + 'qualityGates', + /** + * Name of the result file used locally within the step. + */ + 'reportFile' +]) +@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS +/** + * Executes the Haskell Dockerfile Linter which is a smarter Dockerfile linter that helps you build [best practice](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/) Docker images. + * The linter is parsing the Dockerfile into an abstract syntax tree (AST) and performs rules on top of the AST. + */ +@GenerateDocumentation +void call(Map parameters = [:]) { + handlePipelineStepErrors(stepName: STEP_NAME, stepParameters: parameters) { + final script = checkScript(this, parameters) ?: this + final utils = parameters.juStabUtils ?: new Utils() + + // load default & individual configuration + Map configuration = ConfigurationHelper.newInstance(this) + .loadStepDefaults() + .mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS) + .mixinStepConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS) + .mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, STEP_CONFIG_KEYS) + .mixin(parameters, PARAMETER_KEYS) + .use() + + new Utils().pushToSWA([ + step: STEP_NAME, + stepParamKey1: 'scriptMissing', + stepParam1: parameters?.script == null + ], configuration) + + def existingStashes = utils.unstashAll(configuration.stashContent) + + if (!fileExists(configuration.dockerFile)) { + error "[${STEP_NAME}] Dockerfile '${configuration.dockerFile}' is not found." + } + + if(!fileExists(configuration.configurationFile) && configuration.configurationUrl) { + sh "curl --fail --location --output ${configuration.configurationFile} ${configuration.configurationUrl}" + if(existingStashes) { + def stashName = 'hadolintConfiguration' + stash name: stashName, includes: configuration.configurationFile + existingStashes += stashName + } + } + + def options = [ + "--config ${configuration.configurationFile}", + "--format checkstyle > ${configuration.reportFile}" + ] + + dockerExecute( + script: script, + dockerImage: configuration.dockerImage, + dockerOptions: configuration.dockerOptions, + stashContent: existingStashes + ) { + // HaDoLint status code is ignore, results will be handled by recordIssues / archiveArtifacts + def ignore = sh returnStatus: true, script: "hadolint ${configuration.dockerFile} ${options.join(' ')}" + + archiveArtifacts configuration.reportFile + recordIssues( + tools: [checkStyle(name: configuration.reportName, pattern: configuration.reportFile)], + qualityGates: configuration.qualityGates, + enabledForFailure: true, + blameDisabled: true + ) + } + } +} From 0f12bc8000daa12bee8f6280aa1d3d82f6c0db7f Mon Sep 17 00:00:00 2001 From: Sven Merk <33895725+nevskrem@users.noreply.github.com> Date: Tue, 4 Jun 2019 12:00:22 +0200 Subject: [PATCH 63/67] Add missing compatibility for productVersion --- vars/whitesourceExecuteScan.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/vars/whitesourceExecuteScan.groovy b/vars/whitesourceExecuteScan.groovy index 8f2e36884..7fc9f3780 100644 --- a/vars/whitesourceExecuteScan.groovy +++ b/vars/whitesourceExecuteScan.groovy @@ -175,6 +175,7 @@ import static com.sap.piper.Prerequisites.checkScript productName : 'productName', productToken : 'productToken', projectNames : 'projectNames', + productVersion : 'productVersion', serviceUrl : 'serviceUrl', configFilePath : 'configFilePath', userTokenCredentialsId : 'userTokenCredentialsId', From 121b23fdaae52173a55d1e0d8cfff72bf93d47b4 Mon Sep 17 00:00:00 2001 From: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com> Date: Wed, 5 Jun 2019 11:24:32 +0200 Subject: [PATCH 64/67] dockerExecuteOnKubernetes - stash also .git folder (#739) Make sure that complete workspace is available in Kubernetes Pod. So far e.g. git repository information were missing. --- .../groovy/DockerExecuteOnKubernetesTest.groovy | 17 +++++++++++++++++ vars/dockerExecuteOnKubernetes.groovy | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/test/groovy/DockerExecuteOnKubernetesTest.groovy b/test/groovy/DockerExecuteOnKubernetesTest.groovy index aa49ea395..43beef76c 100644 --- a/test/groovy/DockerExecuteOnKubernetesTest.groovy +++ b/test/groovy/DockerExecuteOnKubernetesTest.groovy @@ -368,6 +368,23 @@ class DockerExecuteOnKubernetesTest extends BasePiperTest { assertThat(securityContext, is(equalTo(expectedSecurityContext))) } + @Test + void testDockerExecuteOnKubernetesWorkspaceStashing() { + + Map stashMap + helper.registerAllowedMethod('stash', [Map.class], {m -> + stashMap = m + }) + + stepRule.step.dockerExecuteOnKubernetes( + script: nullScript, + juStabUtils: utils, + dockerImage: 'maven:3.5-jdk-8-alpine', + ) { bodyExecuted = true } + assertTrue(bodyExecuted) + assertThat(stashMap.useDefaultExcludes, is(false)) + } + private container(options, body) { containerName = options.name diff --git a/vars/dockerExecuteOnKubernetes.groovy b/vars/dockerExecuteOnKubernetes.groovy index cbc1cd699..c25d16799 100644 --- a/vars/dockerExecuteOnKubernetes.groovy +++ b/vars/dockerExecuteOnKubernetes.groovy @@ -225,7 +225,8 @@ chown -R ${runAsUser}:${fsGroup} .""" stash( name: stashName, includes: config.stashIncludes.workspace, - excludes: config.stashExcludes.workspace + excludes: config.stashExcludes.workspace, + useDefaultExcludes: false ) return stashName } catch (AbortException | IOException e) { From 09086518e3be483f2cfe248666694f9a5d4c4ae7 Mon Sep 17 00:00:00 2001 From: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com> Date: Wed, 5 Jun 2019 14:00:04 +0200 Subject: [PATCH 65/67] fix tests for dockerExecuteOnKubernetes (#741) depending on the execution order tests may fail. This solves this issue --- test/groovy/DockerExecuteOnKubernetesTest.groovy | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/groovy/DockerExecuteOnKubernetesTest.groovy b/test/groovy/DockerExecuteOnKubernetesTest.groovy index 43beef76c..42af5a4e7 100644 --- a/test/groovy/DockerExecuteOnKubernetesTest.groovy +++ b/test/groovy/DockerExecuteOnKubernetesTest.groovy @@ -57,6 +57,7 @@ class DockerExecuteOnKubernetesTest extends BasePiperTest { def pullImageMap = [:] def namespace def securityContext + Map stashMap @Before void init() { @@ -92,6 +93,10 @@ class DockerExecuteOnKubernetesTest extends BasePiperTest { } body() }) + helper.registerAllowedMethod('stash', [Map.class], {m -> + stashMap = m + }) + } @Test @@ -371,11 +376,6 @@ class DockerExecuteOnKubernetesTest extends BasePiperTest { @Test void testDockerExecuteOnKubernetesWorkspaceStashing() { - Map stashMap - helper.registerAllowedMethod('stash', [Map.class], {m -> - stashMap = m - }) - stepRule.step.dockerExecuteOnKubernetes( script: nullScript, juStabUtils: utils, From a6e11e7fd3b9e41f8fcfe0d2e7d12a9005585161 Mon Sep 17 00:00:00 2001 From: Christopher Fenner Date: Thu, 6 Jun 2019 13:52:20 +0200 Subject: [PATCH 66/67] add HaDoLint to docs (#744) --- documentation/mkdocs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation/mkdocs.yml b/documentation/mkdocs.yml index 241174973..05ff18cc7 100644 --- a/documentation/mkdocs.yml +++ b/documentation/mkdocs.yml @@ -16,6 +16,7 @@ nav: - durationMeasure: steps/durationMeasure.md - gaugeExecuteTests: steps/gaugeExecuteTests.md - githubPublishRelease: steps/githubPublishRelease.md + - hadolintExecute: steps/hadolintExecute.md - handlePipelineStepErrors: steps/handlePipelineStepErrors.md - healthExecuteCheck: steps/healthExecuteCheck.md - influxWriteData: steps/influxWriteData.md From e7cbf02b8e322b1529b3498eaa5a56367307f286 Mon Sep 17 00:00:00 2001 From: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com> Date: Thu, 6 Jun 2019 17:22:25 +0200 Subject: [PATCH 67/67] dockerExecuteOnKubernetes - revert #739 (#745) stashing .git directory had negative side-effects. Solution would be to stash `.git` folder and unstash in `dockerExecuteOnKubernetes` only if required for a dedicated scenario. --- test/groovy/DockerExecuteOnKubernetesTest.groovy | 3 +++ vars/dockerExecuteOnKubernetes.groovy | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/test/groovy/DockerExecuteOnKubernetesTest.groovy b/test/groovy/DockerExecuteOnKubernetesTest.groovy index 42af5a4e7..07276e028 100644 --- a/test/groovy/DockerExecuteOnKubernetesTest.groovy +++ b/test/groovy/DockerExecuteOnKubernetesTest.groovy @@ -373,6 +373,8 @@ class DockerExecuteOnKubernetesTest extends BasePiperTest { assertThat(securityContext, is(equalTo(expectedSecurityContext))) } + /* + Due to negative side-effect of full git stashing @Test void testDockerExecuteOnKubernetesWorkspaceStashing() { @@ -384,6 +386,7 @@ class DockerExecuteOnKubernetesTest extends BasePiperTest { assertTrue(bodyExecuted) assertThat(stashMap.useDefaultExcludes, is(false)) } + */ private container(options, body) { diff --git a/vars/dockerExecuteOnKubernetes.groovy b/vars/dockerExecuteOnKubernetes.groovy index c25d16799..897446482 100644 --- a/vars/dockerExecuteOnKubernetes.groovy +++ b/vars/dockerExecuteOnKubernetes.groovy @@ -226,7 +226,8 @@ chown -R ${runAsUser}:${fsGroup} .""" name: stashName, includes: config.stashIncludes.workspace, excludes: config.stashExcludes.workspace, - useDefaultExcludes: false + //inactive due to negative side-effects, we may require a dedicated git stash to be used + //useDefaultExcludes: false ) return stashName } catch (AbortException | IOException e) {