image: node:latest stages: -install-test-dist # cache node_modules in package.json as long as the package.json content is not changed, cache: key: files: -package. json paths: -node_modules # Define job install: stage: install script: - npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ - npm install - registry=http://registry.npm.taobao.org # define the job code validation code - lint: stage: the test script: - NPM run lint allow_failure: Job # Compile job build-dist: stage: build-dist before_script: - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' - eval $(ssh-agent -s) - echo $SSH_PRIVATE_KEY "|" tr -d '\ r | SSH - add - the mkdir -p ~ /. SSH - chmod 700 ~ /. SSH, SSH ssh-keyscan 115.159.52.223 > > ~/.ssh/known_hosts - chmod 644 ~/.ssh/known_hosts script: - NPM run build - SCP - r dist [email protected]: / usr/local/WWW artifacts: paths: - dist only: # only compile on the master branch in order to be able to -masterCopy the code
Usr /local/ WWW: directory to which the server nginx agent points
SSH_PRIVATE_KEY: specifies the private key used for encryption-free login
Use public Runner