Dear Friends,
I'm trying to accomplish this with my pipeline:

   - test a part of my newly produced artifact against some previous 
   artifacts inside a docker base image
   - if they are the same, launch a docker build using dockerfileA, 
   otherwise using dockerfileB
   
I've arrived at this point:

                        docker.image("mybaseimage").inside {
                                try {
                                        ...
                                        sh 'find 
tmp_unzip_path/dependencies -type f -exec md5sum {} + | sort -k 2 | awk 
{\'print $1\'} > dir1.txt'
                                        sh 'find /opt/docker/lib -type f 
-exec md5sum {} + | sort -k 2 | awk {\'print $1\'} > dir2.txt'
                                        //sh 'printenv'
                                        sh '''if [ $(echo $?) -eq 0 ]; then
                                                echo "No changes to the 
dependencies!"
                                        else
                                                echo "Dependencies must be 
updated!"

What I'd like to do is assign the result of if statement to a variable, so 
I can use it to make another choise later on.
I've tried variables, environment variables, but neither is working. This 
is one try for example:

withEnv(["DEP_UNCHANGED=0"]) {
...
same code as before
sh '''if [ $(echo $?) -eq 0 ]; then
     DEP_UNCHANGED=0
else 
    DEP_UNCHANGED=1
...
}

This says that DEP_UNCHANGED is not defined. Ironically enough if I do this:

withEnv(["DEP_UNCHANGED=0"]) {
...
same code as before
sh '''if [ $(echo $?) -eq 0 ]; then
     $DEP_UNCHANGED=0
else 
    $DEP_UNCHANGED=1
...
}

it complains that 0 = 0, so it IS defined I guess....
printenv also does print DEP_UNCHANGED=0, so it IS defined?

What is the proper way to accomplish this?
Thank you so much,
Best regards,
Roberto

-- 
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/dd51bf00-0f05-4098-aed7-9e993d5c16c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to