Another option would be to use triple quoted strings to run all the
commands within the same shell execution. You'd have to deal with the env
variables and possibly escaping $ as needed.

sh """TAG=\$(git describe...) | cut -d....
WEB_IMAGE_NAME=${ACR_LOGINSERVER}/.../\$(TAG)
sudo docker...."""


On Wed, May 23, 2018, 09:04 Ramanathan Muthaiah <[email protected]>
wrote:

>         stage('Build image') {
>>             steps {
>>                 sh 'TAG=$(git describe --candidate=1 --tags)'
>>                 sh 'TAG=$(echo $TAG | cut -d\'-\' -f 1)'
>>                 sh 'WEB_IMAGE_NAME=' + env['ACR_LOGINSERVER'] +
>> '/my-project-1499882073260/test:' + env['TAG']
>>
>>                 sh 'sudo docker build -t ${WEB_IMAGE_NAME} -f
>> WebApplication/WebApplication1/Dockerfile WebApplication/.'
>>             }
>>         }
>>
>
> How about like this ?
>
> def tag = sh (returnStdout: true, script: "git describe --candidate=1
> --tags").trim()
> env.TAG = sh (returnStdout: true, script: "echo ${tag} | cut -d\'-\' -f 1"
> ).trim()
>
> I haven't tested this code though, so, cannot guarantee it's success or
> failure, you may want to tweak and customize according to your needs. But,
> it's worth looking at / using the 'sh' step's return status and output.
>
> Remember to use them inside 'script' block if you're using Declarative
> syntax.
>
> /Ram
>
> --
> 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/44d030af-6af6-4f5a-815b-030e89fc5e3f%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/44d030af-6af6-4f5a-815b-030e89fc5e3f%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/CAPiUgVdLgPR-BSF-JeXzqLXG7w2pTvxHCh%2B%2BgoB0pAMwvUh4dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to