Skip to content
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

Adding functionality to limit the number of characters from a variable #12

Merged
merged 2 commits into from
Mar 4, 2017

Conversation

joemar1988
Copy link
Contributor

(anything else with substring) Any other argument in the following format ${ARGUMENT, "n"} or ${ARGUMENT, "-n"} where ARGUMENT is your environment variable and n is a whole number. This can be used to limit the size of the environment variable you are using, taking the first "n" characters or the last "-n" characters from the variable.

…any variable that isn't specifically part of the defined variables. This lets us take the last 4 characters from the svn revision as that is all we need for one section of our version and the first 2 characters for another.
@jenkinsadmin
Copy link
Member

Thank you for this pull request! Please check this document for how the Jenkins project handles pull requests.

@DenizThatMenace
Copy link
Contributor

This seems to work, although it took me some time to figure out, how and where exactly this should be used.

This brings me to two things that are missing before this pull-request can be accepted.

  1. Some help/documentation.
    Probably you should extend the help-message for the Version Number Format String text-field.
  2. Tests
    Please add a test which explicitly tests the different cases. Not only test the ones that are expected to work but also those that are expected to fail.

Just as a side-note:
Should ${VARIABLE, "+5"} do the same as ${VARIABLE, "5"}? (It does not.)

@joemar1988
Copy link
Contributor Author

Thanks for letting me know. I will get these updates in as soon as possible.

…lly to escape the quotes. Updated the VersionNumberBuilder.java to handle 5 or +5. Added JUnit Tests for testing the functionality.
@DenizThatMenace DenizThatMenace merged commit d9536e4 into jenkinsci:master Mar 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants