Get value of package.json in gitLab CI YML

后端 未结 6 2158
小鲜肉
小鲜肉 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:36

    variables:

    PACKAGE_VERSION: $(cat package.json | grep version | head -1 | awk -F= "{ print $2 }" | sed 's/[version:,\",]//g' | tr -d '[[:space:]]')  `
    

    in your job or template

    .package-template: &package_template 
    image: docker-hub.registry.integ.fr.auchan.com/docker:latest
    stage: package 
    tags: 
      - stocks
    script:
      - export VERSION= ``eval $PACKAGE_VERSION``
      - echo "======> Getting VERSION:  $VERSION" `
    

提交回复
热议问题