mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-03-03 15:02:35 +02:00
Merge branch 'master' of https://github.com/SAP/jenkins-library
This commit is contained in:
commit
646a51556a
@ -6,16 +6,17 @@ Executes a maven command inside a Docker container.
|
||||
|
||||
## Parameters
|
||||
|
||||
| parameter | mandatory | default | example values |
|
||||
| ---------------------|-----------|-------------------|----------------------------|
|
||||
| `dockerImage` | no | 'maven:3.5-jdk-7' | |
|
||||
| `globalSettingsFile` | no | | 'local_folder/settings.xml'|
|
||||
| `projectSettingsFile`| no | | |
|
||||
| `pomPath` | no | | 'local_folder/m2' |
|
||||
| `flags` | no | | '-o' |
|
||||
| `goals` | no | | 'clean install' |
|
||||
| `m2Path` | no | | 'local_folder/m2' |
|
||||
| `defines` | no | | '-Dmaven.tests.skip=true' |
|
||||
| parameter | mandatory | default | example values |
|
||||
| -------------------------------|-----------|-------------------|----------------------------|
|
||||
| `dockerImage` | no | 'maven:3.5-jdk-7' | |
|
||||
| `globalSettingsFile` | no | | 'local_folder/settings.xml'|
|
||||
| `projectSettingsFile` | no | | |
|
||||
| `pomPath` | no | | 'local_folder/m2' |
|
||||
| `flags` | no | | '-o' |
|
||||
| `goals` | no | | 'clean install' |
|
||||
| `m2Path` | no | | 'local_folder/m2' |
|
||||
| `defines` | no | | '-Dmaven.tests.skip=true' |
|
||||
| `logSuccessfulMavenTransfers` | no | `false` | 'true' |
|
||||
|
||||
* `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.
|
||||
@ -25,6 +26,7 @@ Executes a maven command inside a Docker container.
|
||||
* `goals` Maven goals that should be executed.
|
||||
* `m2Path` Path to the location of the local repository that should be used.
|
||||
* `defines` Additional properties.
|
||||
* `logSuccessfulMavenTransfers` configures maven to log successful downloads. This is set to `false` by default to reduce the noise in build logs.
|
||||
|
||||
## Step configuration
|
||||
The following parameters can also be specified as step parameters using the global configuration file:
|
||||
|
62
documentation/docs/steps/pipelineStashFiles.md
Normal file
62
documentation/docs/steps/pipelineStashFiles.md
Normal file
@ -0,0 +1,62 @@
|
||||
# pipelineStashFiles
|
||||
|
||||
## Description
|
||||
This step stashes files that are needed in other build steps (on other nodes).
|
||||
|
||||
## Prerequsites
|
||||
none
|
||||
|
||||
## Parameters
|
||||
|
||||
| parameter | mandatory | default | possible values |
|
||||
| ----------|-----------|---------|-----------------|
|
||||
| script | no | empty `commonPipelineEnvironment` | |
|
||||
| runCheckmarx | no | false | |
|
||||
| runOpaTests | no | false | |
|
||||
| stashIncludes | no | see details | |
|
||||
| stashExcludes | no | see details | |
|
||||
|
||||
Details:
|
||||
|
||||
The step is stashing files before and after the build. This is due to the fact, that some of the code that needs to be stashed, is generated during the build (TypeScript for NPM).
|
||||
|
||||
| stash name | mandatory | prerequisite | pattern |
|
||||
|---|---|---|---|
|
||||
|buildDescriptor|no| |includes: `**/pom.xml, **/.mvn/**, **/assembly.xml, **/.swagger-codegen-ignore, **/package.json, **/requirements.txt, **/setup.py, **/whitesource_config.py, **/mta*.y*ml, **/.npmrc, **/whitesource.*.json, **/whitesource-fs-agent.config, .xmake.cfg, Dockerfile, **/VERSION, **/version.txt, **/build.sbt, **/sbtDescriptor.json, **/project/*`<br /> excludes: `**/node_modules/**/package.json`|
|
||||
|checkmarx|no|Checkmarx is enabled|includes: `**/*.js, **/*.scala, **/*.go`<br /> excludes: `**/*.mockserver.js, node_modules/**/*.js`|
|
||||
|classFiles|no| |includes: `**/target/classes/**/*.class, **/target/test-classes/**/*.class` <br />excludes: `''`|
|
||||
|deployDescriptor|no| |includes: `**/manifest*.y*ml, **/*.mtaext.y*ml, **/*.mtaext, **/xs-app.json, helm/**, *.y*ml`<br />exclude: `''`|
|
||||
|git|no| |includes: `**/gitmetadata/**`<br />exludes: `''`|
|
||||
|opa5|no|OPA5 is enabled|includes: `**/*.*`<br />excludes: `''`|
|
||||
|opensourceConfiguration|no| |includes: `**/srcclr.yml, **/vulas-custom.properties, **/.nsprc, **/.retireignore, **/.retireignore.json, **/.snyk`<br />excludes: `''`|
|
||||
|pipelineConfigAndTests|no| |includes: `.pipeline/*.*`<br />excludes: `''`|
|
||||
|securityDescriptor|no| |includes: `**/xs-security.json`<br />exludes: `''`|
|
||||
|sonar|no| |includes: `**/jacoco*.exec, **/sonar-project.properties`<br />exludes: `''`|
|
||||
|tests|no| |includes: `**/pom.xml, **/*.json, **/*.xml, **/src/**, **/node_modules/**, **/specs/**, **/env/**, **/*.js`<br />excludes: `''`|
|
||||
|
||||
!!! note "Overwriting default stashing behavior"
|
||||
It is possible to overwrite the default behavior of the stashes using the parameters `stashIncludes` and `stashExcludes` , e.g.
|
||||
|
||||
* `stashIncludes: [buildDescriptor: '**/mybuild.yml]`
|
||||
* `stashExcludes: [tests: '**/NOTRELEVANT.*]`
|
||||
|
||||
## Step configuration
|
||||
The following parameters can also be specified as step parameters using the global configuration file:
|
||||
|
||||
* runOpaTests
|
||||
* runCheckmarx
|
||||
* stashExcludes
|
||||
* stashIncludes
|
||||
|
||||
|
||||
## Explanation of pipeline step
|
||||
|
||||
Usage of pipeline step:
|
||||
|
||||
```groovy
|
||||
pipelineStashFiles script: this {
|
||||
mavenExecute script: this, ...
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -12,6 +12,7 @@ pages:
|
||||
- mtaBuild: steps/mtaBuild.md
|
||||
- neoDeploy: steps/neoDeploy.md
|
||||
- pipelineExecute: steps/pipelineExecute.md
|
||||
- pipelineStashFiles: steps/pipelineStashFiles.md
|
||||
- prepareDefaultValues: steps/prepareDefaultValues.md
|
||||
- setupCommonPipelineEnvironment: steps/setupCommonPipelineEnvironment.md
|
||||
- toolValidate: steps/toolValidate.md
|
||||
|
@ -77,6 +77,7 @@ steps:
|
||||
influxServer: 'jenkins'
|
||||
mavenExecute:
|
||||
dockerImage: 'maven:3.5-jdk-7'
|
||||
logSuccessfulMavenTransfers: false
|
||||
mtaBuild:
|
||||
buildTarget: 'NEO'
|
||||
mtaJarLocation: 'mta.jar'
|
||||
@ -86,6 +87,7 @@ steps:
|
||||
vmSize: 'lite'
|
||||
neoCredentialsId: 'CI_CREDENTIALS_ID'
|
||||
pipelineStashFilesAfterBuild:
|
||||
runOpaTests: false
|
||||
stashIncludes:
|
||||
checkmarx: '**/*.js, **/*.scala, **/*.py, **/*.go, **/*.xml, **/*.html'
|
||||
classFiles: '**/target/classes/**/*.class, **/target/test-classes/**/*.class'
|
||||
@ -95,22 +97,22 @@ steps:
|
||||
classFiles: ''
|
||||
sonar: ''
|
||||
pipelineStashFilesBeforeBuild:
|
||||
runCheckmarx: false
|
||||
stashIncludes:
|
||||
buildDescriptor: '**/pom.xml, **/.mvn/**, **/assembly.xml, **/.swagger-codegen-ignore, **/package.json, **/requirements.txt, **/setup.py, **/whitesource_config.py, **/mta*.y*ml, **/.npmrc, **/whitesource.*.json, **/whitesource-fs-agent.config, .xmake.cfg, Dockerfile, **/VERSION, **/version.txt, **/build.sbt, **/sbtDescriptor.json, **/project/*'
|
||||
deployDescriptor: '**/manifest*.y*ml, **/*.mtaext.y*ml, **/*.mtaext, **/xs-app.json, helm/**, *.y*ml'
|
||||
git: '**/gitmetadata/**'
|
||||
opa5: '**/*.*'
|
||||
'opensource configuration': '**/srcclr.yml, **/vulas-custom.properties, **/.nsprc, **/.retireignore, **/.retireignore.json, **/'
|
||||
opensourceConfiguration: '**/srcclr.yml, **/vulas-custom.properties, **/.nsprc, **/.retireignore, **/.retireignore.json, **/.snyk'
|
||||
pipelineConfigAndTests: '.pipeline/*.*'
|
||||
securityDescriptor: '**/xs-security.json'
|
||||
'snyk configuration': '**/.snyk'
|
||||
tests: '**/pom.xml, **/*.json, **/*.xml, **/src/**, **/node_modules/**, **/specs/**, **/env/**, **/*.js'
|
||||
stashExcludes:
|
||||
buildDescriptor: '**/node_modules/**/package.json'
|
||||
deployDescriptor: ''
|
||||
git: ''
|
||||
opa5: ''
|
||||
'opensource configuration': ''
|
||||
opensourceConfiguration: ''
|
||||
pipelineConfigAndTests: ''
|
||||
securityDescriptor: ''
|
||||
'snyk configuration': ''
|
||||
|
@ -1,11 +1,11 @@
|
||||
#!groovy
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
import com.sap.piper.GitUtils
|
||||
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.JenkinsEnvironmentRule
|
||||
import util.JenkinsLoggingRule
|
||||
import util.JenkinsReadMavenPomRule
|
||||
@ -14,16 +14,17 @@ import util.JenkinsStepRule
|
||||
import util.JenkinsWriteFileRule
|
||||
import util.Rules
|
||||
|
||||
import static org.hamcrest.Matchers.hasItem
|
||||
import static org.junit.Assert.assertThat
|
||||
import static org.junit.Assert.assertEquals
|
||||
|
||||
class ArtifactSetVersionTest extends BasePipelineTest {
|
||||
class ArtifactSetVersionTest extends BasePiperTest {
|
||||
Map dockerParameters
|
||||
def mavenExecuteScript
|
||||
|
||||
def gitUtils
|
||||
def sshAgentList = []
|
||||
|
||||
private ExpectedException thrown = ExpectedException.none()
|
||||
private JenkinsDockerExecuteRule jder = new JenkinsDockerExecuteRule(this)
|
||||
private JenkinsLoggingRule jlr = new JenkinsLoggingRule(this)
|
||||
private JenkinsShellCallRule jscr = new JenkinsShellCallRule(this)
|
||||
private JenkinsWriteFileRule jwfr = new JenkinsWriteFileRule(this)
|
||||
@ -38,6 +39,7 @@ class ArtifactSetVersionTest extends BasePipelineTest {
|
||||
.around(jscr)
|
||||
.around(new JenkinsReadMavenPomRule(this, 'test/resources/MavenArtifactVersioning'))
|
||||
.around(jwfr)
|
||||
.around(jder)
|
||||
.around(jsr)
|
||||
.around(jer)
|
||||
|
||||
@ -45,14 +47,6 @@ class ArtifactSetVersionTest extends BasePipelineTest {
|
||||
void init() throws Throwable {
|
||||
dockerParameters = [:]
|
||||
|
||||
helper.registerAllowedMethod("dockerExecute", [Map.class, Closure.class],
|
||||
{ parameters, closure ->
|
||||
dockerParameters = parameters
|
||||
closure()
|
||||
})
|
||||
|
||||
mavenExecuteScript = loadScript("mavenExecute.groovy").mavenExecute
|
||||
|
||||
helper.registerAllowedMethod("sshagent", [List.class, Closure.class], { list, closure ->
|
||||
sshAgentList = list
|
||||
return closure()
|
||||
@ -65,11 +59,7 @@ class ArtifactSetVersionTest extends BasePipelineTest {
|
||||
|
||||
binding.setVariable('Jenkins', [instance: [pluginManager: [plugins: [new DockerExecuteTest.PluginMock()]]]])
|
||||
|
||||
|
||||
gitUtils = new GitUtils()
|
||||
prepareObjectInterceptors(gitUtils)
|
||||
|
||||
this.helper.registerAllowedMethod('fileExists', [String.class], {true})
|
||||
helper.registerAllowedMethod('fileExists', [String.class], {true})
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -79,12 +69,12 @@ class ArtifactSetVersionTest extends BasePipelineTest {
|
||||
assertEquals('1.2.3-20180101010203_testCommitId', jer.env.getArtifactVersion())
|
||||
assertEquals('testCommitId', jer.env.getGitCommitId())
|
||||
|
||||
assertEquals('mvn --file \'pom.xml\' versions:set -DnewVersion=1.2.3-20180101010203_testCommitId', jscr.shell[6])
|
||||
assertEquals('git add .', jscr.shell[7])
|
||||
assertEquals ("git commit -m 'update version 1.2.3-20180101010203_testCommitId'", jscr.shell[8])
|
||||
assertEquals ("git remote set-url origin myGitSshUrl", jscr.shell[9])
|
||||
assertEquals ("git tag build_1.2.3-20180101010203_testCommitId", jscr.shell[10])
|
||||
assertEquals ("git push origin build_1.2.3-20180101010203_testCommitId", jscr.shell[11])
|
||||
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"))
|
||||
assertThat(jscr.shell, hasItem('git add .'))
|
||||
assertThat(jscr.shell, hasItem("git commit -m 'update version 1.2.3-20180101010203_testCommitId'"))
|
||||
assertThat(jscr.shell, hasItem("git remote set-url origin myGitSshUrl"))
|
||||
assertThat(jscr.shell, hasItem("git tag build_1.2.3-20180101010203_testCommitId"))
|
||||
assertThat(jscr.shell, hasItem("git push origin build_1.2.3-20180101010203_testCommitId"))
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -92,7 +82,7 @@ class ArtifactSetVersionTest extends BasePipelineTest {
|
||||
jsr.step.call(script: jsr.step, juStabGitUtils: gitUtils, buildTool: 'maven', commitVersion: false)
|
||||
|
||||
assertEquals('1.2.3-20180101010203_testCommitId', jer.env.getArtifactVersion())
|
||||
assertEquals('mvn --file \'pom.xml\' versions:set -DnewVersion=1.2.3-20180101010203_testCommitId', jscr.shell[6])
|
||||
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"))
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -100,14 +90,14 @@ class ArtifactSetVersionTest extends BasePipelineTest {
|
||||
jsr.step.call(juStabGitUtils: gitUtils, buildTool: 'maven', commitVersion: false)
|
||||
|
||||
assertEquals('1.2.3-20180101010203_testCommitId', jer.env.getArtifactVersion())
|
||||
assertEquals('mvn --file \'pom.xml\' versions:set -DnewVersion=1.2.3-20180101010203_testCommitId', jscr.shell[6])
|
||||
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"))
|
||||
}
|
||||
|
||||
@Test
|
||||
void testVersioningCustomGitUserAndEMail() {
|
||||
jsr.step.call(script: jsr.step, juStabGitUtils: gitUtils, buildTool: 'maven', gitSshUrl: 'myGitSshUrl', gitUserEMail: 'test@test.com', gitUserName: 'test')
|
||||
|
||||
assertEquals ('git -c user.email="test@test.com" -c user.name="test" commit -m \'update version 1.2.3-20180101010203_testCommitId\'', jscr.shell[8])
|
||||
assertThat(jscr.shell, hasItem("git -c user.email=\"test@test.com\" -c user.name=\"test\" commit -m 'update version 1.2.3-20180101010203_testCommitId'"))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -4,7 +4,7 @@ import org.junit.Test
|
||||
import org.junit.rules.RuleChain
|
||||
import org.junit.Ignore
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
import util.BasePiperTest
|
||||
|
||||
import static org.junit.Assert.assertEquals
|
||||
import static org.junit.Assert.assertTrue
|
||||
@ -12,7 +12,7 @@ import static org.junit.Assert.assertTrue
|
||||
import util.Rules
|
||||
import util.JenkinsStepRule
|
||||
|
||||
class ChecksPublishResultsTest extends BasePipelineTest {
|
||||
class ChecksPublishResultsTest extends BasePiperTest {
|
||||
Map publisherStepOptions
|
||||
List archiveStepPatterns
|
||||
|
||||
|
@ -4,23 +4,20 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.RuleChain
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
|
||||
import util.BasePiperTest
|
||||
import util.JenkinsLoggingRule
|
||||
import util.Rules
|
||||
import util.JenkinsStepRule
|
||||
import util.JenkinsEnvironmentRule
|
||||
|
||||
import static org.junit.Assert.assertEquals
|
||||
import static org.junit.Assert.assertTrue
|
||||
import static org.junit.Assert.assertFalse
|
||||
|
||||
class DockerExecuteTest extends BasePipelineTest {
|
||||
class DockerExecuteTest extends BasePiperTest {
|
||||
private DockerMock docker
|
||||
|
||||
private JenkinsLoggingRule jlr = new JenkinsLoggingRule(this)
|
||||
private JenkinsStepRule jsr = new JenkinsStepRule(this)
|
||||
private JenkinsEnvironmentRule jer = new JenkinsEnvironmentRule(this)
|
||||
|
||||
@Rule
|
||||
public RuleChain ruleChain = Rules
|
||||
@ -44,7 +41,7 @@ class DockerExecuteTest extends BasePipelineTest {
|
||||
@Test
|
||||
void testExecuteInsideDocker() throws Exception {
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
dockerImage: 'maven:3.5-jdk-8-alpine') {
|
||||
bodyExecuted = true
|
||||
}
|
||||
@ -58,7 +55,7 @@ class DockerExecuteTest extends BasePipelineTest {
|
||||
@Test
|
||||
void testExecuteInsideDockerWithParameters() throws Exception {
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
dockerImage: 'maven:3.5-jdk-8-alpine',
|
||||
dockerOptions: '-it',
|
||||
dockerVolumeBind: ['my_vol': '/my_vol'],
|
||||
@ -74,7 +71,7 @@ class DockerExecuteTest extends BasePipelineTest {
|
||||
|
||||
@Test
|
||||
void testExecuteDockerWithDockerOptionsList() throws Exception {
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
dockerImage: 'maven:3.5-jdk-8-alpine',
|
||||
dockerOptions: ['-it', '--network=my-network'],
|
||||
dockerEnvVars: ['http_proxy': 'http://proxy:8000']) {
|
||||
@ -91,7 +88,7 @@ class DockerExecuteTest extends BasePipelineTest {
|
||||
|
||||
whichDockerReturnValue = 1
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
dockerImage: 'maven:3.5-jdk-8-alpine',
|
||||
dockerOptions: '-it',
|
||||
dockerVolumeBind: ['my_vol': '/my_vol'],
|
||||
|
@ -1,32 +1,29 @@
|
||||
#!groovy
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import util.BasePiperTest
|
||||
|
||||
import static org.junit.Assert.assertTrue
|
||||
import org.junit.rules.RuleChain
|
||||
|
||||
import util.Rules
|
||||
import util.JenkinsStepRule
|
||||
import util.JenkinsEnvironmentRule
|
||||
|
||||
class DurationMeasureTest extends BasePipelineTest {
|
||||
class DurationMeasureTest extends BasePiperTest {
|
||||
private JenkinsStepRule jsr = new JenkinsStepRule(this)
|
||||
private JenkinsEnvironmentRule jer = new JenkinsEnvironmentRule(this)
|
||||
|
||||
@Rule
|
||||
public RuleChain rules = Rules
|
||||
.getCommonRules(this)
|
||||
.around(jsr)
|
||||
.around(jer)
|
||||
|
||||
@Test
|
||||
void testDurationMeasurement() throws Exception {
|
||||
def bodyExecuted = false
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env], measurementName: 'test') {
|
||||
jsr.step.call(script: nullScript, measurementName: 'test') {
|
||||
bodyExecuted = true
|
||||
}
|
||||
assertTrue(jer.env.getPipelineMeasurement('test') != null)
|
||||
assertTrue(nullScript.commonPipelineEnvironment.getPipelineMeasurement('test') != null)
|
||||
assertTrue(bodyExecuted)
|
||||
assertJobStatusSuccess()
|
||||
}
|
||||
|
@ -1,29 +1,26 @@
|
||||
#!groovy
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
import com.sap.piper.DefaultValueCache
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.RuleChain
|
||||
import util.BasePiperTest
|
||||
import util.JenkinsLoggingRule
|
||||
import util.JenkinsStepRule
|
||||
import util.JenkinsEnvironmentRule
|
||||
import util.Rules
|
||||
|
||||
import static org.junit.Assert.assertTrue
|
||||
import static org.junit.Assert.assertEquals
|
||||
|
||||
class InfluxWriteDataTest extends BasePipelineTest {
|
||||
class InfluxWriteDataTest extends BasePiperTest {
|
||||
public JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this)
|
||||
private JenkinsStepRule jsr = new JenkinsStepRule(this)
|
||||
private JenkinsEnvironmentRule jer = new JenkinsEnvironmentRule(this)
|
||||
|
||||
@Rule
|
||||
public RuleChain ruleChain = Rules
|
||||
.getCommonRules(this)
|
||||
.around(loggingRule)
|
||||
.around(jsr)
|
||||
.around(jer)
|
||||
|
||||
Map fileMap = [:]
|
||||
Map stepMap = [:]
|
||||
@ -55,8 +52,8 @@ class InfluxWriteDataTest extends BasePipelineTest {
|
||||
@Test
|
||||
void testInfluxWriteDataWithDefault() throws Exception {
|
||||
|
||||
jer.env.setArtifactVersion('1.2.3')
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env])
|
||||
nullScript.commonPipelineEnvironment.setArtifactVersion('1.2.3')
|
||||
jsr.step.call(script: nullScript)
|
||||
|
||||
assertTrue(loggingRule.log.contains('Artifact version: 1.2.3'))
|
||||
|
||||
@ -74,8 +71,8 @@ class InfluxWriteDataTest extends BasePipelineTest {
|
||||
@Test
|
||||
void testInfluxWriteDataNoInflux() throws Exception {
|
||||
|
||||
jer.env.setArtifactVersion('1.2.3')
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env], influxServer: '')
|
||||
nullScript.commonPipelineEnvironment.setArtifactVersion('1.2.3')
|
||||
jsr.step.call(script: nullScript, influxServer: '')
|
||||
|
||||
assertEquals(0, stepMap.size())
|
||||
|
||||
@ -88,7 +85,7 @@ class InfluxWriteDataTest extends BasePipelineTest {
|
||||
@Test
|
||||
void testInfluxWriteDataNoArtifactVersion() throws Exception {
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env])
|
||||
jsr.step.call(script: nullScript)
|
||||
|
||||
assertEquals(0, stepMap.size())
|
||||
assertEquals(0, fileMap.size())
|
||||
|
@ -9,16 +9,14 @@ import org.junit.rules.RuleChain
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import org.yaml.snakeyaml.parser.ParserException
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
|
||||
import hudson.AbortException
|
||||
import util.JenkinsEnvironmentRule
|
||||
import util.BasePiperTest
|
||||
import util.JenkinsLoggingRule
|
||||
import util.JenkinsShellCallRule
|
||||
import util.JenkinsStepRule
|
||||
import util.Rules
|
||||
|
||||
public class MtaBuildTest extends BasePipelineTest {
|
||||
public class MtaBuildTest extends BasePiperTest {
|
||||
|
||||
def toolMtaValidateCalled = false
|
||||
def toolJavaValidateCalled = false
|
||||
@ -30,7 +28,6 @@ public class MtaBuildTest extends BasePipelineTest {
|
||||
private JenkinsLoggingRule jlr = new JenkinsLoggingRule(this)
|
||||
private JenkinsShellCallRule jscr = new JenkinsShellCallRule(this)
|
||||
private JenkinsStepRule jsr = new JenkinsStepRule(this)
|
||||
private JenkinsEnvironmentRule jer = new JenkinsEnvironmentRule(this)
|
||||
|
||||
@Rule
|
||||
public RuleChain ruleChain = Rules
|
||||
@ -39,7 +36,6 @@ public class MtaBuildTest extends BasePipelineTest {
|
||||
.around(jlr)
|
||||
.around(jscr)
|
||||
.around(jsr)
|
||||
.around(jer)
|
||||
|
||||
private static currentDir
|
||||
private static newDir
|
||||
@ -88,10 +84,10 @@ public class MtaBuildTest extends BasePipelineTest {
|
||||
@Test
|
||||
void mtarFilePathFromCommonPipelineEnviromentTest() {
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
buildTarget: 'NEO')
|
||||
|
||||
def mtarFilePath = jer.env.getMtarFilePath()
|
||||
def mtarFilePath = nullScript.commonPipelineEnvironment.getMtarFilePath()
|
||||
|
||||
assert mtarFilePath == "$currentDir/com.mycompany.northwind.mtar"
|
||||
}
|
||||
@ -172,9 +168,9 @@ public class MtaBuildTest extends BasePipelineTest {
|
||||
@Test
|
||||
void mtaJarLocationFromCustomStepConfigurationTest() {
|
||||
|
||||
jer.env.configuration = [steps:[mtaBuild:[mtaJarLocation: '/config/mta/mta.jar']]]
|
||||
nullScript.commonPipelineEnvironment.configuration = [steps:[mtaBuild:[mtaJarLocation: '/config/mta/mta.jar']]]
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
buildTarget: 'NEO')
|
||||
|
||||
assert jscr.shell.find(){ c -> c.contains("-jar /config/mta/mta.jar --mtar")}
|
||||
@ -186,7 +182,7 @@ public class MtaBuildTest extends BasePipelineTest {
|
||||
@Test
|
||||
void mtaJarLocationFromDefaultStepConfigurationTest() {
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
buildTarget: 'NEO')
|
||||
|
||||
assert jscr.shell.find(){ c -> c.contains("-jar mta.jar --mtar")}
|
||||
@ -207,9 +203,9 @@ public class MtaBuildTest extends BasePipelineTest {
|
||||
@Test
|
||||
void buildTargetFromCustomStepConfigurationTest() {
|
||||
|
||||
jer.env.configuration = [steps:[mtaBuild:[buildTarget: 'NEO']]]
|
||||
nullScript.commonPipelineEnvironment.configuration = [steps:[mtaBuild:[buildTarget: 'NEO']]]
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env])
|
||||
jsr.step.call(script: nullScript)
|
||||
|
||||
assert jscr.shell.find(){ c -> c.contains('java -jar mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO build')}
|
||||
}
|
||||
@ -218,9 +214,9 @@ public class MtaBuildTest extends BasePipelineTest {
|
||||
@Test
|
||||
void buildTargetFromDefaultStepConfigurationTest() {
|
||||
|
||||
jer.env.defaultConfiguration = [steps:[mtaBuild:[buildTarget: 'NEO']]]
|
||||
nullScript.commonPipelineEnvironment.defaultConfiguration = [steps:[mtaBuild:[buildTarget: 'NEO']]]
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env])
|
||||
jsr.step.call(script: nullScript)
|
||||
|
||||
assert jscr.shell.find { c -> c.contains('java -jar mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO build')}
|
||||
}
|
||||
@ -238,9 +234,9 @@ public class MtaBuildTest extends BasePipelineTest {
|
||||
@Test
|
||||
void extensionFromCustomStepConfigurationTest() {
|
||||
|
||||
jer.env.configuration = [steps:[mtaBuild:[buildTarget: 'NEO', extension: 'config_extension']]]
|
||||
nullScript.commonPipelineEnvironment.configuration = [steps:[mtaBuild:[buildTarget: 'NEO', extension: 'config_extension']]]
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env])
|
||||
jsr.step.call(script: nullScript)
|
||||
|
||||
assert jscr.shell.find(){ c -> c.contains('java -jar mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO --extension=config_extension build')}
|
||||
}
|
||||
|
@ -1,57 +1,52 @@
|
||||
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.RuleChain
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
import util.BasePiperTest
|
||||
import util.JenkinsDockerExecuteRule
|
||||
import util.JenkinsShellCallRule
|
||||
import util.JenkinsStepRule
|
||||
import util.Rules
|
||||
|
||||
import static org.junit.Assert.assertEquals
|
||||
import static org.junit.Assert.assertTrue
|
||||
|
||||
import util.BasePiperTest
|
||||
import util.JenkinsShellCallRule
|
||||
import util.Rules
|
||||
|
||||
class MavenExecuteTest extends BasePiperTest {
|
||||
|
||||
Map dockerParameters
|
||||
|
||||
private JenkinsShellCallRule jscr = new JenkinsShellCallRule(this)
|
||||
private JenkinsDockerExecuteRule jder = new JenkinsDockerExecuteRule(this)
|
||||
private JenkinsStepRule jsr = new JenkinsStepRule(this)
|
||||
|
||||
@Rule
|
||||
public RuleChain ruleChain = Rules.getCommonRules(this)
|
||||
.around(jscr)
|
||||
|
||||
def mavenExecuteScript
|
||||
|
||||
@Before
|
||||
void init() {
|
||||
|
||||
dockerParameters = [:]
|
||||
|
||||
helper.registerAllowedMethod("dockerExecute", [Map.class, Closure.class],
|
||||
{ parameters, closure ->
|
||||
dockerParameters = parameters
|
||||
closure()
|
||||
})
|
||||
|
||||
mavenExecuteScript = loadScript("mavenExecute.groovy").mavenExecute
|
||||
}
|
||||
public RuleChain ruleChain = Rules
|
||||
.getCommonRules(this)
|
||||
.around(jder)
|
||||
.around(jscr)
|
||||
.around(jsr)
|
||||
|
||||
@Test
|
||||
void testExecuteBasicMavenCommand() throws Exception {
|
||||
|
||||
mavenExecuteScript.call(script: nullScript, goals: 'clean install')
|
||||
assertEquals('maven:3.5-jdk-7', dockerParameters.dockerImage)
|
||||
jsr.step.mavenExecute(script: nullScript, goals: 'clean install')
|
||||
assertEquals('maven:3.5-jdk-7', jder.dockerParams.dockerImage)
|
||||
|
||||
assert jscr.shell[0] == 'mvn clean install'
|
||||
assert jscr.shell[0] == 'mvn --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn clean install'
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExecuteBasicMavenCommandWithDownloadLogsEnabled() throws Exception {
|
||||
|
||||
jsr.step.mavenExecute(script: nullScript, goals: 'clean install', logSuccessfulMavenTransfers: true)
|
||||
assertEquals('maven:3.5-jdk-7', jder.dockerParams.dockerImage)
|
||||
|
||||
assert jscr.shell[0] == 'mvn --batch-mode clean install'
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExecuteMavenCommandWithParameter() throws Exception {
|
||||
|
||||
mavenExecuteScript.call(
|
||||
jsr.step.mavenExecute(
|
||||
script: nullScript,
|
||||
dockerImage: 'maven:3.5-jdk-8-alpine',
|
||||
goals: 'clean install',
|
||||
@ -61,17 +56,17 @@ class MavenExecuteTest extends BasePiperTest {
|
||||
flags: '-o',
|
||||
m2Path: 'm2Path',
|
||||
defines: '-Dmaven.tests.skip=true')
|
||||
assertEquals('maven:3.5-jdk-8-alpine', dockerParameters.dockerImage)
|
||||
String mvnCommand = "mvn --global-settings 'globalSettingsFile.xml' -Dmaven.repo.local='m2Path' --settings 'projectSettingsFile.xml' --file 'pom.xml' -o clean install -Dmaven.tests.skip=true"
|
||||
assertEquals('maven:3.5-jdk-8-alpine', jder.dockerParams.dockerImage)
|
||||
String mvnCommand = "mvn --global-settings 'globalSettingsFile.xml' -Dmaven.repo.local='m2Path' --settings 'projectSettingsFile.xml' --file 'pom.xml' -o --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn clean install -Dmaven.tests.skip=true"
|
||||
assertTrue(jscr.shell.contains(mvnCommand))
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMavenCommandForwardsDockerOptions() throws Exception {
|
||||
|
||||
mavenExecuteScript.call(script: nullScript, goals: 'clean install')
|
||||
assertEquals('maven:3.5-jdk-7', dockerParameters.dockerImage)
|
||||
jsr.step.mavenExecute(script: nullScript, goals: 'clean install')
|
||||
assertEquals('maven:3.5-jdk-7', jder.dockerParams.dockerImage)
|
||||
|
||||
assert jscr.shell[0] == 'mvn clean install'
|
||||
assert jscr.shell[0] == 'mvn --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn clean install'
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,6 @@ import hudson.AbortException
|
||||
|
||||
import org.junit.rules.TemporaryFolder
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
|
||||
import org.junit.BeforeClass
|
||||
import org.junit.ClassRule
|
||||
import org.junit.Ignore
|
||||
@ -12,15 +10,13 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.rules.RuleChain
|
||||
|
||||
|
||||
import util.BasePiperTest
|
||||
import util.JenkinsLoggingRule
|
||||
import util.JenkinsShellCallRule
|
||||
import util.JenkinsStepRule
|
||||
import util.JenkinsEnvironmentRule
|
||||
import util.Rules
|
||||
|
||||
class NeoDeployTest extends BasePipelineTest {
|
||||
class NeoDeployTest extends BasePiperTest {
|
||||
|
||||
def toolJavaValidateCalled = false
|
||||
|
||||
@ -31,7 +27,6 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
private JenkinsLoggingRule jlr = new JenkinsLoggingRule(this)
|
||||
private JenkinsShellCallRule jscr = new JenkinsShellCallRule(this)
|
||||
private JenkinsStepRule jsr = new JenkinsStepRule(this)
|
||||
private JenkinsEnvironmentRule jer = new JenkinsEnvironmentRule(this)
|
||||
|
||||
@Rule
|
||||
public RuleChain ruleChain = Rules
|
||||
@ -40,7 +35,6 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
.around(jlr)
|
||||
.around(jscr)
|
||||
.around(jsr)
|
||||
.around(jer)
|
||||
|
||||
private static workspacePath
|
||||
private static warArchiveName
|
||||
@ -86,18 +80,18 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
|
||||
helper.registerAllowedMethod('sh', [Map], { Map m -> getVersionWithEnvVars(m) })
|
||||
|
||||
jer.env.configuration = [steps:[neoDeploy: [host: 'test.deploy.host.com', account: 'trialuser123']]]
|
||||
nullScript.commonPipelineEnvironment.configuration = [steps:[neoDeploy: [host: 'test.deploy.host.com', account: 'trialuser123']]]
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void straightForwardTestConfigViaConfigProperties() {
|
||||
|
||||
jer.env.setConfigProperty('DEPLOY_HOST', 'test.deploy.host.com')
|
||||
jer.env.setConfigProperty('CI_DEPLOY_ACCOUNT', 'trialuser123')
|
||||
jer.env.configuration = [:]
|
||||
nullScript.commonPipelineEnvironment.setConfigProperty('DEPLOY_HOST', 'test.deploy.host.com')
|
||||
nullScript.commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'trialuser123')
|
||||
nullScript.commonPipelineEnvironment.configuration = [:]
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: archiveName,
|
||||
neoCredentialsId: 'myCredentialsId'
|
||||
)
|
||||
@ -108,7 +102,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
@Test
|
||||
void straightForwardTestConfigViaConfiguration() {
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: archiveName,
|
||||
neoCredentialsId: 'myCredentialsId'
|
||||
)
|
||||
@ -119,13 +113,13 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
@Test
|
||||
void straightForwardTestConfigViaConfigurationAndViaConfigProperties() {
|
||||
|
||||
jer.env.setConfigProperty('DEPLOY_HOST', 'configProperties.deploy.host.com')
|
||||
jer.env.setConfigProperty('CI_DEPLOY_ACCOUNT', 'configPropsUser123')
|
||||
nullScript.commonPipelineEnvironment.setConfigProperty('DEPLOY_HOST', 'configProperties.deploy.host.com')
|
||||
nullScript.commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'configPropsUser123')
|
||||
|
||||
jer.env.configuration = [steps:[neoDeploy: [host: 'configuration-frwk.deploy.host.com',
|
||||
nullScript.commonPipelineEnvironment.configuration = [steps:[neoDeploy: [host: 'configuration-frwk.deploy.host.com',
|
||||
account: 'configurationFrwkUser123']]]
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: archiveName,
|
||||
neoCredentialsId: 'myCredentialsId'
|
||||
)
|
||||
@ -140,7 +134,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
thrown.expect(MissingPropertyException)
|
||||
thrown.expectMessage('No such property: username')
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: archiveName,
|
||||
neoCredentialsId: 'badCredentialsId'
|
||||
)
|
||||
@ -150,7 +144,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
@Test
|
||||
void credentialsIdNotProvidedTest() {
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: archiveName
|
||||
)
|
||||
|
||||
@ -163,7 +157,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
|
||||
helper.registerAllowedMethod('sh', [Map], { Map m -> getVersionWithPath(m) })
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: archiveName
|
||||
)
|
||||
|
||||
@ -178,7 +172,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
|
||||
helper.registerAllowedMethod('sh', [Map], { Map m -> getVersionWithPath(m) })
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: archiveName,
|
||||
neoCredentialsId: 'myCredentialsId',
|
||||
neoHome: '/param/neo'
|
||||
@ -193,7 +187,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
@Test
|
||||
void neoHomeFromEnvironmentTest() {
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: archiveName
|
||||
)
|
||||
|
||||
@ -208,9 +202,9 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
|
||||
helper.registerAllowedMethod('sh', [Map], { Map m -> getVersionWithPath(m) })
|
||||
|
||||
jer.env.configuration = [steps:[neoDeploy: [host: 'test.deploy.host.com', account: 'trialuser123', neoHome: '/config/neo']]]
|
||||
nullScript.commonPipelineEnvironment.configuration = [steps:[neoDeploy: [host: 'test.deploy.host.com', account: 'trialuser123', neoHome: '/config/neo']]]
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: archiveName
|
||||
)
|
||||
|
||||
@ -226,7 +220,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
thrown.expect(Exception)
|
||||
thrown.expectMessage('Archive path not configured (parameter "archivePath").')
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env])
|
||||
jsr.step.call(script: nullScript)
|
||||
}
|
||||
|
||||
|
||||
@ -236,7 +230,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage('Archive cannot be found')
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: 'wrongArchiveName')
|
||||
}
|
||||
|
||||
@ -247,7 +241,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
thrown.expect(Exception)
|
||||
thrown.expectMessage('ERROR - NO VALUE AVAILABLE FOR host')
|
||||
|
||||
jer.env.configuration = [:]
|
||||
nullScript.commonPipelineEnvironment.configuration = [:]
|
||||
|
||||
jsr.step.call(archivePath: archiveName)
|
||||
}
|
||||
@ -255,7 +249,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
@Test
|
||||
void mtaDeployModeTest() {
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env], archivePath: archiveName, deployMode: 'mta')
|
||||
jsr.step.call(script: nullScript, archivePath: archiveName, deployMode: 'mta')
|
||||
|
||||
assert jscr.shell.find { c -> c =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy-mta --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*"/}
|
||||
}
|
||||
@ -263,7 +257,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
@Test
|
||||
void warFileParamsDeployModeTest() {
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
applicationName: 'testApp',
|
||||
runtime: 'neo-javaee6-wp',
|
||||
runtimeVersion: '2.125',
|
||||
@ -278,7 +272,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
@Test
|
||||
void warFileParamsDeployModeRollingUpdateTest() {
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: warArchiveName,
|
||||
deployMode: 'warParams',
|
||||
applicationName: 'testApp',
|
||||
@ -293,7 +287,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
@Test
|
||||
void warPropertiesFileDeployModeTest() {
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: warArchiveName,
|
||||
deployMode: 'warPropertiesFile',
|
||||
propertiesFile: propertiesFileName,
|
||||
@ -309,7 +303,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
@Test
|
||||
void warPropertiesFileDeployModeRollingUpdateTest() {
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: warArchiveName,
|
||||
deployMode: 'warPropertiesFile',
|
||||
propertiesFile: propertiesFileName,
|
||||
@ -328,7 +322,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
thrown.expect(Exception)
|
||||
thrown.expectMessage('ERROR - NO VALUE AVAILABLE FOR applicationName')
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: warArchiveName,
|
||||
deployMode: 'warParams',
|
||||
runtime: 'neo-javaee6-wp',
|
||||
@ -342,7 +336,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
thrown.expect(Exception)
|
||||
thrown.expectMessage('ERROR - NO VALUE AVAILABLE FOR runtime')
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: warArchiveName,
|
||||
applicationName: 'testApp',
|
||||
deployMode: 'warParams',
|
||||
@ -355,7 +349,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
thrown.expect(Exception)
|
||||
thrown.expectMessage('ERROR - NO VALUE AVAILABLE FOR runtimeVersion')
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: warArchiveName,
|
||||
applicationName: 'testApp',
|
||||
deployMode: 'warParams',
|
||||
@ -368,7 +362,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
thrown.expect(Exception)
|
||||
thrown.expectMessage("[neoDeploy] Invalid deployMode = 'illegalMode'. Valid 'deployMode' values are: [mta, warParams, warPropertiesFile]")
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: warArchiveName,
|
||||
deployMode: 'illegalMode',
|
||||
applicationName: 'testApp',
|
||||
@ -384,7 +378,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
thrown.expect(Exception)
|
||||
thrown.expectMessage("[neoDeploy] Invalid vmSize = 'illegalVM'. Valid 'vmSize' values are: [lite, pro, prem, prem-plus].")
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: warArchiveName,
|
||||
deployMode: 'warParams',
|
||||
applicationName: 'testApp',
|
||||
@ -400,7 +394,7 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
thrown.expect(Exception)
|
||||
thrown.expectMessage("[neoDeploy] Invalid warAction = 'illegalWARAction'. Valid 'warAction' values are: [deploy, rolling-update].")
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: warArchiveName,
|
||||
deployMode: 'warParams',
|
||||
applicationName: 'testApp',
|
||||
@ -413,9 +407,9 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
@Test
|
||||
void deployHostProvidedAsDeprecatedParameterTest() {
|
||||
|
||||
jer.env.setConfigProperty('CI_DEPLOY_ACCOUNT', 'configPropsUser123')
|
||||
nullScript.commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'configPropsUser123')
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: archiveName,
|
||||
deployHost: "my.deploy.host.com"
|
||||
)
|
||||
@ -426,9 +420,9 @@ class NeoDeployTest extends BasePipelineTest {
|
||||
@Test
|
||||
void deployAccountProvidedAsDeprecatedParameterTest() {
|
||||
|
||||
jer.env.setConfigProperty('CI_DEPLOY_ACCOUNT', 'configPropsUser123')
|
||||
nullScript.commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'configPropsUser123')
|
||||
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env],
|
||||
jsr.step.call(script: nullScript,
|
||||
archivePath: archiveName,
|
||||
host: "my.deploy.host.com",
|
||||
deployAccount: "myAccount"
|
||||
|
@ -1,17 +1,15 @@
|
||||
import util.BasePiperTest
|
||||
import util.Rules
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.rules.RuleChain
|
||||
|
||||
import util.JenkinsReadYamlRule
|
||||
import util.JenkinsStepRule
|
||||
|
||||
class PipelineExecuteTest extends BasePipelineTest {
|
||||
class PipelineExecuteTest extends BasePiperTest {
|
||||
private ExpectedException thrown = new ExpectedException().none()
|
||||
private JenkinsStepRule jsr = new JenkinsStepRule(this)
|
||||
|
||||
|
@ -31,9 +31,8 @@ class PipelineStashFilesAfterBuildTest extends BasePiperTest {
|
||||
)
|
||||
// asserts
|
||||
assertFalse(jlr.log.contains('Stash content: checkmarx'))
|
||||
assertThat(jlr.log, containsString('Stash content: classFiles (include: **/target/classes/**/*.class, **/target/test-classes/**/*.class, exclude: )'))
|
||||
assertThat(jlr.log, containsString('Stash content: sonar (include: **/jacoco*.exec, **/sonar-project.properties, exclude: )'))
|
||||
assertFalse(jlr.log.contains('Stash content: postStagedFiles'))
|
||||
assertThat(jlr.log, containsString('Stash content: classFiles'))
|
||||
assertThat(jlr.log, containsString('Stash content: sonar'))
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -48,9 +47,9 @@ class PipelineStashFilesAfterBuildTest extends BasePiperTest {
|
||||
runCheckmarx: true
|
||||
)
|
||||
// asserts
|
||||
assertThat(jlr.log, containsString('Stash content: checkmarx (include: **/*.js, **/*.scala, **/*.py, **/*.go, **/*.xml, **/*.html, exclude: **/*.mockserver.js, node_modules/**/*.js)'))
|
||||
assertThat(jlr.log, containsString('Stash content: classFiles (include: **/target/classes/**/*.class, **/target/test-classes/**/*.class, exclude: )'))
|
||||
assertThat(jlr.log, containsString('Stash content: sonar (include: **/jacoco*.exec, **/sonar-project.properties, exclude: )'))
|
||||
assertThat(jlr.log, containsString('Stash content: checkmarx'))
|
||||
assertThat(jlr.log, containsString('Stash content: classFiles'))
|
||||
assertThat(jlr.log, containsString('Stash content: sonar'))
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -64,9 +63,9 @@ class PipelineStashFilesAfterBuildTest extends BasePiperTest {
|
||||
juStabUtils: utils,
|
||||
)
|
||||
// asserts
|
||||
assertThat(jlr.log, containsString('Stash content: checkmarx (include: **/*.js, **/*.scala, **/*.py, **/*.go, **/*.xml, **/*.html, exclude: **/*.mockserver.js, node_modules/**/*.js)'))
|
||||
assertThat(jlr.log, containsString('Stash content: classFiles (include: **/target/classes/**/*.class, **/target/test-classes/**/*.class, exclude: )'))
|
||||
assertThat(jlr.log, containsString('Stash content: sonar (include: **/jacoco*.exec, **/sonar-project.properties, exclude: )'))
|
||||
assertThat(jlr.log, containsString('Stash content: checkmarx'))
|
||||
assertThat(jlr.log, containsString('Stash content: classFiles'))
|
||||
assertThat(jlr.log, containsString('Stash content: sonar'))
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,15 +29,15 @@ class PipelineStashFilesBeforeBuildTest extends BasePiperTest {
|
||||
assertEquals('mkdir -p gitmetadata', jscr.shell[0])
|
||||
assertEquals('cp -rf .git/* gitmetadata', jscr.shell[1])
|
||||
assertEquals('chmod -R u+w gitmetadata', jscr.shell[2])
|
||||
|
||||
assertThat(jlr.log, containsString('Stash content: buildDescriptor'))
|
||||
assertThat(jlr.log, containsString('Stash content: deployDescriptor'))
|
||||
assertThat(jlr.log, containsString('Stash content: git'))
|
||||
assertFalse(jlr.log.contains('Stash content: opa5'))
|
||||
assertThat(jlr.log, containsString('Stash content: git (include: **/gitmetadata/**, exclude: )'))
|
||||
assertThat(jlr.log, containsString('Stash content: tests (include: **/pom.xml, **/*.json, **/*.xml, **/src/**, **/node_modules/**, **/specs/**, **/env/**, **/*.js, exclude: )'))
|
||||
assertThat(jlr.log, containsString('Stash content: buildDescriptor (include: **/pom.xml, **/.mvn/**, **/assembly.xml, **/.swagger-codegen-ignore, **/package.json, **/requirements.txt, **/setup.py, **/whitesource_config.py, **/mta*.y*ml, **/.npmrc, **/whitesource.*.json, **/whitesource-fs-agent.config, .xmake.cfg, Dockerfile, **/VERSION, **/version.txt, **/build.sbt, **/sbtDescriptor.json, **/project/*, exclude: **/node_modules/**/package.json)'))
|
||||
assertThat(jlr.log, containsString('Stash content: deployDescriptor (include: **/manifest*.y*ml, **/*.mtaext.y*ml, **/*.mtaext, **/xs-app.json, helm/**, *.y*ml, exclude: )'))
|
||||
assertThat(jlr.log, containsString('Stash content: opensource configuration (include: **/srcclr.yml'))
|
||||
assertThat(jlr.log, containsString('Stash content: snyk configuration (include: **/.snyk'))
|
||||
assertThat(jlr.log, containsString('Stash content: pipelineConfigAndTests (include: .pipeline/*.*'))
|
||||
assertThat(jlr.log, containsString('Stash content: securityDescriptor (include: **/xs-security.json'))
|
||||
assertThat(jlr.log, containsString('Stash content: opensourceConfiguration'))
|
||||
assertThat(jlr.log, containsString('Stash content: pipelineConfigAndTests'))
|
||||
assertThat(jlr.log, containsString('Stash content: securityDescriptor'))
|
||||
assertThat(jlr.log, containsString('Stash content: tests'))
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -46,31 +46,13 @@ class PipelineStashFilesBeforeBuildTest extends BasePiperTest {
|
||||
jsr.step.call(script: nullScript, juStabUtils: utils, runOpaTests: true)
|
||||
|
||||
// asserts
|
||||
assertThat(jlr.log, containsString('Stash content: opa5'))
|
||||
assertThat(jlr.log, containsString('Stash content: git'))
|
||||
assertThat(jlr.log, containsString('Stash content: tests'))
|
||||
assertThat(jlr.log, containsString('Stash content: buildDescriptor'))
|
||||
assertThat(jlr.log, containsString('Stash content: deployDescriptor'))
|
||||
assertThat(jlr.log, containsString('Stash content: opensource configuration'))
|
||||
assertThat(jlr.log, containsString('Stash content: snyk configuration'))
|
||||
assertThat(jlr.log, containsString('Stash content: pipelineConfigAndTests'))
|
||||
assertThat(jlr.log, containsString('Stash content: securityDescriptor'))
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStashBeforeBuildOpaCompatibility() {
|
||||
|
||||
jsr.step.call(script: nullScript, juStabUtils: utils, runOpaTests: 'true')
|
||||
|
||||
// asserts
|
||||
assertThat(jlr.log, containsString('Stash content: opa5'))
|
||||
assertThat(jlr.log, containsString('Stash content: git'))
|
||||
assertThat(jlr.log, containsString('Stash content: tests'))
|
||||
assertThat(jlr.log, containsString('Stash content: buildDescriptor'))
|
||||
assertThat(jlr.log, containsString('Stash content: deployDescriptor'))
|
||||
assertThat(jlr.log, containsString('Stash content: opensource configuration'))
|
||||
assertThat(jlr.log, containsString('Stash content: snyk configuration'))
|
||||
assertThat(jlr.log, containsString('Stash content: opa5'))
|
||||
assertThat(jlr.log, containsString('Stash content: opensourceConfiguration'))
|
||||
assertThat(jlr.log, containsString('Stash content: pipelineConfigAndTests'))
|
||||
assertThat(jlr.log, containsString('Stash content: securityDescriptor'))
|
||||
assertThat(jlr.log, containsString('Stash content: tests'))
|
||||
}
|
||||
}
|
||||
|
@ -4,26 +4,22 @@ import org.junit.Test
|
||||
import org.junit.rules.RuleChain
|
||||
import org.yaml.snakeyaml.Yaml
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
|
||||
import util.BasePiperTest
|
||||
import util.Rules
|
||||
import util.JenkinsStepRule
|
||||
import util.JenkinsEnvironmentRule
|
||||
|
||||
import static org.junit.Assert.assertEquals
|
||||
import static org.junit.Assert.assertNotNull
|
||||
|
||||
class SetupCommonPipelineEnvironmentTest extends BasePipelineTest {
|
||||
class SetupCommonPipelineEnvironmentTest extends BasePiperTest {
|
||||
def usedConfigFile
|
||||
|
||||
private JenkinsStepRule jsr = new JenkinsStepRule(this)
|
||||
private JenkinsEnvironmentRule jer = new JenkinsEnvironmentRule(this)
|
||||
|
||||
@Rule
|
||||
public RuleChain rules = Rules
|
||||
.getCommonRules(this)
|
||||
.around(jsr)
|
||||
.around(jer)
|
||||
|
||||
@Before
|
||||
void init() {
|
||||
@ -44,11 +40,11 @@ class SetupCommonPipelineEnvironmentTest extends BasePipelineTest {
|
||||
|
||||
@Test
|
||||
void testIsConfigurationAvailable() throws Exception {
|
||||
jsr.step.call(script: [commonPipelineEnvironment: jer.env])
|
||||
jsr.step.call(script: nullScript)
|
||||
|
||||
assertEquals('.pipeline/config.yml', usedConfigFile)
|
||||
assertNotNull(jer.env.configuration)
|
||||
assertEquals('develop', jer.env.configuration.general.productiveBranch)
|
||||
assertEquals('my-maven-docker', jer.env.configuration.steps.mavenExecute.dockerImage)
|
||||
assertNotNull(nullScript.commonPipelineEnvironment.configuration)
|
||||
assertEquals('develop', nullScript.commonPipelineEnvironment.configuration.general.productiveBranch)
|
||||
assertEquals('my-maven-docker', nullScript.commonPipelineEnvironment.configuration.steps.mavenExecute.dockerImage)
|
||||
}
|
||||
}
|
||||
|
@ -4,28 +4,30 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.RuleChain
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
import util.BasePiperTest
|
||||
import util.JenkinsStepRule
|
||||
|
||||
import static org.junit.Assert.assertEquals
|
||||
import static org.junit.Assert.assertTrue
|
||||
|
||||
import util.Rules
|
||||
|
||||
class TestsPublishResultsTest extends BasePipelineTest {
|
||||
class TestsPublishResultsTest extends BasePiperTest {
|
||||
Map publisherStepOptions
|
||||
List archiveStepPatterns
|
||||
|
||||
@Rule
|
||||
public RuleChain ruleChain = RuleChain.outerRule(Rules.getCommonRules(this))
|
||||
private JenkinsStepRule jsr = new JenkinsStepRule(this)
|
||||
|
||||
def testsPublishResultsScript
|
||||
@Rule
|
||||
public RuleChain ruleChain = Rules
|
||||
.getCommonRules(this)
|
||||
.around(jsr)
|
||||
|
||||
@Before
|
||||
void init() {
|
||||
publisherStepOptions = [:]
|
||||
archiveStepPatterns = []
|
||||
// prepare checkResultsPublish step
|
||||
testsPublishResultsScript = loadScript('testsPublishResults.groovy').testsPublishResults
|
||||
helper.registerAllowedMethod('junit', [Map.class], {
|
||||
parameters -> publisherStepOptions['junit'] = parameters
|
||||
})
|
||||
@ -45,7 +47,7 @@ class TestsPublishResultsTest extends BasePipelineTest {
|
||||
|
||||
@Test
|
||||
void testPublishNothingWithDefaultSettings() throws Exception {
|
||||
testsPublishResultsScript.call()
|
||||
jsr.step.testsPublishResults()
|
||||
|
||||
// ensure nothing is published
|
||||
assertTrue('WarningsPublisher options not empty', publisherStepOptions.junit == null)
|
||||
@ -56,7 +58,7 @@ class TestsPublishResultsTest extends BasePipelineTest {
|
||||
|
||||
@Test
|
||||
void testPublishNothingWithAllDisabled() throws Exception {
|
||||
testsPublishResultsScript.call(junit: false, jacoco: false, cobertura: false, jmeter: false)
|
||||
jsr.step.testsPublishResults(junit: false, jacoco: false, cobertura: false, jmeter: false)
|
||||
|
||||
// ensure nothing is published
|
||||
assertTrue('WarningsPublisher options not empty', publisherStepOptions.junit == null)
|
||||
@ -67,7 +69,7 @@ class TestsPublishResultsTest extends BasePipelineTest {
|
||||
|
||||
@Test
|
||||
void testPublishUnitTestsWithDefaultSettings() throws Exception {
|
||||
testsPublishResultsScript.call(junit: true)
|
||||
jsr.step.testsPublishResults(junit: true)
|
||||
|
||||
assertTrue('JUnit options are empty', publisherStepOptions.junit != null)
|
||||
// ensure default patterns are set
|
||||
@ -81,7 +83,7 @@ class TestsPublishResultsTest extends BasePipelineTest {
|
||||
|
||||
@Test
|
||||
void testPublishCoverageWithDefaultSettings() throws Exception {
|
||||
testsPublishResultsScript.call(jacoco: true, cobertura: true)
|
||||
jsr.step.testsPublishResults(jacoco: true, cobertura: true)
|
||||
|
||||
assertTrue('JaCoCo options are empty', publisherStepOptions.jacoco != null)
|
||||
assertTrue('Cobertura options are empty', publisherStepOptions.cobertura != null)
|
||||
@ -96,7 +98,7 @@ class TestsPublishResultsTest extends BasePipelineTest {
|
||||
|
||||
@Test
|
||||
void testPublishJMeterWithDefaultSettings() throws Exception {
|
||||
testsPublishResultsScript.call(jmeter: true)
|
||||
jsr.step.testsPublishResults(jmeter: true)
|
||||
|
||||
assertTrue('JMeter options are empty', publisherStepOptions.jmeter != null)
|
||||
assertEquals('JMeter default pattern not set',
|
||||
@ -110,7 +112,7 @@ class TestsPublishResultsTest extends BasePipelineTest {
|
||||
|
||||
@Test
|
||||
void testPublishUnitTestsWithCustomSettings() throws Exception {
|
||||
testsPublishResultsScript.call(junit: [pattern: 'fancy/file/path', archive: true, active: true])
|
||||
jsr.step.testsPublishResults(junit: [pattern: 'fancy/file/path', archive: true, active: true])
|
||||
|
||||
assertTrue('JUnit options are empty', publisherStepOptions.junit != null)
|
||||
// ensure default patterns are set
|
||||
|
@ -6,15 +6,13 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.rules.RuleChain
|
||||
import org.junit.rules.TemporaryFolder
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
|
||||
import util.BasePiperTest
|
||||
import util.JenkinsLoggingRule
|
||||
import util.JenkinsStepRule
|
||||
import util.Rules
|
||||
|
||||
class ToolValidateTest extends BasePipelineTest {
|
||||
class ToolValidateTest extends BasePiperTest {
|
||||
|
||||
private ExpectedException thrown = new ExpectedException().none()
|
||||
private JenkinsLoggingRule jlr = new JenkinsLoggingRule(this)
|
||||
@ -122,8 +120,6 @@ class ToolValidateTest extends BasePipelineTest {
|
||||
helper.registerAllowedMethod('sh', [Map], { Map m -> getNoVersion(m) })
|
||||
|
||||
jsr.step.call(tool: 'cm', home: home)
|
||||
|
||||
script.execute()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -5,32 +5,21 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.rules.RuleChain
|
||||
|
||||
import util.BasePiperTest
|
||||
import util.JenkinsStepRule
|
||||
import util.Rules
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
|
||||
import com.sap.piper.EnvironmentUtils
|
||||
|
||||
import hudson.AbortException
|
||||
|
||||
|
||||
class EnvironmentUtilsTest extends BasePipelineTest {
|
||||
class EnvironmentUtilsTest extends BasePiperTest {
|
||||
|
||||
private ExpectedException thrown = new ExpectedException()
|
||||
|
||||
@Rule
|
||||
public RuleChain rules = Rules.getCommonRules(this)
|
||||
.around(thrown)
|
||||
|
||||
private script
|
||||
|
||||
|
||||
@Before
|
||||
void setup() {
|
||||
|
||||
script = loadScript('commonPipelineEnvironment.groovy').commonPipelineEnvironment
|
||||
}
|
||||
public RuleChain rules = Rules
|
||||
.getCommonRules(this)
|
||||
.around(thrown)
|
||||
|
||||
@Test
|
||||
void isEnvironmentVariableFailedTest() {
|
||||
@ -40,7 +29,7 @@ class EnvironmentUtilsTest extends BasePipelineTest {
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("There was an error requesting the environment variable 'JAVA_HOME'.")
|
||||
|
||||
EnvironmentUtils.isEnvironmentVariable(script, 'JAVA_HOME')
|
||||
EnvironmentUtils.isEnvironmentVariable(nullScript, 'JAVA_HOME')
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -48,7 +37,7 @@ class EnvironmentUtilsTest extends BasePipelineTest {
|
||||
|
||||
helper.registerAllowedMethod('sh', [Map], { Map m -> return '' })
|
||||
|
||||
def isEnvVar = EnvironmentUtils.isEnvironmentVariable(script, 'JAVA_HOME')
|
||||
def isEnvVar = EnvironmentUtils.isEnvironmentVariable(nullScript, 'JAVA_HOME')
|
||||
|
||||
assert isEnvVar == false
|
||||
}
|
||||
@ -58,7 +47,7 @@ class EnvironmentUtilsTest extends BasePipelineTest {
|
||||
|
||||
helper.registerAllowedMethod('sh', [Map], { Map m -> return '/env/java' })
|
||||
|
||||
def isEnvVar = EnvironmentUtils.isEnvironmentVariable(script, 'JAVA_HOME')
|
||||
def isEnvVar = EnvironmentUtils.isEnvironmentVariable(nullScript, 'JAVA_HOME')
|
||||
|
||||
assert isEnvVar == true
|
||||
}
|
||||
@ -71,7 +60,7 @@ class EnvironmentUtilsTest extends BasePipelineTest {
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("There was an error requesting the environment variable 'JAVA_HOME'.")
|
||||
|
||||
EnvironmentUtils.getEnvironmentVariable(script, 'JAVA_HOME')
|
||||
EnvironmentUtils.getEnvironmentVariable(nullScript, 'JAVA_HOME')
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -79,7 +68,7 @@ class EnvironmentUtilsTest extends BasePipelineTest {
|
||||
|
||||
helper.registerAllowedMethod('sh', [Map], { Map m -> return '/env/java' })
|
||||
|
||||
def envVar = EnvironmentUtils.getEnvironmentVariable(script, 'JAVA_HOME')
|
||||
def envVar = EnvironmentUtils.getEnvironmentVariable(nullScript, 'JAVA_HOME')
|
||||
|
||||
assert envVar == '/env/java'
|
||||
}
|
||||
|
@ -8,17 +8,13 @@ import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import org.junit.rules.RuleChain
|
||||
|
||||
import util.BasePiperTest
|
||||
import util.Rules
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
|
||||
import com.sap.piper.FileUtils
|
||||
|
||||
import hudson.AbortException
|
||||
|
||||
|
||||
class FileUtilsTest extends BasePipelineTest {
|
||||
class FileUtilsTest extends BasePiperTest {
|
||||
|
||||
@ClassRule
|
||||
public static TemporaryFolder tmp = new TemporaryFolder()
|
||||
@ -33,8 +29,6 @@ class FileUtilsTest extends BasePipelineTest {
|
||||
private static notEmptyDir
|
||||
private static file
|
||||
|
||||
private static script
|
||||
|
||||
@BeforeClass
|
||||
static void createTestFiles() {
|
||||
|
||||
@ -43,20 +37,13 @@ class FileUtilsTest extends BasePipelineTest {
|
||||
file = tmp.newFile('notEmptyDir/file.txt').getAbsolutePath()
|
||||
}
|
||||
|
||||
@Before
|
||||
void setup() {
|
||||
|
||||
script = loadScript('commonPipelineEnvironment.groovy').commonPipelineEnvironment
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void validateDirectory_nullParameterTest() {
|
||||
|
||||
thrown.expect(IllegalArgumentException)
|
||||
thrown.expectMessage("The parameter 'dir' can not be null or empty.")
|
||||
|
||||
FileUtils.validateDirectory(script, null)
|
||||
FileUtils.validateDirectory(nullScript, null)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -65,7 +52,7 @@ class FileUtilsTest extends BasePipelineTest {
|
||||
thrown.expect(IllegalArgumentException)
|
||||
thrown.expectMessage("The parameter 'dir' can not be null or empty.")
|
||||
|
||||
FileUtils.validateDirectory(script, '')
|
||||
FileUtils.validateDirectory(nullScript, '')
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -78,7 +65,7 @@ class FileUtilsTest extends BasePipelineTest {
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("Validation failed. '$dir' does not exist.")
|
||||
|
||||
FileUtils.validateDirectory(script, dir)
|
||||
FileUtils.validateDirectory(nullScript, dir)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -89,7 +76,7 @@ class FileUtilsTest extends BasePipelineTest {
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("Validation failed. '$file' is not a directory.")
|
||||
|
||||
FileUtils.validateDirectory(script, file)
|
||||
FileUtils.validateDirectory(nullScript, file)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -97,7 +84,7 @@ class FileUtilsTest extends BasePipelineTest {
|
||||
|
||||
helper.registerAllowedMethod('sh', [Map], { Map m -> script(m, notEmptyDir) })
|
||||
|
||||
FileUtils.validateDirectory(script, notEmptyDir)
|
||||
FileUtils.validateDirectory(nullScript, notEmptyDir)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -108,7 +95,7 @@ class FileUtilsTest extends BasePipelineTest {
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("Validation failed. '$emptyDir' is empty.")
|
||||
|
||||
FileUtils.validateDirectoryIsNotEmpty(script, emptyDir)
|
||||
FileUtils.validateDirectoryIsNotEmpty(nullScript, emptyDir)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -116,7 +103,7 @@ class FileUtilsTest extends BasePipelineTest {
|
||||
|
||||
helper.registerAllowedMethod('sh', [Map], { Map m -> script(m, notEmptyDir) })
|
||||
|
||||
FileUtils.validateDirectoryIsNotEmpty(script, notEmptyDir)
|
||||
FileUtils.validateDirectoryIsNotEmpty(nullScript, notEmptyDir)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -125,7 +112,7 @@ class FileUtilsTest extends BasePipelineTest {
|
||||
thrown.expect(IllegalArgumentException)
|
||||
thrown.expectMessage("The parameter 'filePath' can not be null or empty.")
|
||||
|
||||
FileUtils.validateFile(script, null)
|
||||
FileUtils.validateFile(nullScript, null)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -134,7 +121,7 @@ class FileUtilsTest extends BasePipelineTest {
|
||||
thrown.expect(IllegalArgumentException)
|
||||
thrown.expectMessage("The parameter 'filePath' can not be null or empty.")
|
||||
|
||||
FileUtils.validateFile(script, '')
|
||||
FileUtils.validateFile(nullScript, '')
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -147,7 +134,7 @@ class FileUtilsTest extends BasePipelineTest {
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("Validation failed. '$path' does not exist.")
|
||||
|
||||
FileUtils.validateFile(script, path)
|
||||
FileUtils.validateFile(nullScript, path)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -155,7 +142,7 @@ class FileUtilsTest extends BasePipelineTest {
|
||||
|
||||
helper.registerAllowedMethod('sh', [Map], { Map m -> script(m, file) })
|
||||
|
||||
FileUtils.validateFile(script, file)
|
||||
FileUtils.validateFile(nullScript, file)
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,19 +1,18 @@
|
||||
package com.sap.piper
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
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.JenkinsShellCallRule
|
||||
import util.MockHelper
|
||||
import util.Rules
|
||||
|
||||
import static org.junit.Assert.assertEquals
|
||||
import static org.junit.Assert.assertNull
|
||||
|
||||
class GitUtilsTest extends BasePipelineTest {
|
||||
class GitUtilsTest extends BasePiperTest {
|
||||
|
||||
JenkinsShellCallRule jscr = new JenkinsShellCallRule(this)
|
||||
ExpectedException thrown = ExpectedException.none()
|
||||
@ -21,22 +20,11 @@ class GitUtilsTest extends BasePipelineTest {
|
||||
@Rule
|
||||
public RuleChain ruleChain = Rules.getCommonRules(this).around(jscr).around(thrown)
|
||||
|
||||
GitUtils gitUtils
|
||||
|
||||
@Before
|
||||
void init() throws Exception {
|
||||
gitUtils = new GitUtils()
|
||||
prepareObjectInterceptors(gitUtils)
|
||||
|
||||
jscr.setReturnValue('git rev-parse HEAD', 'testCommitId')
|
||||
}
|
||||
|
||||
void prepareObjectInterceptors(object) {
|
||||
object.metaClass.invokeMethod = helper.getMethodInterceptor()
|
||||
object.metaClass.static.invokeMethod = helper.getMethodInterceptor()
|
||||
object.metaClass.methodMissing = helper.getMethodMissingInterceptor()
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetGitCommitId() {
|
||||
jscr.setReturnValue('git rev-parse --is-inside-work-tree 1>/dev/null 2>&1', 0)
|
||||
|
@ -9,15 +9,13 @@ import org.junit.rules.RuleChain
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import org.yaml.snakeyaml.Yaml
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
|
||||
import groovy.json.JsonSlurper
|
||||
import hudson.AbortException
|
||||
import util.JenkinsEnvironmentRule
|
||||
import util.BasePiperTest
|
||||
import util.Rules
|
||||
|
||||
|
||||
class MtaUtilsTest extends BasePipelineTest {
|
||||
class MtaUtilsTest extends BasePiperTest {
|
||||
private static srcPackageJson = 'test/resources/MtaUtils/package.json'
|
||||
private static mtaTemplate = 'resources/template_mta.yml'
|
||||
private static data
|
||||
@ -26,26 +24,15 @@ class MtaUtilsTest extends BasePipelineTest {
|
||||
private File badJson
|
||||
private mtaUtils
|
||||
|
||||
@Rule
|
||||
public JenkinsEnvironmentRule jer = new JenkinsEnvironmentRule(this)
|
||||
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown= ExpectedException.none();
|
||||
private ExpectedException thrown= ExpectedException.none();
|
||||
|
||||
@ClassRule
|
||||
public static TemporaryFolder tmp = new TemporaryFolder()
|
||||
|
||||
@Rule
|
||||
public RuleChain ruleChain = Rules
|
||||
.getCommonRules(this)
|
||||
.around(jer)
|
||||
|
||||
void prepareObjectInterceptors(object) {
|
||||
object.metaClass.invokeMethod = helper.getMethodInterceptor()
|
||||
object.metaClass.static.invokeMethod = helper.getMethodInterceptor()
|
||||
object.metaClass.methodMissing = helper.getMethodMissingInterceptor()
|
||||
}
|
||||
.getCommonRules(this)
|
||||
.around(thrown)
|
||||
|
||||
@Before
|
||||
void init() {
|
||||
|
@ -7,20 +7,13 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.rules.RuleChain
|
||||
|
||||
import util.BasePiperTest
|
||||
import util.JenkinsLoggingRule
|
||||
import util.JenkinsErrorRule
|
||||
import util.Rules
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
|
||||
import com.sap.piper.tools.ToolDescriptor
|
||||
import com.sap.piper.tools.JavaArchiveDescriptor
|
||||
|
||||
import hudson.AbortException
|
||||
|
||||
|
||||
class JavaArchiveDescriptorTest extends BasePipelineTest {
|
||||
class JavaArchiveDescriptorTest extends BasePiperTest {
|
||||
|
||||
private ExpectedException thrown = new ExpectedException()
|
||||
private JenkinsLoggingRule jlr = new JenkinsLoggingRule(this)
|
||||
|
@ -6,18 +6,13 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.rules.RuleChain
|
||||
|
||||
import util.BasePiperTest
|
||||
import util.JenkinsLoggingRule
|
||||
import util.Rules
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
|
||||
import com.sap.piper.tools.ToolDescriptor
|
||||
|
||||
import hudson.AbortException
|
||||
|
||||
|
||||
class ToolDescriptorTest extends BasePipelineTest {
|
||||
class ToolDescriptorTest extends BasePiperTest {
|
||||
|
||||
private ExpectedException thrown = new ExpectedException()
|
||||
private JenkinsLoggingRule jlr = new JenkinsLoggingRule(this)
|
||||
|
@ -1,22 +1,20 @@
|
||||
package com.sap.piper.versioning
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
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.JenkinsLoggingRule
|
||||
import util.JenkinsReadFileRule
|
||||
import util.JenkinsReadMavenPomRule
|
||||
import util.JenkinsShellCallRule
|
||||
import util.JenkinsWriteFileRule
|
||||
import util.Rules
|
||||
|
||||
import static org.junit.Assert.assertEquals
|
||||
import static org.junit.Assert.assertTrue
|
||||
|
||||
class DockerArtifactVersioningTest extends BasePipelineTest{
|
||||
class DockerArtifactVersioningTest extends BasePiperTest{
|
||||
|
||||
DockerArtifactVersioning av
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
package com.sap.piper.versioning
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
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.JenkinsReadMavenPomRule
|
||||
@ -16,7 +14,6 @@ import static org.junit.Assert.assertEquals
|
||||
class MavenArtifactVersioningTest extends BasePiperTest{
|
||||
|
||||
Map dockerParameters
|
||||
def mavenExecuteScript
|
||||
def commonPipelineEnvironment
|
||||
|
||||
MavenArtifactVersioning av
|
||||
@ -45,7 +42,7 @@ class MavenArtifactVersioningTest extends BasePiperTest{
|
||||
av = new MavenArtifactVersioning(nullScript, [filePath: 'pom.xml'])
|
||||
assertEquals('1.2.3', av.getVersion())
|
||||
av.setVersion('1.2.3-20180101')
|
||||
assertEquals('mvn --file \'pom.xml\' versions:set -DnewVersion=1.2.3-20180101', jscr.shell[0])
|
||||
assertEquals('mvn --file \'pom.xml\' --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn versions:set -DnewVersion=1.2.3-20180101', jscr.shell[0])
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -53,6 +50,6 @@ class MavenArtifactVersioningTest extends BasePiperTest{
|
||||
av = new MavenArtifactVersioning(nullScript, [filePath: 'snapshot/pom.xml'])
|
||||
assertEquals('1.2.3', av.getVersion())
|
||||
av.setVersion('1.2.3-20180101')
|
||||
assertEquals('mvn --file \'snapshot/pom.xml\' versions:set -DnewVersion=1.2.3-20180101', jscr.shell[0])
|
||||
assertEquals('mvn --file \'snapshot/pom.xml\' --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn versions:set -DnewVersion=1.2.3-20180101', jscr.shell[0])
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
package util
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
import com.sap.piper.GitUtils
|
||||
import com.sap.piper.Utils
|
||||
import org.junit.Before
|
||||
import org.junit.runner.RunWith
|
||||
@ -22,6 +23,9 @@ abstract class BasePiperTest extends BasePipelineTest {
|
||||
@Autowired
|
||||
Script nullScript
|
||||
|
||||
@Autowired
|
||||
GitUtils gitUtils
|
||||
|
||||
@Autowired
|
||||
Utils utils
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
package util
|
||||
|
||||
import com.sap.piper.GitUtils
|
||||
import com.sap.piper.Utils
|
||||
import org.codehaus.groovy.runtime.InvokerHelper
|
||||
import org.springframework.context.annotation.Bean
|
||||
@ -18,6 +19,13 @@ class BasePiperTestContext {
|
||||
return nullScript
|
||||
}
|
||||
|
||||
@Bean
|
||||
GitUtils mockGitUtils() {
|
||||
def mockGitUtils = new GitUtils()
|
||||
LibraryLoadingTestExecutionListener.prepareObjectInterceptors(mockGitUtils)
|
||||
return mockGitUtils
|
||||
}
|
||||
|
||||
@Bean
|
||||
Utils mockUtils() {
|
||||
def mockUtils = new Utils()
|
||||
|
37
test/groovy/util/JenkinsDockerExecuteRule.groovy
Normal file
37
test/groovy/util/JenkinsDockerExecuteRule.groovy
Normal file
@ -0,0 +1,37 @@
|
||||
package util
|
||||
|
||||
import com.lesfurets.jenkins.unit.BasePipelineTest
|
||||
import org.junit.rules.TestRule
|
||||
import org.junit.runner.Description
|
||||
import org.junit.runners.model.Statement
|
||||
|
||||
class JenkinsDockerExecuteRule implements TestRule {
|
||||
|
||||
final BasePipelineTest testInstance
|
||||
|
||||
def dockerParams = [:]
|
||||
|
||||
JenkinsDockerExecuteRule(BasePipelineTest testInstance) {
|
||||
this.testInstance = testInstance
|
||||
}
|
||||
|
||||
@Override
|
||||
Statement apply(Statement base, Description description) {
|
||||
return statement(base)
|
||||
}
|
||||
|
||||
private Statement statement(final Statement base) {
|
||||
return new Statement() {
|
||||
@Override
|
||||
void evaluate() throws Throwable {
|
||||
|
||||
testInstance.helper.registerAllowedMethod("dockerExecute", [Map.class, Closure.class], {map, closure ->
|
||||
dockerParams = map
|
||||
return closure()
|
||||
})
|
||||
|
||||
base.evaluate()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
import com.sap.piper.ConfigurationLoader
|
||||
import com.sap.piper.ConfigurationMerger
|
||||
|
||||
def call(Map parameters = [:]) {
|
||||
@ -17,7 +16,8 @@ def call(Map parameters = [:]) {
|
||||
'flags',
|
||||
'goals',
|
||||
'm2Path',
|
||||
'defines'
|
||||
'defines',
|
||||
'logSuccessfulMavenTransfers'
|
||||
]
|
||||
Set stepConfigurationKeys = [
|
||||
'dockerImage',
|
||||
@ -66,6 +66,19 @@ def call(Map parameters = [:]) {
|
||||
command += " ${mavenFlags}"
|
||||
}
|
||||
|
||||
// Always use Maven's batch mode
|
||||
if (!(command.contains('-B') || command.contains('--batch-mode'))){
|
||||
command += ' --batch-mode'
|
||||
}
|
||||
|
||||
// Disable log for successful transfers by default. Note this requires the batch-mode flag.
|
||||
final String disableSuccessfulMavenTransfersLogFlag = ' -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
|
||||
if (!configuration.logSuccessfulMavenTransfers) {
|
||||
if (!command.contains(disableSuccessfulMavenTransfersLogFlag)) {
|
||||
command += disableSuccessfulMavenTransfersLogFlag
|
||||
}
|
||||
}
|
||||
|
||||
def mavenGoals = configuration.goals
|
||||
if (mavenGoals?.trim()) {
|
||||
command += " ${mavenGoals}"
|
||||
|
@ -25,13 +25,19 @@ def call(Map parameters = [:]) {
|
||||
.mixinGeneralConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS)
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, STEP_CONFIG_KEYS)
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS)
|
||||
.mixin([
|
||||
runCheckmarx: (script.commonPipelineEnvironment.configuration?.steps?.executeCheckmarxScan?.checkmarxProject != null && script.commonPipelineEnvironment.configuration.steps.executeCheckmarxScan.checkmarxProject.length()>0)
|
||||
])
|
||||
.mixin(parameters, PARAMETER_KEYS)
|
||||
.addIfEmpty('runCheckmarx', (script.commonPipelineEnvironment.configuration?.steps?.executeCheckmarxScan?.checkmarxProject != null && script.commonPipelineEnvironment.configuration.steps.executeCheckmarxScan.checkmarxProject.length()>0))
|
||||
.use()
|
||||
|
||||
// store files to be checked with checkmarx
|
||||
if (config.runCheckmarx) {
|
||||
utils.stash('checkmarx', config.stashIncludes?.get('checkmarx')?config.stashIncludes.checkmarx:'**/*.js, **/*.scala, **/*.py, **/*.go, **/*.xml, **/*.html', config.stashExcludes?.get('checkmarx')?config.stashExcludes.checkmarx:'**/*.mockserver.js, node_modules/**/*.js')
|
||||
utils.stash(
|
||||
'checkmarx',
|
||||
config.stashIncludes.checkmarx,
|
||||
config.stashExcludes.checkmarx
|
||||
)
|
||||
}
|
||||
|
||||
utils.stashWithMessage(
|
||||
|
@ -34,24 +34,6 @@ def call(Map parameters = [:]) {
|
||||
utils.stash('opa5', config.stashIncludes?.get('opa5')?config.stashIncludes.opa5:'**/*.*', config.stashExcludes?.get('opa5')?config.stashExcludes.opa5:'')
|
||||
}
|
||||
|
||||
//store git metadata for SourceClear agent
|
||||
sh "mkdir -p gitmetadata"
|
||||
sh "cp -rf .git/* gitmetadata"
|
||||
sh "chmod -R u+w gitmetadata"
|
||||
utils.stashWithMessage(
|
||||
'git',
|
||||
'[${STEP_NAME}] no git repo files detected: ',
|
||||
config.stashIncludes.git,
|
||||
config.stashExcludes.git
|
||||
)
|
||||
|
||||
//store files required for tests, e.g. Gauge, SUT, ...
|
||||
utils.stashWithMessage(
|
||||
'tests',
|
||||
'[${STEP_NAME}] no files for tests provided: ',
|
||||
config.stashIncludes.tests,
|
||||
config.stashExcludes.tests
|
||||
)
|
||||
//store build descriptor files depending on technology, e.g. pom.xml, package.json
|
||||
utils.stash(
|
||||
'buildDescriptor',
|
||||
@ -65,19 +47,22 @@ def call(Map parameters = [:]) {
|
||||
config.stashIncludes.deployDescriptor,
|
||||
config.stashExcludes.deployDescriptor
|
||||
)
|
||||
//store git metadata for SourceClear agent
|
||||
sh "mkdir -p gitmetadata"
|
||||
sh "cp -rf .git/* gitmetadata"
|
||||
sh "chmod -R u+w gitmetadata"
|
||||
utils.stashWithMessage(
|
||||
'git',
|
||||
'[${STEP_NAME}] no git repo files detected: ',
|
||||
config.stashIncludes.git,
|
||||
config.stashExcludes.git
|
||||
)
|
||||
//store nsp & retire exclusion file for future use
|
||||
utils.stashWithMessage(
|
||||
'opensource configuration',
|
||||
'[${STEP_NAME}] no opensource configuration files provided: ',
|
||||
config.stashIncludes.get('opensource configuration'),
|
||||
config.stashExcludes.get('opensource configuration')
|
||||
)
|
||||
//store snyk config file for future use
|
||||
utils.stashWithMessage(
|
||||
'snyk configuration',
|
||||
'[${STEP_NAME}] no snyk configuration files provided: ',
|
||||
config.stashIncludes.get('snyk configuration'),
|
||||
config.stashExcludes.get('snyk configuration')
|
||||
'opensourceConfiguration',
|
||||
'[${STEP_NAME}] no opensourceConfiguration files provided: ',
|
||||
config.stashIncludes.get('opensourceConfiguration'),
|
||||
config.stashExcludes.get('opensourceConfiguration')
|
||||
)
|
||||
//store pipeline configuration including additional groovy test scripts for future use
|
||||
utils.stashWithMessage(
|
||||
@ -86,12 +71,18 @@ def call(Map parameters = [:]) {
|
||||
config.stashIncludes.pipelineConfigAndTests,
|
||||
config.stashExcludes.pipelineConfigAndTests
|
||||
)
|
||||
|
||||
utils.stashWithMessage(
|
||||
'securityDescriptor',
|
||||
'[${STEP_NAME}] no security descriptor found: ',
|
||||
config.stashIncludes.securityDescriptor,
|
||||
config.stashExcludes.securityDescriptor
|
||||
)
|
||||
//store files required for tests, e.g. Gauge, SUT, ...
|
||||
utils.stashWithMessage(
|
||||
'tests',
|
||||
'[${STEP_NAME}] no files for tests provided: ',
|
||||
config.stashIncludes.tests,
|
||||
config.stashExcludes.tests
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user