Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-13784

Environment Variables do not replace in shell scripts

      Here is my shell script:

      echo ${BUILD_NUMBER};
      echo ${SERVER};

      sed -e 's/NSString *SERVER = @"[A-Z0-9]*";/NSString *SERVER = @"${SERVER}";/g'

      Here is the output when the build runs. Notice the second ${SERVER} is not replaced.

      + echo 98
      98
      + echo CI1
      CI1
      + sed -e 's/NSString *SERVER = @"[A-Z0-9]*";/NSString *SERVER = @"${SERVER}";/g'

          [JENKINS-13784] Environment Variables do not replace in shell scripts

          nobody added a comment -

          The title of the issue is somewhat misleading. The environment variables are being replaced as evidenced by the echo statements. The problem appears to be with the sed command. I copied it and attempted to run it from the command line but it doesn't complete. If it won't complete from the command line then I wouldn't expect it to run when put in a shell script.

          nobody added a comment - The title of the issue is somewhat misleading. The environment variables are being replaced as evidenced by the echo statements. The problem appears to be with the sed command. I copied it and attempted to run it from the command line but it doesn't complete. If it won't complete from the command line then I wouldn't expect it to run when put in a shell script.

          nobody added a comment -

          From what I can tell, doesn't appear to be a problem with environment variables replacing.

          nobody added a comment - From what I can tell, doesn't appear to be a problem with environment variables replacing.

          I had the same issue where Jenkins environment variables would not replace when surrounded by quotes, but for some reason putting it inside single quotes first worked for me, as in below:

          play 'set version:="'${BUILD_ID}'"' 'session save';

          Rebecca Grenier added a comment - I had the same issue where Jenkins environment variables would not replace when surrounded by quotes, but for some reason putting it inside single quotes first worked for me, as in below: play 'set version:="'${BUILD_ID}'"' 'session save';

            richscze nobody
            booyah Brian Booyah
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: