You want to do something like this: def GIT_VER = sh(returnStdout: true, script: 'git tag... | tail -n1')
Each invocation of sh will have it's own environment space. On Fri, Oct 19, 2018, 15:12 <[email protected]> wrote: > Hi, > I have the following steps in my jenkinsfile that work pretty well with > $GIT_VER=some number in the following step only. > > stage('Git Checkout') { > steps { > git(url: 'ssh://mygit/my.git', branch: 'develop') > sh '''export GIT_VER=$(git tag -l [0-9].* --points-at > origin/develop | tail -n1) > > When I add another step in my jenkinsfile environment variable $GIT_VER is > blank. Is there a way to set this variable so it applies to each step in > Jenkinfile? > > Thank you for looking into this issue for me. > > > -- > 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/1482d40a-9e94-4e62-b548-6f91ab469e28%40googlegroups.com > <https://groups.google.com/d/msgid/jenkinsci-users/1482d40a-9e94-4e62-b548-6f91ab469e28%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/CAPiUgVevypbb4%3D19urxE1bAhCpfW%2BX3iKcJZ1Zm%3DrWyqYnZU2Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
