-
Notifications
You must be signed in to change notification settings - Fork 830
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
[JENKINS-34085] Added support for Versionnumber Plugin (https://wiki.jenkins-ci.org/d… #818
Changes from all commits
9db2c12
d218cf2
2da439e
f5c1cc1
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
job('example') { | ||
wrappers { | ||
versionNumber('1.0.0.${BUILDS_ALL_TIME}', 'VERSION') { | ||
startDate() | ||
prefixVariable('') | ||
buildsToday() | ||
buildsThisWeek() | ||
buildsThisMonth() | ||
buildsThisYear() | ||
buildsAllTime() | ||
skipFailedBuilds(false) | ||
displayBuildName(true) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package javaposse.jobdsl.dsl.helpers.wrapper | ||
|
||
import javaposse.jobdsl.dsl.Context | ||
|
||
class VersionNumberContext implements Context { | ||
|
||
String format | ||
String nameVariable | ||
String prefixVariable | ||
boolean skipFailedBuilds | ||
boolean displayBuildName | ||
String startDate | ||
String buildsToday | ||
String buildsThisWeek | ||
String buildsThisMonth | ||
String buildsThisYear | ||
String buildsAllTime | ||
|
||
/** | ||
* @param format Version Number Format String | ||
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. Have a look at other contexts for the expected GroovyDoc. Use one sentence to describe the option and do not use the |
||
* @param nameVariable The version number will be stored in the environment variable specified here. | ||
*/ | ||
VersionNumberContext(String format, String nameVariable) { | ||
this.format = format | ||
this.nameVariable = nameVariable | ||
} | ||
|
||
/** | ||
* @param prefixVariable The prefix variable name is the environment variable specified here | ||
* to allow using the same build numbers for all the release tags. | ||
*/ | ||
void prefixVariable(String prefixVariable) { | ||
this.prefixVariable = prefixVariable | ||
} | ||
|
||
/** | ||
* @param skipFailedBuilds Don't increment builds today / this month / this year / all time after a failed build. | ||
*/ | ||
void skipFailedBuilds(boolean skipFailedBuilds = true) { | ||
this.skipFailedBuilds = skipFailedBuilds | ||
} | ||
|
||
/** | ||
* @param displayBuildName Use the formatted version number for build display name. | ||
*/ | ||
void displayBuildName(boolean displayBuildName = true) { | ||
this.displayBuildName = displayBuildName | ||
} | ||
|
||
/** | ||
* @param startDate The date the project began, in the format yyyy-MM-dd. This is used in calculating the | ||
* number of months and years since the beginning of the project. | ||
*/ | ||
void startDate(String startDate) { | ||
this.startDate = startDate | ||
} | ||
|
||
/** | ||
* @param buildsToday Number of builds today | ||
*/ | ||
void buildsToday(String buildsToday) { | ||
this.buildsToday = buildsToday | ||
} | ||
|
||
/** | ||
* @param buildsThisWeek Number of builds this week | ||
*/ | ||
void buildsThisWeek(String buildsThisWeek) { | ||
this.buildsThisWeek = buildsThisWeek | ||
} | ||
|
||
/** | ||
* @param buildsThisMonth Number of builds this month | ||
*/ | ||
void buildsThisMonth(String buildsThisMonth) { | ||
this.buildsThisMonth = buildsThisMonth | ||
} | ||
|
||
/** | ||
* @param buildsThisYear Number of builds this year | ||
*/ | ||
void buildsThisYear(String buildsThisYear) { | ||
this.buildsThisYear = buildsThisYear | ||
} | ||
|
||
/** | ||
* @param buildsAllTime Number of builds since the start of the project | ||
*/ | ||
void buildsAllTime(String buildsAllTime) { | ||
this.buildsAllTime = buildsAllTime | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1488,4 +1488,83 @@ class WrapperContextSpec extends Specification { | |
'key1' | 'key2' | 'key3' | null | 'key1' | 'key2' | 'key3' | '' | ||
'key1' | 'key2' | 'key3' | 'key4' | 'key1' | 'key2' | 'key3' | 'key4' | ||
} | ||
|
||
def 'call versionNumber'() { | ||
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. Sorry about this, I didn't review your test case, would you mind adding another TestCase for call versionNumber with all options' |
||
when: | ||
context.versionNumber('', '') { | ||
} | ||
|
||
then: | ||
with(context.wrapperNodes[0]) { | ||
name() == 'org.jvnet.hudson.tools.versionnumber.VersionNumberBuilder' | ||
children().size() == 11 | ||
children()[0].name() == 'versionNumberString' | ||
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. there is no need to reference all children by index, the order is not relevant in this case. See the other tests for the expected syntax, e.g. |
||
children()[0].value() == '' | ||
children()[1].name() == 'projectStartDate' | ||
children()[1].value() == '' | ||
children()[2].name() == 'environmentVariableName' | ||
children()[2].value() == '' | ||
children()[3].name() == 'environmentPrefixVariable' | ||
children()[3].value() == '' | ||
children()[4].name() == 'oBuildsToday' | ||
children()[4].value() == '' | ||
children()[5].name() == 'oBuildsThisWeek' | ||
children()[5].value() == '' | ||
children()[6].name() == 'oBuildsThisMonth' | ||
children()[6].value() == '' | ||
children()[7].name() == 'oBuildsThisYear' | ||
children()[7].value() == '' | ||
children()[8].name() == 'oBuildsAllTime' | ||
children()[8].value() == '' | ||
children()[9].name() == 'skipFailedBuilds' | ||
children()[9].value() == false | ||
children()[10].name() == 'useAsBuildDisplayName' | ||
children()[10].value() == false | ||
} | ||
1 * mockJobManagement.requireMinimumPluginVersion('versionnumber', '1.6') | ||
} | ||
|
||
def 'call versionNumber with all options'() { | ||
when: | ||
context.versionNumber('1.0.0.${BUILDS_ALL_TIME}', 'VER') { | ||
startDate('1970-01-02 03:04:05.6 UTC') | ||
prefixVariable('PFX') | ||
buildsToday('1') | ||
buildsThisWeek('2') | ||
buildsThisMonth('3') | ||
buildsThisYear('4') | ||
buildsAllTime('5') | ||
skipFailedBuilds(false) | ||
displayBuildName(false) | ||
} | ||
|
||
then: | ||
with(context.wrapperNodes[0]) { | ||
name() == 'org.jvnet.hudson.tools.versionnumber.VersionNumberBuilder' | ||
children().size() == 11 | ||
children()[0].name() == 'versionNumberString' | ||
children()[0].value() == '1.0.0.${BUILDS_ALL_TIME}' | ||
children()[1].name() == 'projectStartDate' | ||
children()[1].value() == '1970-01-02 03:04:05.6 UTC' | ||
children()[2].name() == 'environmentVariableName' | ||
children()[2].value() == 'VER' | ||
children()[3].name() == 'environmentPrefixVariable' | ||
children()[3].value() == 'PFX' | ||
children()[4].name() == 'oBuildsToday' | ||
children()[4].value() == '1' | ||
children()[5].name() == 'oBuildsThisWeek' | ||
children()[5].value() == '2' | ||
children()[6].name() == 'oBuildsThisMonth' | ||
children()[6].value() == '3' | ||
children()[7].name() == 'oBuildsThisYear' | ||
children()[7].value() == '4' | ||
children()[8].name() == 'oBuildsAllTime' | ||
children()[8].value() == '5' | ||
children()[9].name() == 'skipFailedBuilds' | ||
children()[9].value() == false | ||
children()[10].name() == 'useAsBuildDisplayName' | ||
children()[10].value() == false | ||
} | ||
1 * mockJobManagement.requireMinimumPluginVersion('versionnumber', '1.6') | ||
} | ||
} |
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.
try to find a better example with some values instead of just calling all methods without options