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