echo "${BRANCH_NAME.replaceAll('^.*/','')}"

or

sh 'echo "${BRANCH_NAME}" | sed -e "s:^.*/::"'

Note the second one needs the careful quoting so that the shell does the
expansion

On 12 December 2017 at 13:04, Paul McGregory <[email protected]>
wrote:

> Hi Everybody.
>
>
> I am using multibranch pipeline.
>
> The deployment works fine, but ein want get the BranchName only, instead the 
> full branchname path.
>
>
> e.g I am using echo "${env.BRANCH_NAME}" and get "feature/1234", but I just 
> want "1234".
>
>
> If found something like echo "${env.BRANCH_NAME}#*feature/" or 
> "${env.BRANCH_NAME}##feature/", but this doesnt work with the pipeline
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/jenkinsci-users/deef32e8-98ab-42ba-9ac2-b30238e6e4c3%40googlegroups.
> com
> <https://groups.google.com/d/msgid/jenkinsci-users/deef32e8-98ab-42ba-9ac2-b30238e6e4c3%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CA%2BnPnMz2FYm7i-E_%3DDa91Q3JkXqF%2BetDCxF%2BQDMVprD9Snd9qw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to