mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
Merge pull request #305 from marcusholl/pr/scriptAsMandatoryParameter
Ensure script is mandatory parameter
This commit is contained in:
commit
1835f4d7bd
@ -21,7 +21,7 @@ none
|
||||
|
||||
| parameter | mandatory | default | possible values |
|
||||
| ----------|-----------|---------|-----------------|
|
||||
| script | no | empty `commonPipelineEnvironment` | |
|
||||
| script | yes | | |
|
||||
| artifactType | no | | 'appContainer' |
|
||||
| buildTool | no | maven | docker, dlang, golang, maven, mta, npm, pip, sbt |
|
||||
| commitVersion | no | `true` | `true`, `false` |
|
||||
|
@ -12,7 +12,7 @@ You need to have a Bats test file. By default you would put this into directory
|
||||
|
||||
| parameter | mandatory | default | possible values |
|
||||
|-----------|-----------|---------|-----------------|
|
||||
| script | no | empty `globalPipelineEnvironment` | |
|
||||
| script | yes | | |
|
||||
| dockerImage | no | `node:8-stretch` | |
|
||||
| dockerWorkspace | no |`/home/node`| |
|
||||
| envVars | no | `[:]` | |
|
||||
|
@ -16,6 +16,7 @@ This step can publish static check results from various sources.
|
||||
## Parameters
|
||||
| parameter | mandatory | default | possible values |
|
||||
| ---------------|-----------|-----------------------------------|--------------------|
|
||||
| script | yes | | |
|
||||
| aggregation | no | `true` | see below |
|
||||
| tasks | no | `false` | see below |
|
||||
| pmd | no | `false` | see below |
|
||||
|
@ -26,7 +26,7 @@ Deployment can be done
|
||||
|
||||
| parameter | mandatory | default | possible values |
|
||||
| ----------|-----------|---------|-----------------|
|
||||
| script | no | empty `commonPipelineEnvironment` | |
|
||||
| script | yes | | |
|
||||
| cloudFoundry | yes | | |
|
||||
| deployTool | no | cf_native | cf_native, mtaDeployPlugin |
|
||||
| deployType | no | standard | standard, blue-green |
|
||||
|
@ -18,7 +18,7 @@ none
|
||||
|
||||
| parameter | mandatory | default | possible values |
|
||||
| ----------|-----------|---------|-----------------|
|
||||
| script | no | empty `globalPipelineEnvironment` | |
|
||||
| script | yes | | |
|
||||
| measurementName | no | test_duration | |
|
||||
|
||||
Details:
|
||||
|
@ -84,7 +84,7 @@ influxDBServer=jenkins
|
||||
|
||||
| parameter | mandatory | default | possible values |
|
||||
| ----------|-----------|---------|-----------------|
|
||||
| script | no | empty `commonPipelineEnvironment` | |
|
||||
| script | yes | | |
|
||||
| artifactVersion | yes | commonPipelineEnvironment.getArtifactVersion() | |
|
||||
| influxServer | no | `jenkins` | |
|
||||
| influxPrefix | no | `null` | |
|
||||
|
@ -8,6 +8,7 @@ Executes a maven command inside a Docker container.
|
||||
|
||||
| parameter | mandatory | default | example values |
|
||||
| -------------------------------|-----------|-------------------|----------------------------|
|
||||
| `script` | yes | | |
|
||||
| `dockerImage` | no | 'maven:3.5-jdk-7' | |
|
||||
| `globalSettingsFile` | no | | 'local_folder/settings.xml'|
|
||||
| `projectSettingsFile` | no | | |
|
||||
@ -18,6 +19,10 @@ Executes a maven command inside a Docker container.
|
||||
| `defines` | no | | '-Dmaven.tests.skip=true' |
|
||||
| `logSuccessfulMavenTransfers` | no | `false` | 'true' |
|
||||
|
||||
* `script` defines the global script environment of the Jenkinsfile run.
|
||||
Typically `this` is passed to this parameter. This allows the function
|
||||
to access the commonPipelineEnvironment for retrieving, for example,
|
||||
configuration parameters.
|
||||
* `dockerImage` Name of the docker image that should be used.
|
||||
* `globalSettingsFile` Path or url to the mvn settings file that should be used as global settings file.
|
||||
* `projectSettingsFile` Path or url to the mvn settings file that should be used as project settings file.
|
||||
|
@ -10,7 +10,7 @@ none
|
||||
|
||||
| parameter | mandatory | default | possible values |
|
||||
| ----------|-----------|---------|-----------------|
|
||||
| script | no | empty `commonPipelineEnvironment` | |
|
||||
| script | yes | | |
|
||||
| runCheckmarx | no | false | |
|
||||
| runOpaTests | no | false | |
|
||||
| stashIncludes | no | see details | |
|
||||
|
@ -31,11 +31,17 @@ Available parameters:
|
||||
|
||||
| parameter | mandatory | default | possible values |
|
||||
| ----------|-----------|---------|-----------------|
|
||||
| script | yes | | |
|
||||
| junit | no | `false` | true, false |
|
||||
| jacoco | no | `false` | true, false |
|
||||
| cobertura | no | `false` | true, false |
|
||||
| jmeter | no | `false` | true, false |
|
||||
|
||||
* `script` - The common script environment of the Jenkinsfile running.
|
||||
Typically the reference to the script calling the pipeline step is provided
|
||||
with the `this` parameter, as in `script: this`.
|
||||
This allows the function to access the [`commonPipelineEnvironment`](commonPipelineEnvironment.md)
|
||||
for retrieving, for example, configuration parameters.
|
||||
* `junit` - Publishes test results files in JUnit format with the [JUnit Plugin](https://plugins.jenkins.io/junit).
|
||||
* `jacoco` - Publishes code coverage with the [JaCoCo plugin](https://plugins.jenkins.io/jacoco) .
|
||||
* `cobertura` - Publishes code coverage with the [Cobertura plugin](https://plugins.jenkins.io/cobertura).
|
||||
|
22
src/com/sap/piper/Prerequisites.groovy
Normal file
22
src/com/sap/piper/Prerequisites.groovy
Normal file
@ -0,0 +1,22 @@
|
||||
package com.sap.piper
|
||||
|
||||
import static java.lang.Boolean.getBoolean
|
||||
|
||||
static checkScript(def step, Map params) {
|
||||
|
||||
def script = params?.script
|
||||
|
||||
if(script == null) {
|
||||
|
||||
if(getBoolean('com.sap.piper.featureFlag.failOnMissingScript')) {
|
||||
step.error("[ERROR][${step.STEP_NAME}] No reference to surrounding script provided with key 'script', e.g. 'script: this'.")
|
||||
}
|
||||
|
||||
step.currentBuild.setResult('UNSTABLE')
|
||||
|
||||
step.echo "[WARNING][${step.STEP_NAME}] No reference to surrounding script provided with key 'script', e.g. 'script: this'. " +
|
||||
"Build status has been set to 'UNSTABLE'. In future versions of piper-lib the build will fail."
|
||||
}
|
||||
|
||||
return script
|
||||
}
|
@ -8,6 +8,7 @@ import org.junit.rules.RuleChain
|
||||
|
||||
import com.sap.piper.GitUtils
|
||||
|
||||
import hudson.AbortException
|
||||
import util.BasePiperTest
|
||||
import util.JenkinsDockerExecuteRule
|
||||
import util.JenkinsEnvironmentRule
|
||||
@ -109,14 +110,6 @@ class ArtifactSetVersionTest extends BasePiperTest {
|
||||
assertThat(jscr.shell, not(hasItem(containsString('commit'))))
|
||||
}
|
||||
|
||||
@Test
|
||||
void testVersioningWithoutScript() {
|
||||
jsr.step.artifactSetVersion(juStabGitUtils: gitUtils, buildTool: 'maven', commitVersion: false)
|
||||
|
||||
assertEquals('1.2.3-20180101010203_testCommitId', jer.env.getArtifactVersion())
|
||||
assertThat(jscr.shell, hasItem("mvn --file 'pom.xml' --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn versions:set -DnewVersion=1.2.3-20180101010203_testCommitId -DgenerateBackupPoms=false"))
|
||||
}
|
||||
|
||||
@Test
|
||||
void testVersioningCustomGitUserAndEMail() {
|
||||
jsr.step.artifactSetVersion(script: jsr.step, juStabGitUtils: gitUtils, buildTool: 'maven', gitSshUrl: 'myGitSshUrl', gitUserEMail: 'test@test.com', gitUserName: 'test')
|
||||
|
@ -45,11 +45,11 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
|
||||
ChangeManagement cm = getChangeManagementUtils(true)
|
||||
jsr.step.checkChangeInDevelopment(
|
||||
script: nullScript,
|
||||
cmUtils: cm,
|
||||
changeManagement: [
|
||||
type: 'SOLMAN',
|
||||
endpoint: 'https://example.org/cm'],
|
||||
failIfStatusIsNotInDevelopment: true)
|
||||
cmUtils: cm,
|
||||
changeManagement: [
|
||||
type: 'SOLMAN',
|
||||
endpoint: 'https://example.org/cm'],
|
||||
failIfStatusIsNotInDevelopment: true)
|
||||
|
||||
assert cmUtilReceivedParams == [
|
||||
changeId: '001',
|
||||
@ -80,7 +80,7 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
|
||||
|
||||
ChangeManagement cm = getChangeManagementUtils(false)
|
||||
boolean inDevelopment = jsr.step.checkChangeInDevelopment(
|
||||
script: nullScript,
|
||||
script: nullScript,
|
||||
cmUtils: cm,
|
||||
changeManagement: [endpoint: 'https://example.org/cm'],
|
||||
failIfStatusIsNotInDevelopment: false)
|
||||
|
@ -43,7 +43,7 @@ class ChecksPublishResultsTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void testPublishWithDefaultSettings() throws Exception {
|
||||
jsr.step.call()
|
||||
jsr.step.call(script: nullScript)
|
||||
|
||||
assertTrue("AnalysisPublisher options not set", publisherStepOptions['AnalysisPublisher'] != null)
|
||||
// ensure nothing else is published
|
||||
@ -56,7 +56,7 @@ class ChecksPublishResultsTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void testPublishForJavaWithDefaultSettings() throws Exception {
|
||||
jsr.step.call(pmd: true, cpd: true, findbugs: true, checkstyle: true)
|
||||
jsr.step.call(script: nullScript, pmd: true, cpd: true, findbugs: true, checkstyle: true)
|
||||
|
||||
assertTrue("AnalysisPublisher options not set", publisherStepOptions['AnalysisPublisher'] != null)
|
||||
assertTrue("PmdPublisher options not set", publisherStepOptions['PmdPublisher'] != null)
|
||||
@ -74,7 +74,7 @@ class ChecksPublishResultsTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void testPublishForJavaScriptWithDefaultSettings() throws Exception {
|
||||
jsr.step.call(eslint: true)
|
||||
jsr.step.call(script: nullScript, eslint: true)
|
||||
|
||||
assertTrue("AnalysisPublisher options not set", publisherStepOptions['AnalysisPublisher'] != null)
|
||||
assertTrue("WarningsPublisher options not set", publisherStepOptions['WarningsPublisher'] != null)
|
||||
@ -92,7 +92,7 @@ class ChecksPublishResultsTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void testPublishForPythonWithDefaultSettings() throws Exception {
|
||||
jsr.step.call(pylint: true)
|
||||
jsr.step.call(script: nullScript, pylint: true)
|
||||
|
||||
assertTrue("AnalysisPublisher options not set", publisherStepOptions['AnalysisPublisher'] != null)
|
||||
assertTrue("WarningsPublisher options not set", publisherStepOptions['WarningsPublisher'] != null)
|
||||
@ -111,7 +111,7 @@ class ChecksPublishResultsTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void testPublishNothing() throws Exception {
|
||||
jsr.step.call(aggregation: false)
|
||||
jsr.step.call(script: nullScript, aggregation: false)
|
||||
|
||||
// ensure nothing is published
|
||||
assertTrue("AnalysisPublisher options not empty", publisherStepOptions['AnalysisPublisher'] == null)
|
||||
@ -124,7 +124,7 @@ class ChecksPublishResultsTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void testPublishNothingExplicitFalse() throws Exception {
|
||||
jsr.step.call(pmd: false)
|
||||
jsr.step.call(script: nullScript, pmd: false)
|
||||
|
||||
assertTrue("AnalysisPublisher options not set", publisherStepOptions['AnalysisPublisher'] != null)
|
||||
// ensure nothing else is published
|
||||
@ -137,7 +137,7 @@ class ChecksPublishResultsTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void testPublishNothingImplicitTrue() throws Exception {
|
||||
jsr.step.call(pmd: [:])
|
||||
jsr.step.call(script: nullScript, pmd: [:])
|
||||
|
||||
// ensure pmd is not published
|
||||
assertTrue("PmdPublisher options not set", publisherStepOptions['PmdPublisher'] != null)
|
||||
@ -145,7 +145,7 @@ class ChecksPublishResultsTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void testPublishNothingExplicitActiveFalse() throws Exception {
|
||||
jsr.step.call(pmd: [active: false])
|
||||
jsr.step.call(script: nullScript, pmd: [active: false])
|
||||
|
||||
// ensure pmd is not published
|
||||
assertTrue("PmdPublisher options not empty", publisherStepOptions['PmdPublisher'] == null)
|
||||
@ -169,7 +169,7 @@ class ChecksPublishResultsTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void testPublishWithCustomPattern() throws Exception {
|
||||
jsr.step.call(eslint: [pattern: 'my-fancy-file.ext'], pmd: [pattern: 'this-is-not-a-patter.xml'])
|
||||
jsr.step.call(script: nullScript, eslint: [pattern: 'my-fancy-file.ext'], pmd: [pattern: 'this-is-not-a-patter.xml'])
|
||||
|
||||
assertTrue("AnalysisPublisher options not set", publisherStepOptions['AnalysisPublisher'] != null)
|
||||
assertTrue("PmdPublisher options not set", publisherStepOptions['PmdPublisher'] != null)
|
||||
@ -186,7 +186,7 @@ class ChecksPublishResultsTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void testPublishWithArchive() throws Exception {
|
||||
jsr.step.call(archive: true, eslint: true, pmd: true, cpd: true, findbugs: true, checkstyle: true)
|
||||
jsr.step.call(script: nullScript, archive: true, eslint: true, pmd: true, cpd: true, findbugs: true, checkstyle: true)
|
||||
|
||||
assertTrue("ArchivePatterns number not correct", archiveStepPatterns.size() == 5)
|
||||
assertTrue("ArchivePatterns contains no PMD pattern", archiveStepPatterns.contains('**/target/pmd.xml'))
|
||||
@ -198,7 +198,7 @@ class ChecksPublishResultsTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void testPublishWithPartialArchive() throws Exception {
|
||||
jsr.step.call(archive: true, eslint: [archive: false], pmd: true, cpd: true, findbugs: true, checkstyle: true)
|
||||
jsr.step.call(script: nullScript, archive: true, eslint: [archive: false], pmd: true, cpd: true, findbugs: true, checkstyle: true)
|
||||
|
||||
assertTrue("ArchivePatterns number not correct", archiveStepPatterns.size() == 4)
|
||||
assertTrue("ArchivePatterns contains no PMD pattern", archiveStepPatterns.contains('**/target/pmd.xml'))
|
||||
@ -211,7 +211,7 @@ class ChecksPublishResultsTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void testPublishWithDefaultThresholds() throws Exception {
|
||||
jsr.step.call(pmd: true)
|
||||
jsr.step.call(script: nullScript, pmd: true)
|
||||
|
||||
assertTrue("AnalysisPublisher options not set",
|
||||
publisherStepOptions['AnalysisPublisher'] != null)
|
||||
@ -245,7 +245,7 @@ class ChecksPublishResultsTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void testPublishWithThresholds() throws Exception {
|
||||
jsr.step.call(aggregation: [thresholds: [fail: [high: '10']]], pmd: true)
|
||||
jsr.step.call(script: nullScript, aggregation: [thresholds: [fail: [high: '10']]], pmd: true)
|
||||
|
||||
assertTrue("AnalysisPublisher options not set", publisherStepOptions['AnalysisPublisher'] != null)
|
||||
assertTrue("PmdPublisher options not set", publisherStepOptions['PmdPublisher'] != null)
|
||||
|
@ -1,20 +1,26 @@
|
||||
import static java.util.stream.Collectors.toList
|
||||
import static org.hamcrest.Matchers.empty
|
||||
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 java.lang.reflect.Field
|
||||
import java.io.File;
|
||||
import java.util.stream.Collectors
|
||||
import java.lang.reflect.Field
|
||||
|
||||
import org.codehaus.groovy.runtime.metaclass.MethodSelectionException
|
||||
import org.hamcrest.Matchers
|
||||
import org.junit.Assert
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.rules.RuleChain
|
||||
|
||||
import groovy.io.FileType
|
||||
import hudson.AbortException
|
||||
import util.BasePiperTest
|
||||
|
||||
import util.JenkinsStepRule
|
||||
import util.Rules
|
||||
|
||||
/*
|
||||
@ -25,6 +31,74 @@ public class CommonStepsTest extends BasePiperTest{
|
||||
@Rule
|
||||
public RuleChain ruleChain = Rules.getCommonRules(this)
|
||||
|
||||
/*
|
||||
* With that test we ensure the very first action inside a method body of a call method
|
||||
* for a not white listed step is the check for the script handed over properly.
|
||||
* Actually we assert for the exception type (AbortException) and for the exception message.
|
||||
* In case a new step is added this step will fail. It is the duty of the author of the
|
||||
* step to either follow the pattern of checking the script first or to add the step
|
||||
* to the white list.
|
||||
*/
|
||||
@Test
|
||||
public void scriptReferenceNotHandedOverTest() {
|
||||
|
||||
// all steps not adopting the usual pattern of working with the script.
|
||||
def whitelistScriptReference = [
|
||||
'commonPipelineEnvironment',
|
||||
'handlePipelineStepErrors',
|
||||
'pipelineExecute',
|
||||
'prepareDefaultValues',
|
||||
'setupCommonPipelineEnvironment',
|
||||
'toolValidate',
|
||||
]
|
||||
|
||||
List steps = getSteps().stream()
|
||||
.filter {! whitelistScriptReference.contains(it)}
|
||||
.forEach {checkReference(it)}
|
||||
}
|
||||
|
||||
private void checkReference(step) {
|
||||
|
||||
try {
|
||||
def script = loadScript("${step}.groovy")
|
||||
|
||||
try {
|
||||
|
||||
System.setProperty('com.sap.piper.featureFlag.failOnMissingScript', 'true')
|
||||
|
||||
try {
|
||||
script.call([:])
|
||||
} catch(AbortException | MissingMethodException e) {
|
||||
throw e
|
||||
} catch(Exception e) {
|
||||
fail "Unexpected exception ${e.getClass().getName()} caught from step '${step}': ${e.getMessage()}"
|
||||
}
|
||||
fail("Expected AbortException not raised by step '${step}'")
|
||||
|
||||
} catch(MissingMethodException e) {
|
||||
|
||||
// can be improved: exception handling as some kind of control flow.
|
||||
// we can also check for the methods and call the appropriate one.
|
||||
|
||||
try {
|
||||
script.call([:]) {}
|
||||
} catch(AbortException e1) {
|
||||
throw e1
|
||||
} catch(Exception e1) {
|
||||
fail "Unexpected exception ${e1.getClass().getName()} caught from step '${step}': ${e1.getMessage()}"
|
||||
}
|
||||
fail("Expected AbortException not raised by step '${step}'")
|
||||
}
|
||||
|
||||
} catch(AbortException e) {
|
||||
assertThat("Step ''${step} does not fail with expected error message in case mandatory parameter 'script' is not provided.",
|
||||
e.getMessage() ==~ /.*\[ERROR\]\[.*\] No reference to surrounding script provided with key 'script', e.g. 'script: this'./,
|
||||
is(equalTo(true)))
|
||||
} finally {
|
||||
System.clearProperty('com.sap.piper.featureFlag.failOnMissingScript')
|
||||
}
|
||||
}
|
||||
|
||||
private static fieldRelatedWhitelist = [
|
||||
'toolValidate', // step is intended to be configured by other steps
|
||||
'durationMeasure', // only expects parameters via signature
|
||||
@ -130,6 +204,7 @@ public class CommonStepsTest extends BasePiperTest{
|
||||
assertThat("Steps with wrong step name or without STEP_NAME field.: ${stepsWithWrongStepName}",
|
||||
stepsWithWrongStepName, is(empty()))
|
||||
}
|
||||
|
||||
/*
|
||||
* With that test we ensure that all return types of the call methods of all the steps
|
||||
* are void. Return types other than void are not possible when running inside declarative
|
||||
@ -165,6 +240,5 @@ public class CommonStepsTest extends BasePiperTest{
|
||||
new File('vars').traverse(type: FileType.FILES, maxDepth: 0)
|
||||
{ if(it.getName().endsWith('.groovy')) steps << (it =~ /vars\/(.*)\.groovy/)[0][1] }
|
||||
return steps
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class MtaBuildTest extends BasePiperTest {
|
||||
@Test
|
||||
void environmentPathTest() {
|
||||
|
||||
jsr.step.call(buildTarget: 'NEO')
|
||||
jsr.step.call(script: nullScript, buildTarget: 'NEO')
|
||||
|
||||
assert jscr.shell.find { c -> c.contains('PATH=./node_modules/.bin:/usr/bin')}
|
||||
}
|
||||
@ -59,7 +59,7 @@ public class MtaBuildTest extends BasePiperTest {
|
||||
@Test
|
||||
void sedTest() {
|
||||
|
||||
jsr.step.call(buildTarget: 'NEO')
|
||||
jsr.step.call(script: nullScript, buildTarget: 'NEO')
|
||||
|
||||
assert jscr.shell.find { c -> c =~ /sed -ie "s\/\\\$\{timestamp\}\/`date \+%Y%m%d%H%M%S`\/g" "mta.yaml"$/}
|
||||
}
|
||||
@ -79,7 +79,7 @@ public class MtaBuildTest extends BasePiperTest {
|
||||
@Test
|
||||
void mtaJarLocationAsParameterTest() {
|
||||
|
||||
jsr.step.call(mtaJarLocation: '/mylocation/mta/mta.jar', buildTarget: 'NEO')
|
||||
jsr.step.call(script: nullScript, mtaJarLocation: '/mylocation/mta/mta.jar', buildTarget: 'NEO')
|
||||
|
||||
assert jscr.shell.find { c -> c.contains('-jar /mylocation/mta/mta.jar --mtar')}
|
||||
|
||||
@ -94,7 +94,7 @@ public class MtaBuildTest extends BasePiperTest {
|
||||
jryr.registerYaml('mta.yaml', { throw new FileNotFoundException() })
|
||||
thrown.expect(FileNotFoundException)
|
||||
|
||||
jsr.step.call(buildTarget: 'NEO')
|
||||
jsr.step.call(script: nullScript, buildTarget: 'NEO')
|
||||
}
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ public class MtaBuildTest extends BasePiperTest {
|
||||
|
||||
jryr.registerYaml('mta.yaml', badMtaYaml())
|
||||
|
||||
jsr.step.call(buildTarget: 'NEO')
|
||||
jsr.step.call(script: nullScript, buildTarget: 'NEO')
|
||||
}
|
||||
|
||||
|
||||
@ -118,7 +118,7 @@ public class MtaBuildTest extends BasePiperTest {
|
||||
|
||||
jryr.registerYaml('mta.yaml', noIdMtaYaml() )
|
||||
|
||||
jsr.step.call(buildTarget: 'NEO')
|
||||
jsr.step.call(script: nullScript, buildTarget: 'NEO')
|
||||
}
|
||||
|
||||
|
||||
@ -127,7 +127,7 @@ public class MtaBuildTest extends BasePiperTest {
|
||||
|
||||
helper.registerAllowedMethod('sh', [Map], { Map m -> getVersionWithEnvVars(m) })
|
||||
|
||||
jsr.step.call(buildTarget: 'NEO')
|
||||
jsr.step.call(script: nullScript, buildTarget: 'NEO')
|
||||
|
||||
assert jscr.shell.find { c -> c.contains("-jar /env/mta/mta.jar --mtar")}
|
||||
assert jlr.log.contains("SAP Multitarget Application Archive Builder file '/env/mta/mta.jar' retrieved from environment.")
|
||||
@ -164,7 +164,7 @@ public class MtaBuildTest extends BasePiperTest {
|
||||
@Test
|
||||
void buildTargetFromParametersTest() {
|
||||
|
||||
jsr.step.call(buildTarget: 'NEO')
|
||||
jsr.step.call(script: nullScript, buildTarget: 'NEO')
|
||||
|
||||
assert jscr.shell.find { c -> c.contains('java -jar mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO build')}
|
||||
}
|
||||
@ -210,7 +210,7 @@ public class MtaBuildTest extends BasePiperTest {
|
||||
@Test
|
||||
void extensionFromParametersTest() {
|
||||
|
||||
jsr.step.call(buildTarget: 'NEO', extension: 'param_extension')
|
||||
jsr.step.call(script: nullScript, buildTarget: 'NEO', extension: 'param_extension')
|
||||
|
||||
assert jscr.shell.find { c -> c.contains('java -jar mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO --extension=param_extension build')}
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ public class TransportRequestCreateTest extends BasePiperTest {
|
||||
|
||||
jlr.expect('[INFO] Change management integration intentionally switched off.')
|
||||
|
||||
jsr.step.call(
|
||||
jsr.step.call(script: nullScript,
|
||||
changeManagement: [type: 'NONE'])
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ public class TransportRequestReleaseTest extends BasePiperTest {
|
||||
|
||||
jlr.expect('[INFO] Change management integration intentionally switched off.')
|
||||
|
||||
jsr.step.call(
|
||||
jsr.step.call(script: nullScript,
|
||||
changeManagement: [type: 'NONE'])
|
||||
}
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
|
||||
jlr.expect('[INFO] Change management integration intentionally switched off.')
|
||||
|
||||
jsr.step.call(
|
||||
jsr.step.call(script: nullScript,
|
||||
changeManagement: [type: 'NONE'])
|
||||
}
|
||||
|
||||
|
71
test/groovy/com/sap/piper/PrerequisitesTest.groovy
Normal file
71
test/groovy/com/sap/piper/PrerequisitesTest.groovy
Normal file
@ -0,0 +1,71 @@
|
||||
package com.sap.piper
|
||||
|
||||
import util.JenkinsLoggingRule
|
||||
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.rules.RuleChain
|
||||
|
||||
import hudson.AbortException
|
||||
import util.BasePiperTest
|
||||
import util.Rules
|
||||
|
||||
class PrerequisitesTest extends BasePiperTest {
|
||||
|
||||
def result = 'SUCCESS'
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none()
|
||||
|
||||
public JenkinsLoggingRule jlr = new JenkinsLoggingRule(this)
|
||||
|
||||
@Rule
|
||||
public RuleChain ruleChain = Rules.getCommonRules(this)
|
||||
.around(jlr)
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
nullScript.currentBuild = [
|
||||
'setResult' : { r -> result = r },
|
||||
STEP_NAME: 'dummy',
|
||||
]
|
||||
nullScript.STEP_NAME = 'dummy'
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkScriptProvidedTest() {
|
||||
|
||||
def script = Prerequisites.checkScript(nullScript, [script:{}])
|
||||
|
||||
assert script != null
|
||||
assert result == 'SUCCESS'
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkScriptMissingTest() {
|
||||
|
||||
jlr.expect('No reference to surrounding script provided with key \'script\'')
|
||||
|
||||
def script = Prerequisites.checkScript(nullScript, [:])
|
||||
|
||||
assert script == null
|
||||
assert result == 'UNSTABLE'
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkScriptMissingTestFeatureFlagSet() {
|
||||
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage('No reference to surrounding script provided')
|
||||
|
||||
try {
|
||||
System.setProperty('com.sap.piper.featureFlag.failOnMissingScript', 'true')
|
||||
Prerequisites.checkScript(nullScript, [:])
|
||||
} finally {
|
||||
System.clearProperty('com.sap.piper.featureFlag.failOnMissingScript')
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.GitUtils
|
||||
import com.sap.piper.Utils
|
||||
@ -33,17 +35,16 @@ void call(Map parameters = [:], Closure body = null) {
|
||||
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
|
||||
def script = checkScript(this, parameters)
|
||||
|
||||
def gitUtils = parameters.juStabGitUtils ?: new GitUtils()
|
||||
|
||||
if (gitUtils.insideWorkTree()) {
|
||||
if (sh(returnStatus: true, script: 'git diff --quiet HEAD') != 0)
|
||||
error "[${STEP_NAME}] Files in the workspace have been changed previously - aborting ${STEP_NAME}"
|
||||
}
|
||||
|
||||
def script = parameters.script
|
||||
if (script == null)
|
||||
script = this
|
||||
|
||||
// load default & individual configuration
|
||||
ConfigurationHelper configHelper = ConfigurationHelper.newInstance(this)
|
||||
.loadStepDefaults()
|
||||
@ -61,7 +62,7 @@ void call(Map parameters = [:], Closure body = null) {
|
||||
config = configHelper.addIfEmpty('timestamp', getTimestamp(config.timestampTemplate))
|
||||
.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME, stepParam1: config.buildTool, stepParam2: config.artifactType], config)
|
||||
new Utils().pushToSWA([step: STEP_NAME, stepParam1: config.buildTool, stepParam2: config.artifactType, stepParam3: parameters?.script == null], config)
|
||||
|
||||
def artifactVersioning = ArtifactVersioning.getArtifactVersioning(config.buildTool, script, config)
|
||||
def currentVersion = artifactVersioning.getVersion()
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.GitUtils
|
||||
import com.sap.piper.Utils
|
||||
@ -29,7 +31,8 @@ void call(Map parameters = [:]) {
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
|
||||
def utils = parameters.juStabUtils ?: new Utils()
|
||||
def script = parameters.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
|
||||
Map config = ConfigurationHelper.newInstance(this)
|
||||
.loadStepDefaults()
|
||||
@ -40,7 +43,8 @@ void call(Map parameters = [:]) {
|
||||
.use()
|
||||
|
||||
// report to SWA
|
||||
utils.pushToSWA([step: STEP_NAME], config)
|
||||
utils.pushToSWA([step: STEP_NAME,
|
||||
stepParam1: parameters?.script == null], config)
|
||||
|
||||
script.commonPipelineEnvironment.setInfluxStepData('bats', false)
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.GitUtils
|
||||
import com.sap.piper.Utils
|
||||
import groovy.transform.Field
|
||||
@ -38,7 +40,7 @@ void call(parameters = [:]) {
|
||||
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
|
||||
def script = parameters.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
|
||||
GitUtils gitUtils = parameters?.gitUtils ?: new GitUtils()
|
||||
|
||||
@ -56,8 +58,6 @@ void call(parameters = [:]) {
|
||||
BackendType backendType = getBackendTypeAndLogInfoIfCMIntegrationDisabled(this, configuration)
|
||||
if(backendType == BackendType.NONE) return
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
|
||||
configHelper
|
||||
// for the following parameters we expect defaults
|
||||
/**
|
||||
@ -94,6 +94,11 @@ void call(parameters = [:]) {
|
||||
.withMandatoryProperty('changeManagement/endpoint')
|
||||
|
||||
|
||||
configuration = configHelper.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME,
|
||||
stepParam1: parameters?.script == null], configuration)
|
||||
|
||||
def changeId = configuration.changeDocumentId
|
||||
|
||||
if(changeId?.trim()) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.cloudbees.groovy.cps.NonCPS
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
@ -23,9 +25,10 @@ import groovy.transform.Field
|
||||
*/
|
||||
void call(Map parameters = [:]) {
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
def script = parameters.script
|
||||
|
||||
def script = checkScript(this, parameters)
|
||||
if (script == null)
|
||||
script = [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
script = this
|
||||
|
||||
prepare(parameters)
|
||||
|
||||
@ -38,7 +41,8 @@ void call(Map parameters = [:]) {
|
||||
.mixin(parameters, PARAMETER_KEYS)
|
||||
.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
new Utils().pushToSWA([step: STEP_NAME,
|
||||
stepParam1: parameters?.script == null], configuration)
|
||||
|
||||
// JAVA
|
||||
report('PmdPublisher', configuration.pmd, configuration.archive)
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.Utils
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.CfManifestUtils
|
||||
@ -34,9 +36,9 @@ void call(Map parameters = [:]) {
|
||||
utils = new Utils()
|
||||
}
|
||||
|
||||
def script = parameters.script
|
||||
def script = checkScript(this, parameters)
|
||||
if (script == null)
|
||||
script = [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
script = this
|
||||
|
||||
Map config = ConfigurationHelper.newInstance(this)
|
||||
.loadStepDefaults()
|
||||
@ -51,7 +53,7 @@ void call(Map parameters = [:]) {
|
||||
.withMandatoryProperty('cloudFoundry/credentialsId')
|
||||
.use()
|
||||
|
||||
utils.pushToSWA([step: STEP_NAME, stepParam1: config.deployTool, stepParam2: config.deployType], config)
|
||||
utils.pushToSWA([step: STEP_NAME, stepParam1: config.deployTool, stepParam2: config.deployType, stepParam3: parameters?.script == null], config)
|
||||
|
||||
echo "[${STEP_NAME}] General parameters: deployTool=${config.deployTool}, deployType=${config.deployType}, cfApiEndpoint=${config.cloudFoundry.apiEndpoint}, cfOrg=${config.cloudFoundry.org}, cfSpace=${config.cloudFoundry.space}, cfCredentialsId=${config.cloudFoundry.credentialsId}, deployUser=${config.deployUser}"
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.cloudbees.groovy.cps.NonCPS
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
@ -32,10 +34,11 @@ import groovy.transform.Field
|
||||
|
||||
void call(Map parameters = [:], body) {
|
||||
handlePipelineStepErrors(stepName: STEP_NAME, stepParameters: parameters) {
|
||||
final script = parameters.script
|
||||
if (script == null)
|
||||
script = [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
|
||||
final script = checkScript(this, parameters) ?: this
|
||||
|
||||
def utils = parameters?.juStabUtils ?: new Utils()
|
||||
|
||||
Map config = ConfigurationHelper.newInstance(this)
|
||||
.loadStepDefaults()
|
||||
.mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS)
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.JenkinsUtils
|
||||
import com.sap.piper.Utils
|
||||
@ -24,12 +26,13 @@ import hudson.AbortException
|
||||
|
||||
void call(Map parameters = [:], body) {
|
||||
handlePipelineStepErrors(stepName: STEP_NAME, stepParameters: parameters) {
|
||||
|
||||
final script = checkScript(this, parameters) ?: this
|
||||
|
||||
if (!JenkinsUtils.isPluginActive(PLUGIN_ID_KUBERNETES)) {
|
||||
error("[ERROR][${STEP_NAME}] not supported. Plugin '${PLUGIN_ID_KUBERNETES}' is not installed or not active.")
|
||||
}
|
||||
final script = parameters.script
|
||||
if (script == null)
|
||||
script = [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
|
||||
def utils = parameters?.juStabUtils ?: new Utils()
|
||||
|
||||
ConfigurationHelper configHelper = ConfigurationHelper.newInstance(this)
|
||||
|
@ -1,10 +1,12 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field STEP_NAME = 'durationMeasure'
|
||||
|
||||
def call(Map parameters = [:], body) {
|
||||
|
||||
def script = parameters.script
|
||||
def script = checkScript(this, parameters)
|
||||
|
||||
def measurementName = parameters.get('measurementName', 'test_duration')
|
||||
|
||||
//start measurement
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.Utils
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.GitUtils
|
||||
@ -26,7 +28,7 @@ import groovy.transform.Field
|
||||
|
||||
void call(Map parameters = [:]) {
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
def script = parameters.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
def utils = parameters.juStabUtils ?: new Utils()
|
||||
|
||||
script.commonPipelineEnvironment.setInfluxStepData('gauge', false)
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.Utils
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
|
||||
@ -22,7 +24,7 @@ import groovy.transform.Field
|
||||
|
||||
void call(Map parameters = [:]) {
|
||||
handlePipelineStepErrors(stepName: STEP_NAME, stepParameters: parameters) {
|
||||
def script = parameters.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
|
||||
// load default & individual configuration
|
||||
Map config = ConfigurationHelper.newInstance(this)
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.Utils
|
||||
import groovy.transform.Field
|
||||
@ -15,7 +17,7 @@ import groovy.transform.Field
|
||||
|
||||
void call(Map parameters = [:]) {
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
def script = parameters?.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
// load default & individual configuration
|
||||
Map config = ConfigurationHelper.newInstance(this)
|
||||
.loadStepDefaults()
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.ConfigurationLoader
|
||||
import com.sap.piper.ConfigurationMerger
|
||||
@ -19,9 +21,10 @@ import groovy.transform.Field
|
||||
|
||||
void call(Map parameters = [:]) {
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters, allowBuildFailure: true) {
|
||||
def script = parameters.script
|
||||
|
||||
def script = checkScript(this, parameters)
|
||||
if (script == null)
|
||||
script = [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
script = this
|
||||
|
||||
// load default & individual configuration
|
||||
Map configuration = ConfigurationHelper.newInstance(this)
|
||||
@ -35,7 +38,8 @@ void call(Map parameters = [:]) {
|
||||
.mixin(parameters, PARAMETER_KEYS)
|
||||
.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
new Utils().pushToSWA([step: STEP_NAME,
|
||||
stepParam1: parameters?.script == null], configuration)
|
||||
|
||||
if (!configuration.artifactVersion) {
|
||||
//this takes care that terminated builds due to milestone-locking do not cause an error
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.Utils
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
@ -21,7 +23,7 @@ import groovy.transform.Field
|
||||
|
||||
void call(Map parameters = [:]) {
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters, allowBuildFailure: true) {
|
||||
def script = parameters.script?:[commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
|
||||
// load default & individual configuration
|
||||
Map config = ConfigurationHelper.newInstance(this)
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.Utils
|
||||
|
||||
@ -23,7 +25,8 @@ import groovy.transform.Field
|
||||
|
||||
void call(Map parameters = [:]) {
|
||||
handlePipelineStepErrors(stepName: STEP_NAME, stepParameters: parameters) {
|
||||
final script = parameters.script
|
||||
|
||||
final script = checkScript(this, parameters) ?: this
|
||||
|
||||
// load default & individual configuration
|
||||
Map configuration = ConfigurationHelper.newInstance(this)
|
||||
@ -34,7 +37,8 @@ void call(Map parameters = [:]) {
|
||||
.mixin(parameters, PARAMETER_KEYS)
|
||||
.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
new Utils().pushToSWA([step: STEP_NAME,
|
||||
stepParam1: parameters?.script == null], configuration)
|
||||
|
||||
String command = "mvn"
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.MtaUtils
|
||||
import com.sap.piper.Utils
|
||||
@ -22,7 +24,8 @@ import groovy.transform.Field
|
||||
|
||||
void call(Map parameters = [:]) {
|
||||
handlePipelineStepErrors(stepName: STEP_NAME, stepParameters: parameters) {
|
||||
final script = parameters?.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
|
||||
final script = checkScript(this, parameters) ?: this
|
||||
|
||||
// load default & individual configuration
|
||||
Map configuration = ConfigurationHelper.newInstance(this)
|
||||
@ -33,7 +36,8 @@ void call(Map parameters = [:]) {
|
||||
.mixin(parameters, PARAMETER_KEYS)
|
||||
.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
new Utils().pushToSWA([step: STEP_NAME,
|
||||
stepParam1: parameters?.script == null], configuration)
|
||||
|
||||
dockerExecute(script: script, dockerImage: configuration.dockerImage, dockerOptions: configuration.dockerOptions) {
|
||||
def java = new ToolDescriptor('Java', 'JAVA_HOME', '', '/bin/', 'java', '1.8.0', '-version 2>&1')
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.Utils
|
||||
|
||||
@ -32,7 +34,8 @@ import groovy.transform.Field
|
||||
void call(parameters = [:]) {
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
|
||||
def script = parameters?.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
|
||||
def utils = new Utils()
|
||||
|
||||
prepareDefaultValues script: script
|
||||
@ -85,7 +88,8 @@ void call(parameters = [:]) {
|
||||
utils.pushToSWA([
|
||||
step: STEP_NAME,
|
||||
stepParam1: configuration.deployMode == 'mta'?'mta':'war', // ['mta', 'warParams', 'warPropertiesFile']
|
||||
stepParam2: configuration.warAction == 'rolling-update'?'blue-green':'standard' // ['deploy', 'deploy-mta', 'rolling-update']
|
||||
stepParam2: configuration.warAction == 'rolling-update'?'blue-green':'standard', // ['deploy', 'deploy-mta', 'rolling-update']
|
||||
stepParam3: parameters?.script == null
|
||||
], configuration)
|
||||
|
||||
def archivePath = configuration.archivePath
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.GitUtils
|
||||
import com.sap.piper.Utils
|
||||
@ -25,7 +27,9 @@ import groovy.transform.Field
|
||||
|
||||
void call(Map parameters = [:]) {
|
||||
handlePipelineStepErrors(stepName: STEP_NAME, stepParameters: parameters) {
|
||||
def script = parameters?.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
|
||||
def utils = parameters?.juStabUtils ?: new Utils()
|
||||
|
||||
// load default & individual configuration
|
||||
@ -37,7 +41,8 @@ void call(Map parameters = [:]) {
|
||||
.mixin(parameters, PARAMETER_KEYS)
|
||||
.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], config)
|
||||
new Utils().pushToSWA([step: STEP_NAME,
|
||||
stepParam1: parameters?.script == null], config)
|
||||
|
||||
config.stashContent = config.testRepository
|
||||
?[GitUtils.handleTestRepository(this, config)]
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.JenkinsUtils
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import groovy.transform.Field
|
||||
@ -11,7 +13,7 @@ import groovy.transform.Field
|
||||
|
||||
void call(Map parameters = [:], body) {
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
def script = parameters.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
def jenkinsUtils = parameters.jenkinsUtilsStub ?: new JenkinsUtils()
|
||||
// load default & individual configuration
|
||||
Map config = ConfigurationHelper.newInstance(this)
|
||||
|
@ -4,6 +4,7 @@ import groovy.transform.Field
|
||||
|
||||
void call(Map parameters = [:], body) {
|
||||
handlePipelineStepErrors (stepName: 'pipelineStashFiles', stepParameters: parameters) {
|
||||
|
||||
pipelineStashFilesBeforeBuild(parameters)
|
||||
body() //execute build
|
||||
pipelineStashFilesAfterBuild(parameters)
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.Utils
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import groovy.transform.Field
|
||||
@ -13,9 +15,10 @@ void call(Map parameters = [:]) {
|
||||
if (utils == null) {
|
||||
utils = new Utils()
|
||||
}
|
||||
def script = parameters.script
|
||||
|
||||
def script = checkScript(this, parameters)
|
||||
if (script == null)
|
||||
script = [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
script = this
|
||||
|
||||
//additional includes via passing e.g. stashIncludes: [opa5: '**/*.include']
|
||||
//additional excludes via passing e.g. stashExcludes: [opa5: '**/*.exclude']
|
||||
@ -31,7 +34,8 @@ void call(Map parameters = [:]) {
|
||||
.mixin(parameters, PARAMETER_KEYS)
|
||||
.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], config)
|
||||
new Utils().pushToSWA([step: STEP_NAME,
|
||||
stepParam1: parameters?.script == null], config)
|
||||
|
||||
// store files to be checked with checkmarx
|
||||
if (config.runCheckmarx) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.Utils
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import groovy.transform.Field
|
||||
@ -15,9 +17,9 @@ void call(Map parameters = [:]) {
|
||||
utils = new Utils()
|
||||
}
|
||||
|
||||
def script = parameters.script
|
||||
def script = checkScript(this, parameters)
|
||||
if (script == null)
|
||||
script = [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
script = this
|
||||
|
||||
//additional includes via passing e.g. stashIncludes: [opa5: '**/*.include']
|
||||
//additional excludes via passing e.g. stashExcludes: [opa5: '**/*.exclude']
|
||||
@ -30,7 +32,8 @@ void call(Map parameters = [:]) {
|
||||
.mixin(parameters, PARAMETER_KEYS)
|
||||
.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], config)
|
||||
new Utils().pushToSWA([step: STEP_NAME,
|
||||
stepParam1: parameters?.script == null], config)
|
||||
|
||||
if (config.runOpaTests){
|
||||
utils.stash('opa5', config.stashIncludes?.get('opa5')?config.stashIncludes.opa5:'**/*.*', config.stashExcludes?.get('opa5')?config.stashExcludes.opa5:'')
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.GitUtils
|
||||
import com.sap.piper.Utils
|
||||
@ -31,7 +33,7 @@ import groovy.text.SimpleTemplateEngine
|
||||
|
||||
void call(Map parameters = [:], Closure body) {
|
||||
handlePipelineStepErrors(stepName: STEP_NAME, stepParameters: parameters) {
|
||||
def script = parameters?.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
def utils = parameters?.juStabUtils ?: new Utils()
|
||||
|
||||
// load default & individual configuration
|
||||
@ -46,7 +48,8 @@ void call(Map parameters = [:], Closure body) {
|
||||
.dependingOn('buildTool').mixin('dockerWorkspace')
|
||||
.use()
|
||||
|
||||
utils.pushToSWA([step: STEP_NAME], config)
|
||||
utils.pushToSWA([step: STEP_NAME,
|
||||
stepParam1: parameters?.script == null], config)
|
||||
|
||||
dockerExecute(
|
||||
script: script,
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.Utils
|
||||
import groovy.transform.Field
|
||||
@ -9,7 +11,7 @@ void call(Map parameters = [:]) {
|
||||
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
|
||||
def script = parameters.script
|
||||
def script = checkScript(this, parameters)
|
||||
|
||||
prepareDefaultValues script: script, customDefaults: parameters.customDefaults
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.Utils
|
||||
import com.sap.piper.mta.MtaMultiplexer
|
||||
@ -22,7 +24,8 @@ import groovy.transform.Field
|
||||
void call(Map parameters = [:]) {
|
||||
handlePipelineStepErrors(stepName: STEP_NAME, stepParameters: parameters) {
|
||||
def utils = parameters.juStabUtils ?: new Utils()
|
||||
def script = parameters.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
|
||||
Map config = ConfigurationHelper.newInstance(this)
|
||||
.loadStepDefaults()
|
||||
@ -35,7 +38,8 @@ void call(Map parameters = [:]) {
|
||||
.withMandatoryProperty('snykCredentialsId')
|
||||
.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], config)
|
||||
new Utils().pushToSWA([step: STEP_NAME,
|
||||
stepParam1: parameters?.script == null], config)
|
||||
|
||||
utils.unstashAll(config.stashContent)
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.cloudbees.groovy.cps.NonCPS
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
@ -22,9 +24,11 @@ import groovy.transform.Field
|
||||
*/
|
||||
void call(Map parameters = [:]) {
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
def script = parameters.script
|
||||
|
||||
def script = checkScript(this, parameters)
|
||||
if (script == null)
|
||||
script = [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
script = this
|
||||
|
||||
prepare(parameters)
|
||||
|
||||
// load default & individual configuration
|
||||
@ -36,7 +40,8 @@ void call(Map parameters = [:]) {
|
||||
.mixin(parameters, PARAMETER_KEYS)
|
||||
.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
new Utils().pushToSWA([step: STEP_NAME,
|
||||
stepParam1: parameters?.script == null], configuration)
|
||||
|
||||
// UNIT TESTS
|
||||
publishJUnitReport(configuration.get('junit'))
|
||||
|
@ -2,6 +2,7 @@ import com.sap.piper.FileUtils
|
||||
import com.sap.piper.Version
|
||||
import com.sap.piper.tools.JavaArchiveDescriptor
|
||||
import com.sap.piper.tools.ToolDescriptor
|
||||
import groovy.transform.Field
|
||||
|
||||
import groovy.transform.Field
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.Utils
|
||||
import groovy.transform.Field
|
||||
|
||||
@ -30,7 +32,7 @@ def call(parameters = [:]) {
|
||||
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
|
||||
def script = parameters?.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
|
||||
ChangeManagement cm = parameters.cmUtils ?: new ChangeManagement(script)
|
||||
|
||||
@ -47,8 +49,6 @@ def call(parameters = [:]) {
|
||||
BackendType backendType = getBackendTypeAndLogInfoIfCMIntegrationDisabled(this, configuration)
|
||||
if(backendType == BackendType.NONE) return
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
|
||||
configHelper
|
||||
.withMandatoryProperty('changeManagement/clientOpts')
|
||||
.withMandatoryProperty('changeManagement/credentialsId')
|
||||
@ -62,6 +62,9 @@ def call(parameters = [:]) {
|
||||
|
||||
def changeDocumentId = null
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME,
|
||||
stepParam1: parameters?.script == null], configuration)
|
||||
|
||||
if(backendType == BackendType.SOLMAN) {
|
||||
|
||||
changeDocumentId = configuration.changeDocumentId
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.Utils
|
||||
import groovy.transform.Field
|
||||
|
||||
@ -27,7 +29,7 @@ void call(parameters = [:]) {
|
||||
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
|
||||
def script = parameters?.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
|
||||
ChangeManagement cm = parameters.cmUtils ?: new ChangeManagement(script)
|
||||
|
||||
@ -52,7 +54,10 @@ void call(parameters = [:]) {
|
||||
.withMandatoryProperty('changeManagement/git/from')
|
||||
.withMandatoryProperty('changeManagement/git/format')
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
configuration = configHelper.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME,
|
||||
stepParam1: parameters?.script == null], configuration)
|
||||
|
||||
def transportRequestId = configuration.transportRequestId
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.Utils
|
||||
import groovy.transform.Field
|
||||
|
||||
@ -29,7 +31,7 @@ void call(parameters = [:]) {
|
||||
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
|
||||
def script = parameters?.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
|
||||
ChangeManagement cm = parameters.cmUtils ?: new ChangeManagement(script)
|
||||
|
||||
@ -57,7 +59,9 @@ void call(parameters = [:]) {
|
||||
.withMandatoryProperty('changeManagement/git/format')
|
||||
.withMandatoryProperty('filePath')
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME, stepParam1: configuration.changeManagement.type], configuration)
|
||||
new Utils().pushToSWA([step: STEP_NAME,
|
||||
stepParam1: configuration.changeManagement.type,
|
||||
stepParam2: parameters?.script == null], configuration)
|
||||
|
||||
def changeDocumentId = null
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user