-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plan and build custom fields support #20
Changes from all commits
633f8db
0de8b42
125c35e
f025a6d
9474717
0989242
fb3ce3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,11 @@ public class AbstractTestLinkBuilder extends Builder { | |
*/ | ||
protected final String customFields; | ||
|
||
/** | ||
* Comma separated list of custom fields to download from TestLink. | ||
*/ | ||
protected final String testPlanCustomFields; | ||
|
||
/** | ||
* List of build steps that are executed only once per job execution. | ||
*/ | ||
|
@@ -138,7 +143,7 @@ public class AbstractTestLinkBuilder extends Builder { | |
* Create a AbstractTestLinkBuilder. | ||
*/ | ||
public AbstractTestLinkBuilder(String testLinkName, String testProjectName, String testPlanName, | ||
String platformName, String buildName, String customFields, List<BuildStep> singleBuildSteps, | ||
String platformName, String buildName, String customFields, String testPlanCustomFields, List<BuildStep> singleBuildSteps, | ||
List<BuildStep> beforeIteratingAllTestCasesBuildSteps, List<BuildStep> iterativeBuildSteps, | ||
List<BuildStep> afterIteratingAllTestCasesBuildSteps, Boolean transactional, | ||
Boolean failedTestsMarkBuildAsFailure, Boolean failIfNoResults, Boolean failOnNotRun, | ||
|
@@ -150,6 +155,7 @@ public AbstractTestLinkBuilder(String testLinkName, String testProjectName, Stri | |
this.platformName = platformName; | ||
this.buildName = buildName; | ||
this.customFields = customFields; | ||
this.testPlanCustomFields = testPlanCustomFields; | ||
this.singleBuildSteps = singleBuildSteps; | ||
this.beforeIteratingAllTestCasesBuildSteps = beforeIteratingAllTestCasesBuildSteps; | ||
this.iterativeBuildSteps = iterativeBuildSteps; | ||
|
@@ -182,13 +188,13 @@ public AbstractTestLinkBuilder(String testLinkName, String testProjectName, Stri | |
* @deprecated | ||
*/ | ||
public AbstractTestLinkBuilder(String testLinkName, String testProjectName, String testPlanName, | ||
String platformName, String buildName, String customFields, Boolean executionStatusNotRun, | ||
String platformName, String buildName, String customFields, String testPlanCustomFields, Boolean executionStatusNotRun, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The deprecated constructor can be left as is, and just pass null/empty values to the current constructor. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I come from the C# world, all those deprecated tons of code and almost empty methods and constructors look really frustrating to me (since java does not have default param value in method declaration) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not specifically for Java. But XStream, the library used to serialise XML in Jenkins, may try to load an XML or call the old constructor. So we keep it for a while, just until users update their jobs. A major release like 4.0 is a good opportunity to remove this deprecated constructor, giving notice with enough time to users too. |
||
Boolean executionStatusPassed, Boolean executionStatusFailed, Boolean executionStatusBlocked, | ||
List<BuildStep> singleBuildSteps, List<BuildStep> beforeIteratingAllTestCasesBuildSteps, | ||
List<BuildStep> iterativeBuildSteps, List<BuildStep> afterIteratingAllTestCasesBuildSteps, | ||
Boolean transactional, Boolean failedTestsMarkBuildAsFailure, Boolean failIfNoResults, | ||
Boolean failOnNotRun, List<ResultSeeker> resultSeekers) { | ||
this(testLinkName, testProjectName, testPlanName, platformName, buildName, customFields, singleBuildSteps, | ||
this(testLinkName, testProjectName, testPlanName, platformName, buildName, customFields, testPlanCustomFields, singleBuildSteps, | ||
beforeIteratingAllTestCasesBuildSteps, iterativeBuildSteps, afterIteratingAllTestCasesBuildSteps, | ||
transactional, failedTestsMarkBuildAsFailure, failIfNoResults, failOnNotRun, resultSeekers); | ||
} | ||
|
@@ -230,6 +236,10 @@ public String getCustomFields() { | |
return this.customFields; | ||
} | ||
|
||
public String getTestPlanCustomFields(){ | ||
return this.testPlanCustomFields; | ||
} | ||
|
||
/** | ||
* @deprecated | ||
*/ | ||
|
@@ -361,4 +371,26 @@ protected String[] createArrayOfCustomFieldsNames(final VariableResolver<String> | |
return customFieldNamesArray; | ||
} | ||
|
||
|
||
protected String[] createArrayOfTestPlanCustomFieldsNames(final VariableResolver<String> variableResolver, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will try to merge createArrayOfTestPlanCustomFieldsNames and createArrayOfCustomFieldsNames methods. You could have done that, but that would make this pull request harder to merge. By simply copying and pasting, you made it easier for me to review your code, and also to spot parts of the code that were not suitable for extensibility. Kudos and thanks! 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you reading my mind? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great idea, and again, thanks for not doing that in this commit. It made it waaaay easier to review the code 😁 |
||
final EnvVars envVars){ | ||
String[] customFieldNamesArray = new String[0]; | ||
String customFields = expandVariable(variableResolver, envVars, this.getTestPlanCustomFields()); | ||
|
||
if (StringUtils.isNotBlank(customFields)) { | ||
StringTokenizer tokenizer = new StringTokenizer(customFields, COMMA); | ||
if (tokenizer.countTokens() > 0) { | ||
customFieldNamesArray = new String[tokenizer.countTokens()]; | ||
int index = 0; | ||
while (tokenizer.hasMoreTokens()) { | ||
String customFieldName = tokenizer.nextToken(); | ||
customFieldName = customFieldName.trim(); | ||
customFieldNamesArray[index] = customFieldName; | ||
index = index + 1; | ||
} | ||
} | ||
} | ||
|
||
return customFieldNamesArray; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,7 +82,7 @@ public class TestLinkBuilder extends AbstractTestLinkBuilder { | |
* @deprecated | ||
*/ | ||
public TestLinkBuilder(String testLinkName, String testProjectName, | ||
String testPlanName, String buildName, String customFields, | ||
String testPlanName, String buildName, String customFields, String testPlanCustomFields, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto deprecated constructor. |
||
Boolean executionStatusNotRun, Boolean executionStatusPassed, | ||
Boolean executionStatusFailed, Boolean executionStatusBlocked, | ||
List<BuildStep> singleBuildSteps, | ||
|
@@ -92,7 +92,7 @@ public TestLinkBuilder(String testLinkName, String testProjectName, | |
Boolean transactional, Boolean failedTestsMarkBuildAsFailure, | ||
Boolean failIfNoResults, List<ResultSeeker> resultSeekers) { | ||
super(testLinkName, testProjectName, testPlanName, buildName, | ||
null, customFields, executionStatusNotRun, executionStatusPassed, | ||
null, customFields, testPlanCustomFields, executionStatusNotRun, executionStatusPassed, | ||
executionStatusFailed, executionStatusBlocked, singleBuildSteps, | ||
beforeIteratingAllTestCasesBuildSteps, iterativeBuildSteps, | ||
afterIteratingAllTestCasesBuildSteps, transactional, | ||
|
@@ -104,7 +104,7 @@ public TestLinkBuilder(String testLinkName, String testProjectName, | |
* @deprecated | ||
*/ | ||
public TestLinkBuilder(String testLinkName, String testProjectName, | ||
String testPlanName, String buildName, String customFields, | ||
String testPlanName, String buildName, String customFields, String testPlanCustomFields, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. et hic |
||
Boolean executionStatusNotRun, Boolean executionStatusPassed, | ||
Boolean executionStatusFailed, Boolean executionStatusBlocked, | ||
List<BuildStep> singleBuildSteps, | ||
|
@@ -114,7 +114,7 @@ public TestLinkBuilder(String testLinkName, String testProjectName, | |
Boolean transactional, Boolean failedTestsMarkBuildAsFailure, | ||
Boolean failIfNoResults, Boolean failOnNotRun, List<ResultSeeker> resultSeekers) { | ||
super(testLinkName, testProjectName, testPlanName, buildName, null, | ||
customFields, executionStatusNotRun, executionStatusPassed, | ||
customFields, testPlanCustomFields, executionStatusNotRun, executionStatusPassed, | ||
executionStatusFailed, executionStatusBlocked, singleBuildSteps, | ||
beforeIteratingAllTestCasesBuildSteps, iterativeBuildSteps, | ||
afterIteratingAllTestCasesBuildSteps, transactional, | ||
|
@@ -123,7 +123,7 @@ public TestLinkBuilder(String testLinkName, String testProjectName, | |
|
||
@DataBoundConstructor | ||
public TestLinkBuilder(String testLinkName, String testProjectName, | ||
String testPlanName, String platformName, String buildName, String customFields, | ||
String testPlanName, String platformName, String buildName, String customFields, String testPlanCustomFields, | ||
Boolean executionStatusNotRun, Boolean executionStatusPassed, | ||
Boolean executionStatusFailed, Boolean executionStatusBlocked, | ||
List<BuildStep> singleBuildSteps, | ||
|
@@ -133,7 +133,7 @@ public TestLinkBuilder(String testLinkName, String testProjectName, | |
Boolean transactional, Boolean failedTestsMarkBuildAsFailure, | ||
Boolean failIfNoResults, Boolean failOnNotRun, List<ResultSeeker> resultSeekers) { | ||
super(testLinkName, testProjectName, testPlanName, platformName, buildName, | ||
customFields, singleBuildSteps, beforeIteratingAllTestCasesBuildSteps, iterativeBuildSteps, | ||
customFields, testPlanCustomFields, singleBuildSteps, beforeIteratingAllTestCasesBuildSteps, iterativeBuildSteps, | ||
afterIteratingAllTestCasesBuildSteps, transactional, failedTestsMarkBuildAsFailure, | ||
failIfNoResults, failOnNotRun, resultSeekers); | ||
} | ||
|
@@ -163,6 +163,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, | |
final TestCaseWrapper[] automatedTestCases; | ||
final String testLinkUrl = installation.getUrl(); | ||
final String testLinkDevKey = installation.getDevKey(); | ||
TestPlan testPlan; | ||
listener.getLogger().println(Messages.TestLinkBuilder_UsedTLURL(testLinkUrl)); | ||
|
||
try { | ||
|
@@ -188,9 +189,13 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, | |
if (StringUtils.isNotBlank(platformName) && testLinkSite.getPlatform() == null) | ||
listener.getLogger().println(Messages.TestLinkBuilder_PlatformNotFound(platformName)); | ||
|
||
final String[] customFieldsNames = this.createArrayOfCustomFieldsNames(build.getBuildVariableResolver(), build.getEnvironment(listener)); | ||
final String[] testCaseCustomFieldsNames = this.createArrayOfCustomFieldsNames(build.getBuildVariableResolver(), build.getEnvironment(listener)); | ||
// Array of automated test cases | ||
TestCase[] testCases = testLinkSite.getAutomatedTestCases(customFieldsNames); | ||
TestCase[] testCases = testLinkSite.getAutomatedTestCases(testCaseCustomFieldsNames); | ||
|
||
final String[] testPlanCustomFieldsNames = this.createArrayOfTestPlanCustomFieldsNames(build.getBuildVariableResolver(), build.getEnvironment(listener)); | ||
|
||
testPlan = testLinkSite.getTestPlanWithCustomFields(testPlanCustomFieldsNames); | ||
|
||
// Transforms test cases into test case wrappers | ||
automatedTestCases = this.transform(testCases); | ||
|
@@ -219,10 +224,10 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, | |
} | ||
|
||
listener.getLogger().println(Messages.TestLinkBuilder_ExecutingSingleBuildSteps()); | ||
this.executeSingleBuildSteps(automatedTestCases.length, testLinkSite, build, launcher, listener); | ||
this.executeSingleBuildSteps(automatedTestCases.length, testPlan, testLinkSite, build, launcher, listener); | ||
|
||
listener.getLogger().println(Messages.TestLinkBuilder_ExecutingIterativeBuildSteps()); | ||
this.executeIterativeBuildSteps(automatedTestCases, testLinkSite, build, launcher, listener); | ||
this.executeIterativeBuildSteps(automatedTestCases, testPlan, testLinkSite, build, launcher, listener); | ||
|
||
// Here we search for test results. The return if a wrapped Test Case | ||
// that | ||
|
@@ -308,7 +313,7 @@ public TestLinkSite getTestLinkSite(String testLinkUrl, String testLinkDevKey, | |
|
||
final TestProject testProject = api.getTestProjectByName(testProjectName); | ||
final TestPlan testPlan = api.getTestPlanByName(testPlanName, testProjectName); | ||
|
||
Platform platform = null; | ||
if (StringUtils.isNotBlank(platformName)){ | ||
final Platform platforms[] = api.getProjectPlatforms(testProject.getId()); | ||
|
@@ -335,15 +340,15 @@ public TestLinkSite getTestLinkSite(String testLinkUrl, String testLinkDevKey, | |
* @throws IOException | ||
* @throws InterruptedException | ||
*/ | ||
protected void executeSingleBuildSteps(int numberOfTests, TestLinkSite testLinkSite, AbstractBuild<?, ?> build, | ||
protected void executeSingleBuildSteps(int numberOfTests, TestPlan testPlan, TestLinkSite testLinkSite, AbstractBuild<?, ?> build, | ||
Launcher launcher, BuildListener listener) throws IOException, | ||
InterruptedException { | ||
if (singleBuildSteps != null) { | ||
for (BuildStep b : singleBuildSteps) { | ||
final EnvVars iterativeEnvVars = TestLinkHelper.buildTestCaseEnvVars( | ||
numberOfTests, | ||
testLinkSite.getTestProject(), | ||
testLinkSite.getTestPlan(), | ||
testPlan, | ||
testLinkSite.getBuild(), | ||
listener); | ||
build.addAction(new EnvironmentContributingAction() { | ||
|
@@ -385,6 +390,7 @@ public String getDisplayName() { | |
* @throws IOException | ||
*/ | ||
protected void executeIterativeBuildSteps(TestCaseWrapper[] automatedTestCases, | ||
TestPlan testPlan, | ||
TestLinkSite testLinkSite, AbstractBuild<?, ?> build, | ||
Launcher launcher, BuildListener listener) throws IOException, | ||
InterruptedException { | ||
|
@@ -405,7 +411,7 @@ protected void executeIterativeBuildSteps(TestCaseWrapper[] automatedTestCases, | |
if (iterativeBuildSteps != null) { | ||
final EnvVars iterativeEnvVars = TestLinkHelper.buildTestCaseEnvVars(automatedTestCase, | ||
testLinkSite.getTestProject(), | ||
testLinkSite.getTestPlan(), | ||
testPlan, | ||
testLinkSite.getBuild(), listener); | ||
|
||
build.addAction(new EnvironmentContributingAction() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version value is changed by maven-release-plugin. When I run mvn clean release:prepare it runs the tests, does some other checks like git status and also asks for the next release version. Will fix it after merging.