Get value of package.json in gitLab CI YML

后端 未结 6 2168
小鲜肉
小鲜肉 2021-02-13 03:25

I\'m using gitLab CI for my nodejs application. In my YML file I need to call a script to build a docker image. But instead of using latest I need to use the curren

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-13 03:41

    If you are not against installing additional packages you can use jq which allows for much more flexibility (available in repository for both Ubuntu and Alpine). Once you install it (for example apt-get update && apt-get install -yqq jq on Ubuntu):

    - export VERSION=$(cat package.json | jq -r .version)
    - cd /opt/core/bundle && docker build -t $CI_REGISTRY_IMAGE:$VERSION .
    - docker push $CI_REGISTRY_IMAGE:$VERSION
    

提交回复
热议问题