0

I have in a file a placeholder GitHash and want to replace this with the git commit short sha hash and use sed for example.

This should be done in a pipeline job in GitLab.

So I wrote following into my .gitlab-ci.yml file:

set-revesion:
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  stage: Set
  script: 
    - apk update
    - apk add zip # Because it is a .odt which needs to be unpacked
    - mkdir MyFile
    - unzip MyFile.odt -d unpack
    - cd unpack
    - sed -e 's|GitHash|${$CI_COMMIT_SHORT_SHA}|g' -i content.xml
    - sed -e 's|GitHash|${$CI_COMMIT_SHORT_SHA}|g' -i styles.xml
    - zip -r ../MyFile/MyFile.odt .
  artifacts:
    when: always
    paths:
      - Specification/    
N0cynym
  • 1
  • 1
  • 1
    What is the question? Suppose your `sed` commands succeed, what next? – phd Jan 06 '23 at 07:06
  • sed replace `GitHash` with `$CI_COMMIT_SHORT_SHA`. – N0cynym Jan 06 '23 at 07:12
  • I want to let `$CI_COMMIT_SHORT_SHA` be the sha short of the last commit. – N0cynym Jan 06 '23 at 07:13
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jan 06 '23 at 07:15
  • https://stackoverflow.com/search?q=%5Bbash%5D+difference+quotes – phd Jan 06 '23 at 07:16
  • @N0cynym You need double quotes: `sed -e "s|GitHash|${$CI_COMMIT_SHORT_SHA}|g" -i content.xml` instead of single (apostrophes). – phd Jan 06 '23 at 07:17
  • This works correctly: `- sed -e "s|GitHash|$CI_COMMIT_SHORT_SHA|g" -i content.xml` – N0cynym Jan 06 '23 at 07:24

0 Answers0