Skip to content

Commit

Permalink
[FIXED JENKINS-29134] cont.
Browse files Browse the repository at this point in the history
* Renamed constant "envVarPattern" to "ENV_VAR_PATTERN".

Signed-off-by: Deniz Bahadir <dbahadir@benocs.com>
  • Loading branch information
Bagira80 committed Jul 15, 2015
1 parent 25537f0 commit 9c1a033
Showing 1 changed file with 7 additions and 7 deletions.
Expand Up @@ -59,7 +59,7 @@ public class VersionNumberBuilder extends BuildWrapper {

private static final DateFormat defaultDateFormat = new SimpleDateFormat("yyyy-MM-dd");
// Pattern: ${VAR_NAME} or $VAR_NAME
private static final String envVarPattern = new String("^(?:\\$\\{(\\w+)\\})|(?:\\$(\\w+))$");
private static final String ENV_VAR_PATTERN = new String("^(?:\\$\\{(\\w+)\\})|(?:\\$(\\w+))$");

private final String versionNumberString;
private final Date projectStartDate;
Expand Down Expand Up @@ -168,7 +168,7 @@ private static String makeValid(String buildNum) {
} catch (Exception e) {
// Obviously, we did not receive a valid integer as override.
// Is it a reference to an environment-variable?
if (buildNum.matches(envVarPattern)) {
if (buildNum.matches(ENV_VAR_PATTERN)) {
// Yes, so return it as-is and only retrieve its value when
// the value must be accessed (to always get the most
// up-to-date value).
Expand Down Expand Up @@ -293,15 +293,15 @@ private VersionNumberBuildInfo incBuild(AbstractBuild build, Map<String, String>

// have we overridden any of the version number info? If so, set it up here
boolean saveOverrides = false;
Pattern pattern = Pattern.compile(envVarPattern);
Pattern pattern = Pattern.compile(ENV_VAR_PATTERN);

if (!this.oBuildsToday.equals("")) {
saveOverrides = true; // Always need to save if not empty!
// Just in case someone directly edited the config-file with invalid values.
oBuildsToday = makeValid(oBuildsToday);
int newVal = buildsToday;
try {
if (!oBuildsToday.matches(envVarPattern)) {
if (!oBuildsToday.matches(ENV_VAR_PATTERN)) {
newVal = Integer.parseInt(oBuildsToday);
oBuildsToday = ""; // Reset!
} else {
Expand All @@ -322,7 +322,7 @@ private VersionNumberBuildInfo incBuild(AbstractBuild build, Map<String, String>
oBuildsThisMonth = makeValid(oBuildsThisMonth);
int newVal = buildsThisMonth;
try {
if (!oBuildsThisMonth.matches(envVarPattern)) {
if (!oBuildsThisMonth.matches(ENV_VAR_PATTERN)) {
newVal = Integer.parseInt(oBuildsThisMonth);
oBuildsThisMonth = ""; // Reset!
} else {
Expand All @@ -343,7 +343,7 @@ private VersionNumberBuildInfo incBuild(AbstractBuild build, Map<String, String>
oBuildsThisYear = makeValid(oBuildsThisYear);
int newVal = buildsThisYear;
try {
if (!oBuildsThisYear.matches(envVarPattern)) {
if (!oBuildsThisYear.matches(ENV_VAR_PATTERN)) {
newVal = Integer.parseInt(oBuildsThisYear);
oBuildsThisYear = ""; // Reset!
} else {
Expand All @@ -364,7 +364,7 @@ private VersionNumberBuildInfo incBuild(AbstractBuild build, Map<String, String>
oBuildsAllTime = makeValid(oBuildsAllTime);
int newVal = buildsAllTime;
try {
if (!oBuildsAllTime.matches(envVarPattern)) {
if (!oBuildsAllTime.matches(ENV_VAR_PATTERN)) {
newVal = Integer.parseInt(oBuildsAllTime);
oBuildsAllTime = ""; // Reset!
} else {
Expand Down

0 comments on commit 9c1a033

Please sign in to comment.