diff --git a/docs/index-all.html b/docs/index-all.html index 6f526f4..f434f61 100644 --- a/docs/index-all.html +++ b/docs/index-all.html @@ -141,7 +141,7 @@

C

call(String) - Method in cmd
Executes a passed command on Linux Shell or Windows Batch depending on the node.
-
call(def, def, int) - Method in pipeline2ATX +
call(def, def, int, def, def) - Method in pipeline2ATX
Generates a test.guide compatible JSON report of a pipeline build including logs and stage meta data.
call(String, List, String, boolean, boolean) - Method in task @@ -195,7 +195,7 @@

G

generateJsonReport(def, def, def, def, def) - Method in pipeline2ATX
Generates a test.guide compatible JSON report of the pipeline build.
-
getBuildAttributes(def) - Method in pipeline2ATX +
getBuildAttributes(def, def) - Method in pipeline2ATX
Collects all relevant build information and parameter as a key-value-map: - PRODUCT_NAME (content of the env var PRODUCT_NAME, only added if present) - GIT_URL (content of env var GIT_URL, only added if present) @@ -203,7 +203,7 @@

G

- JENKINS_URL (url to the current Jenkins build job) - JENKINS_WORKSPACE (path to the Jenkins pipeline workspace) - TEST_LEVEL (content of env var TEST_LEVEL, only added if present)
-
getBuildConstants(def) - Method in pipeline2ATX +
getBuildConstants(def, def) - Method in pipeline2ATX
Collects all relevant build information and parameter as a key-value-map: - PRODUCT_VERSION (content of env var PRODUCT_VERSION, only added if present) - GIT_COMMIT (content of env var GIT_COMMIT, only added if present) diff --git a/docs/vars/cmd.html b/docs/vars/cmd.html index b3eaa25..99e42fc 100644 --- a/docs/vars/cmd.html +++ b/docs/vars/cmd.html @@ -163,11 +163,11 @@

Inherited Methods Summary

class groovy.lang.Script - groovy.lang.Script#getBinding(), groovy.lang.Script#setBinding(groovy.lang.Binding), groovy.lang.Script#evaluate(java.lang.String), groovy.lang.Script#evaluate(java.io.File), groovy.lang.Script#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.Script#println(), groovy.lang.Script#println(java.lang.Object), groovy.lang.Script#run(java.io.File, [Ljava.lang.String;), groovy.lang.Script#run(), groovy.lang.Script#getProperty(java.lang.String), groovy.lang.Script#setProperty(java.lang.String, java.lang.Object), groovy.lang.Script#print(java.lang.Object), groovy.lang.Script#printf(java.lang.String, java.lang.Object), groovy.lang.Script#printf(java.lang.String, [Ljava.lang.Object;), groovy.lang.Script#getMetaClass(), groovy.lang.Script#setMetaClass(groovy.lang.MetaClass), groovy.lang.Script#wait(long), groovy.lang.Script#wait(long, int), groovy.lang.Script#wait(), groovy.lang.Script#equals(java.lang.Object), groovy.lang.Script#toString(), groovy.lang.Script#hashCode(), groovy.lang.Script#getClass(), groovy.lang.Script#notify(), groovy.lang.Script#notifyAll() + groovy.lang.Script#getBinding(), groovy.lang.Script#setBinding(groovy.lang.Binding), groovy.lang.Script#evaluate(java.io.File), groovy.lang.Script#evaluate(java.lang.String), groovy.lang.Script#println(java.lang.Object), groovy.lang.Script#println(), groovy.lang.Script#run(java.io.File, [Ljava.lang.String;), groovy.lang.Script#run(), groovy.lang.Script#getProperty(java.lang.String), groovy.lang.Script#setProperty(java.lang.String, java.lang.Object), groovy.lang.Script#print(java.lang.Object), groovy.lang.Script#printf(java.lang.String, java.lang.Object), groovy.lang.Script#printf(java.lang.String, [Ljava.lang.Object;), groovy.lang.Script#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.Script#getMetaClass(), groovy.lang.Script#setMetaClass(groovy.lang.MetaClass), groovy.lang.Script#wait(long), groovy.lang.Script#wait(long, int), groovy.lang.Script#wait(), groovy.lang.Script#equals(java.lang.Object), groovy.lang.Script#toString(), groovy.lang.Script#hashCode(), groovy.lang.Script#getClass(), groovy.lang.Script#notify(), groovy.lang.Script#notifyAll() class groovy.lang.GroovyObjectSupport - groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll() + groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll() diff --git a/docs/vars/log.html b/docs/vars/log.html index a83fb54..864246f 100644 --- a/docs/vars/log.html +++ b/docs/vars/log.html @@ -205,11 +205,11 @@

Inherited Methods Summary

class groovy.lang.Script - groovy.lang.Script#getBinding(), groovy.lang.Script#setBinding(groovy.lang.Binding), groovy.lang.Script#evaluate(java.lang.String), groovy.lang.Script#evaluate(java.io.File), groovy.lang.Script#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.Script#println(), groovy.lang.Script#println(java.lang.Object), groovy.lang.Script#run(java.io.File, [Ljava.lang.String;), groovy.lang.Script#run(), groovy.lang.Script#getProperty(java.lang.String), groovy.lang.Script#setProperty(java.lang.String, java.lang.Object), groovy.lang.Script#print(java.lang.Object), groovy.lang.Script#printf(java.lang.String, java.lang.Object), groovy.lang.Script#printf(java.lang.String, [Ljava.lang.Object;), groovy.lang.Script#getMetaClass(), groovy.lang.Script#setMetaClass(groovy.lang.MetaClass), groovy.lang.Script#wait(long), groovy.lang.Script#wait(long, int), groovy.lang.Script#wait(), groovy.lang.Script#equals(java.lang.Object), groovy.lang.Script#toString(), groovy.lang.Script#hashCode(), groovy.lang.Script#getClass(), groovy.lang.Script#notify(), groovy.lang.Script#notifyAll() + groovy.lang.Script#getBinding(), groovy.lang.Script#setBinding(groovy.lang.Binding), groovy.lang.Script#evaluate(java.io.File), groovy.lang.Script#evaluate(java.lang.String), groovy.lang.Script#println(java.lang.Object), groovy.lang.Script#println(), groovy.lang.Script#run(java.io.File, [Ljava.lang.String;), groovy.lang.Script#run(), groovy.lang.Script#getProperty(java.lang.String), groovy.lang.Script#setProperty(java.lang.String, java.lang.Object), groovy.lang.Script#print(java.lang.Object), groovy.lang.Script#printf(java.lang.String, java.lang.Object), groovy.lang.Script#printf(java.lang.String, [Ljava.lang.Object;), groovy.lang.Script#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.Script#getMetaClass(), groovy.lang.Script#setMetaClass(groovy.lang.MetaClass), groovy.lang.Script#wait(long), groovy.lang.Script#wait(long, int), groovy.lang.Script#wait(), groovy.lang.Script#equals(java.lang.Object), groovy.lang.Script#toString(), groovy.lang.Script#hashCode(), groovy.lang.Script#getClass(), groovy.lang.Script#notify(), groovy.lang.Script#notifyAll() class groovy.lang.GroovyObjectSupport - groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll() + groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll() diff --git a/docs/vars/maven.html b/docs/vars/maven.html index 899f617..a042e32 100644 --- a/docs/vars/maven.html +++ b/docs/vars/maven.html @@ -205,11 +205,11 @@

Inherited Methods Summary

class groovy.lang.Script - groovy.lang.Script#getBinding(), groovy.lang.Script#setBinding(groovy.lang.Binding), groovy.lang.Script#evaluate(java.lang.String), groovy.lang.Script#evaluate(java.io.File), groovy.lang.Script#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.Script#println(), groovy.lang.Script#println(java.lang.Object), groovy.lang.Script#run(java.io.File, [Ljava.lang.String;), groovy.lang.Script#run(), groovy.lang.Script#getProperty(java.lang.String), groovy.lang.Script#setProperty(java.lang.String, java.lang.Object), groovy.lang.Script#print(java.lang.Object), groovy.lang.Script#printf(java.lang.String, java.lang.Object), groovy.lang.Script#printf(java.lang.String, [Ljava.lang.Object;), groovy.lang.Script#getMetaClass(), groovy.lang.Script#setMetaClass(groovy.lang.MetaClass), groovy.lang.Script#wait(long), groovy.lang.Script#wait(long, int), groovy.lang.Script#wait(), groovy.lang.Script#equals(java.lang.Object), groovy.lang.Script#toString(), groovy.lang.Script#hashCode(), groovy.lang.Script#getClass(), groovy.lang.Script#notify(), groovy.lang.Script#notifyAll() + groovy.lang.Script#getBinding(), groovy.lang.Script#setBinding(groovy.lang.Binding), groovy.lang.Script#evaluate(java.io.File), groovy.lang.Script#evaluate(java.lang.String), groovy.lang.Script#println(java.lang.Object), groovy.lang.Script#println(), groovy.lang.Script#run(java.io.File, [Ljava.lang.String;), groovy.lang.Script#run(), groovy.lang.Script#getProperty(java.lang.String), groovy.lang.Script#setProperty(java.lang.String, java.lang.Object), groovy.lang.Script#print(java.lang.Object), groovy.lang.Script#printf(java.lang.String, java.lang.Object), groovy.lang.Script#printf(java.lang.String, [Ljava.lang.Object;), groovy.lang.Script#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.Script#getMetaClass(), groovy.lang.Script#setMetaClass(groovy.lang.MetaClass), groovy.lang.Script#wait(long), groovy.lang.Script#wait(long, int), groovy.lang.Script#wait(), groovy.lang.Script#equals(java.lang.Object), groovy.lang.Script#toString(), groovy.lang.Script#hashCode(), groovy.lang.Script#getClass(), groovy.lang.Script#notify(), groovy.lang.Script#notifyAll() class groovy.lang.GroovyObjectSupport - groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll() + groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll() diff --git a/docs/vars/pipeline2ATX.html b/docs/vars/pipeline2ATX.html index ae20bef..c53a02e 100644 --- a/docs/vars/pipeline2ATX.html +++ b/docs/vars/pipeline2ATX.html @@ -138,7 +138,7 @@

Methods Summary

java.lang.Object - call(java.lang.Object log = false, java.lang.Object jobName = '', int buildNumber = 0)
Generates a test.guide compatible JSON report of a pipeline build including logs and stage meta data. + call(java.lang.Object log = false, java.lang.Object jobName = '', int buildNumber = 0, java.lang.Object customAttributes = [:], java.lang.Object customConstants = [:])
Generates a test.guide compatible JSON report of a pipeline build including logs and stage meta data. @@ -170,7 +170,7 @@

Methods Summary

java.lang.Object - getBuildAttributes(java.lang.Object build)
Collects all relevant build information and parameter as a key-value-map: + getBuildAttributes(java.lang.Object build, java.lang.Object customAttributes)
Collects all relevant build information and parameter as a key-value-map: - PRODUCT_NAME (content of the env var PRODUCT_NAME, only added if present) - GIT_URL (content of env var GIT_URL, only added if present) - JENKINS_PIPELINE (name of the current Jenkins build job) @@ -182,7 +182,7 @@

Methods Summary

java.lang.Object - getBuildConstants(java.lang.Object build)
Collects all relevant build information and parameter as a key-value-map: + getBuildConstants(java.lang.Object build, java.lang.Object customConstants)
Collects all relevant build information and parameter as a key-value-map: - PRODUCT_VERSION (content of env var PRODUCT_VERSION, only added if present) - GIT_COMMIT (content of env var GIT_COMMIT, only added if present) - JENKINS_BUILD_ID (number of current Jenkins build) @@ -261,11 +261,11 @@

Inherited Methods Summary

class groovy.lang.Script - groovy.lang.Script#getBinding(), groovy.lang.Script#setBinding(groovy.lang.Binding), groovy.lang.Script#evaluate(java.lang.String), groovy.lang.Script#evaluate(java.io.File), groovy.lang.Script#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.Script#println(), groovy.lang.Script#println(java.lang.Object), groovy.lang.Script#run(java.io.File, [Ljava.lang.String;), groovy.lang.Script#run(), groovy.lang.Script#getProperty(java.lang.String), groovy.lang.Script#setProperty(java.lang.String, java.lang.Object), groovy.lang.Script#print(java.lang.Object), groovy.lang.Script#printf(java.lang.String, java.lang.Object), groovy.lang.Script#printf(java.lang.String, [Ljava.lang.Object;), groovy.lang.Script#getMetaClass(), groovy.lang.Script#setMetaClass(groovy.lang.MetaClass), groovy.lang.Script#wait(long), groovy.lang.Script#wait(long, int), groovy.lang.Script#wait(), groovy.lang.Script#equals(java.lang.Object), groovy.lang.Script#toString(), groovy.lang.Script#hashCode(), groovy.lang.Script#getClass(), groovy.lang.Script#notify(), groovy.lang.Script#notifyAll() + groovy.lang.Script#getBinding(), groovy.lang.Script#setBinding(groovy.lang.Binding), groovy.lang.Script#evaluate(java.io.File), groovy.lang.Script#evaluate(java.lang.String), groovy.lang.Script#println(java.lang.Object), groovy.lang.Script#println(), groovy.lang.Script#run(java.io.File, [Ljava.lang.String;), groovy.lang.Script#run(), groovy.lang.Script#getProperty(java.lang.String), groovy.lang.Script#setProperty(java.lang.String, java.lang.Object), groovy.lang.Script#print(java.lang.Object), groovy.lang.Script#printf(java.lang.String, java.lang.Object), groovy.lang.Script#printf(java.lang.String, [Ljava.lang.Object;), groovy.lang.Script#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.Script#getMetaClass(), groovy.lang.Script#setMetaClass(groovy.lang.MetaClass), groovy.lang.Script#wait(long), groovy.lang.Script#wait(long, int), groovy.lang.Script#wait(), groovy.lang.Script#equals(java.lang.Object), groovy.lang.Script#toString(), groovy.lang.Script#hashCode(), groovy.lang.Script#getClass(), groovy.lang.Script#notify(), groovy.lang.Script#notifyAll() class groovy.lang.GroovyObjectSupport - groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll() + groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll() @@ -299,10 +299,10 @@

Inherited Methods Summary

Method Detail

- + - + - + diff --git a/test/vars/Pipeline2ATXTest.groovy b/test/vars/Pipeline2ATXTest.groovy index 97d45c1..07c50dd 100644 --- a/test/vars/Pipeline2ATXTest.groovy +++ b/test/vars/Pipeline2ATXTest.groovy @@ -42,7 +42,7 @@ class Pipeline2ATXTest extends PipelineSpockTestBase { addEnvVar('TEST_LEVEL', 'Unit Test') when: 'collect the build attributes' - List attributes = pipeline2ATX.getBuildAttributes(build) + List attributes = pipeline2ATX.getBuildAttributes(build,['GIT_URL':'https://mycustomgit/blub','TOOL_NAME':'test.tool']) then: 'expect a attributes list with build information' @@ -50,11 +50,12 @@ class Pipeline2ATXTest extends PipelineSpockTestBase { where: result = [['key':'PRODUCT_NAME', 'value':'testProd'], - ['key':'GIT_URL', 'value':'https://mygit/blub'], + ['key':'GIT_URL', 'value':'https://mycustomgit/blub'], ['key':'JENKINS_PIPELINE', 'value':'TestBuild'], ['key':'JENKINS_URL', 'value':'https://testurl'], ['key':'JENKINS_WORKSPACE', 'value':'C:/ws/TestBuild/build42'], - ['key':'TEST_LEVEL', 'value':'Unit Test']] + ['key':'TEST_LEVEL', 'value':'Unit Test'], + ['key':'TOOL_NAME', 'value':'test.tool']] } def 'Collect build attributes - missing env vars'() { @@ -63,7 +64,7 @@ class Pipeline2ATXTest extends PipelineSpockTestBase { build.getDisplayName() >> 'TestBuild' build.getAbsoluteUrl() >> 'https://testurl' when: 'collect the build attributes' - List attributes = pipeline2ATX.getBuildAttributes(build) + List attributes = pipeline2ATX.getBuildAttributes(build,[:]) then: 'expect a attributes list with build information' result == attributes @@ -85,17 +86,18 @@ class Pipeline2ATXTest extends PipelineSpockTestBase { when: 'collect the build constants' - List constants = pipeline2ATX.getBuildConstants(build) + List constants = pipeline2ATX.getBuildConstants(build,['GIT_COMMIT':'customGitCommit','TOOL_NAME':'test.tool']) then: 'expect a attributes list with build information' result == constants where: result = [['key':'PRODUCT_VERSION', 'value':'1.2.3'], - ['key':'GIT_COMMIT', 'value':'gitCommit'], + ['key':'GIT_COMMIT', 'value':'customGitCommit'], ['key':'JENKINS_BUILD_ID', 'value':'42'], ['key':'JENKINS_EXECUTOR_NUMBER', 'value':'0815'], - ['key':'JENKINS_NODE_NAME', 'value':'Runner0815']] + ['key':'JENKINS_NODE_NAME', 'value':'Runner0815'], + ['key':'TOOL_NAME', 'value':'test.tool']] } def 'Collect build constants - missing env vars'() { @@ -104,7 +106,7 @@ class Pipeline2ATXTest extends PipelineSpockTestBase { build.id >> 42 when: 'collect the build constants' - List constants = pipeline2ATX.getBuildConstants(build) + List constants = pipeline2ATX.getBuildConstants(build,[:]) then: 'expect a attributes list with build information' result == constants diff --git a/vars/pipeline2ATX.groovy b/vars/pipeline2ATX.groovy index 9971ab8..6ac737b 100644 --- a/vars/pipeline2ATX.groovy +++ b/vars/pipeline2ATX.groovy @@ -52,7 +52,7 @@ import org.jenkinsci.plugins.workflow.support.visualization.table.FlowGraphTable * @param buildNumber * the number of the pipeline build (optional) */ -def call(log = false, jobName = '', int buildNumber = 0) { +def call(log = false, jobName = '', int buildNumber = 0, def customAttributes = [:], def customConstants = [:]) { def build def logFile = '' @@ -62,8 +62,8 @@ def call(log = false, jobName = '', int buildNumber = 0) { } def filename = "${build.getParent().getDisplayName()}_${build.getNumber()}" - def attributes = getBuildAttributes(build) - def constants = getBuildConstants(build) + def attributes = getBuildAttributes(build, customAttributes) + def constants = getBuildConstants(build, customConstants) def executionSteps = getExecutionSteps(build, log) if (log) { @@ -107,24 +107,19 @@ def getRawBuild(String jobName, int buildNumber) { * - JENKINS_WORKSPACE (path to the Jenkins pipeline workspace) * - TEST_LEVEL (content of env var TEST_LEVEL, only added if present) * + * customAttributes overrides build attributes (when adding maps the second map will override values present in both) * @param build * the pipeline raw build * @return the collected build information and parameters in ATX attribute format */ -def getBuildAttributes(build) { - def attributes = [] - def buildAttributes = [PRODUCT_NAME: env.PRODUCT_NAME, +def getBuildAttributes(build, customAttributes) { + def attributes = [PRODUCT_NAME: env.PRODUCT_NAME, GIT_URL: env.GIT_URL, JENKINS_PIPELINE: build.getDisplayName(), JENKINS_URL: build.getAbsoluteUrl(), JENKINS_WORKSPACE: env.WORKSPACE, - TEST_LEVEL: env.TEST_LEVEL] - buildAttributes.each { k, v -> - if (v) { - attributes.add([key: k, value: v.toString()]) - } - } - return attributes + TEST_LEVEL: env.TEST_LEVEL] + customAttributes + return attributes.findAll{k,v -> v}.collect{ k, v -> [key: k, value: v.toString()]} } /** @@ -135,23 +130,18 @@ def getBuildAttributes(build) { * - JENKINS_EXECUTOR_NUMBER (number of currecnt Jenkins executor) * - JENKINS_NODE_NAME (name of current node the current build is running on) * + * customConstants overrides build constants (when adding maps the second map will override values present in both) * @param build * the pipeline raw build * @return the collected build information and parameters in ATX constants format */ -def getBuildConstants(build) { - def constants = [] - def buildConstants = [PRODUCT_VERSION: env.PRODUCT_VERSION, +def getBuildConstants(build, customConstants) { + def constants = [PRODUCT_VERSION: env.PRODUCT_VERSION, GIT_COMMIT: env.GIT_COMMIT, JENKINS_BUILD_ID: build.id, JENKINS_EXECUTOR_NUMBER: env.EXECUTOR_NUMBER, - JENKINS_NODE_NAME: env.NODE_NAME] - buildConstants.each { k, v -> - if (v) { - constants.add([key: k, value: v.toString()]) - } - } - return constants + JENKINS_NODE_NAME: env.NODE_NAME] + customConstants + return constants.findAll{k,v -> v}.collect{ k, v -> [key: k, value: v.toString()]} } /** diff --git a/vars/pipeline2ATX.txt b/vars/pipeline2ATX.txt index 84a3b7c..9932b84 100644 --- a/vars/pipeline2ATX.txt +++ b/vars/pipeline2ATX.txt @@ -33,6 +33,10 @@ The report is compressed as a zip file within the build workspace and can be upl
the name of the pipeline job (optional)
buildNumber
the number of the pipeline build (optional)
+
customAttributes
+
customAttribues to add to testcase (will override buildAttributes)
+
customConstants
+
customConstants to add to testcase (will override buildConstants)