title: Sed failing to replace string in quotes during Gitlab CI
body: <p>I am trying to dynamically set the image name and tag for AWS Elastic Beanstalk in my Dockerrun.aws.json file:</p>
  
  <pre><code>"Image": {
    "Name": "IMAGETAG",
    "Update": "true"
  }
  </code></pre>
  
  <p>with the following sed command as a script in my GitLab CI file:</p>
  
  <pre><code>sed -i.bak "s|IMAGETAG|$CONTAINER_TEST_IMAGE|" Dockerrun.aws.json &amp;&amp; rm Dockerrun.aws.json.bak; eb deploy Production
  </code></pre>
  
  <p>Where <code>$CONTAINER_TEST_IMAGE</code> is a verified good environment variable (tested by doing <code>echo $CONTAINER_TEST_IMAGE</code> as a script). <code>$CONTAINER_TEST_IMAGE</code> contains the structure of the following content (where ... is the full id): </p>
  
  <pre><code>gitlab.company.com:123/my-group/my-project:core_7de09851...8f_testing
  </code></pre>
  
  <p>The problem I am facing is that sed does not work during the CI pipeline. I am failing to understand why considering if I set the environment variable locally and run the same command, it will successfully replace the value of <code>Name</code> to the same structure URL. This testing was done on a Macbook.</p>
  
  <p>I know that it is not updating the file because the Gitlab CI log reports</p>
  
  <pre><code>WARN: Failed to pull Docker image IMAGETAG:latest, retrying...
  </code></pre>
  
  <p>I've tried a few things that did not work:</p>
  
  <ul>
  <li>Running the <code>sed</code> and <code>eb deploy</code> commands as separate scripts (two different lines in the CI file)</li>
  <li>Switch the variable that I am seeking to replace in Dockerrun.aws.json to <code>&lt;IMAGE&gt;</code></li>
  <li>While it was at <code>&lt;IMAGE&gt;</code>, running <code>sed -i='' "s|&lt;IMAGE&gt;|$CONTAINER_RELEASE_IMAGE|" Dockerrun.aws.json</code> instead of doing the .bak and then rm'ing it (I read somewhere that sed has inconsistencies on OSX with the -i='' version)</li>
  </ul>
  
  <p>Does anyone have any thoughts on what the issue might be and how it can be resolved?</p>