Thank you for your reply.
I did try what you had suggested, but it did not work. But i could be doing
something wrong as well.
Here is my step.
pipeline {
agent any
stages {
stage('Checkout') {
steps {
script {
git(url: 'ssh://my.git', branch: 'testing', changelog: true)
//git(url: 'ssh://my.git', branch: 'testing')
//def GIT_VERSION=$(git tag -l [0-9].* --points-at origin/testing
| tail -n1)
//def GIT_VERSION = sh(returnStdout: true, script: 'git tag -l
[0-9].* --points-at testing | tail -n1')
sh '''
export GIT_VERSION=$(git tag -l [0-9].* --points-at origin/testing | tail
-n1)
echo $GIT_VERSION'''
}
}
}
}
stage('Parallel Deployment') {
parallel {
stage('Deployments') {
steps {
sh '''echo "Package deployment to all servers"
echo $GIT_VERSION'''
}
}
stage('server1') {
steps {
sh '''scp myapp-${GIT_VER}-${BUILD_NUMBER}.build'''
}
}
stage('server2') {
steps {
sh '''scp myapp-${GIT_VER}-${BUILD_NUMBER}.build'''
}
}
}
}
}
Basically I need to get $GIT_VER into my parallel step.
Thanks for looking into this.
Regards,
On Friday, October 19, 2018 at 4:46:18 PM UTC-7, slide wrote:
>
> 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] <javascript:>> 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] <javascript:>.
>> 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/3381cf00-78a3-430d-aeaf-9cbe0b0fc209%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.