# 自定义生命周期 stages: - gen_git-log - build_project - test - build_image cache: key: files: - package.json paths: - node_modules # - dist/ before_script: - export CNUI_TAG=$(date +%Y%m%d%H%M%S) generate_git-log: stage: gen_git-log script: - if (( `grep git-log.html ./public/index.html | wc -l` == 0 )); then sed -i 's++R\n+g' ./public/index.html; echo "添加更新记录链接"; fi; - echo "最近的100个提交记录" - echo "
" > ./public/git-log.html
    - "git log -100 --pretty=format:'%ad : %s' >> ./public/git-log.html"
    - echo "
" >> ./public/git-log.html - echo "处理 git-log.html 结束" artifacts: paths: - public/index.html - public/git-log.html only: - dev tags: - galaxy build_project: stage: build_project script: - echo "npm install ..." - npm install --save-dev --unsafe-perm - echo "npm run build" - npm run build artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME" when: on_success paths: - dist/ only: - dev - tags tags: - galaxy test: stage: test script: - cnpm run test when: on_success only: - dev tags: - galaxy build_image: dependencies: - build_project stage: build_image script: - echo "docker build" - sudo docker build --no-cache -t cn-ui-$CI_COMMIT_REF_NAME:$CNUI_TAG . - echo "docker tag" - sudo docker tag cn-ui-$CI_COMMIT_REF_NAME:$CNUI_TAG 192.168.40.153:9080/cyber-narrator/cn-ui-$CI_COMMIT_REF_NAME:$CNUI_TAG - echo "docker push" - sudo docker push 192.168.40.153:9080/cyber-narrator/cn-ui-$CI_COMMIT_REF_NAME:$CNUI_TAG when: on_success only: - dev tags: - galaxy build_release_image: dependencies: - build_project stage: build_image script: - echo 'tag名称是' - echo $CI_COMMIT_TAG - echo '提交的版本是' - echo $CI_COMMIT_REF_NAME - echo "docker build" - sudo docker build --no-cache -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: - galaxy