# 自定义生命周期 stages: - build_project - build_image cache: key: files: - package.json paths: - node_modules - dist/ before_script: - export CNUI_TAG=$(date +%Y%m%d%H%M%S) build_project: stage: build_project script: - echo "npm install ..." - npm install --save-dev --unsafe-perm - echo "npm run build" - npm run build only: - dev_copy - tags tags: - GN-XXG-Server build_image: stage: build_image script: - echo "docker build" - sudo docker build -t cn-ui:$CNUI_TAG . - echo "docker tag" - sudo docker tag cn-ui:$CNUI_TAG 192.168.40.153:9080/cyber-narrator/cn-ui:$CNUI_TAG - echo "docker push" - sudo docker push 192.168.40.153:9080/cyber-narrator/cn-ui:$CNUI_TAG when: on_success only: - dev_copy tags: - GN-XXG-Server build_release_image: stage: build_image script: - echo 'tag名称是' - echo $CI_COMMIT_TAG - echo '提交的版本是' - echo $CI_COMMIT_REF_NAME - echo "docker build" - sudo docker build -t cn-ui:$CI_COMMIT_TAG . - echo "docker tag" - sudo docker tag cn-ui:$CI_COMMIT_TAG 192.168.40.153:9080/cyber-narrator/cn-ui:$CI_COMMIT_TAG - echo "docker push" - sudo docker push 192.168.40.153:9080/cyber-narrator/cn-ui:$CI_COMMIT_TAG only: - tags tags: - GN-XXG-Server