main: push: - docker: # 声明式的构建环境 https://docs.cnb.cool/ # 可以去dockerhub上 https://hub.docker.com/_/maven 找到您需要maven和jdk版本 image: maven:3.8.6-openjdk-8 volumes: # 声明式的构建缓存 https://docs.cnb.cool/zh/grammar/pipeline.html#volumes - /root/.m2:copy-on-write # 导入环境变量,【环境变量】https://docs.cnb.cool/zh/env.html imports: https://cnb.cool/examples/secrets/-/blob/main/springboot-maven-ssh-config.yml stages: - name: mvn package script: # 合并./settings.xml和/root/.m2/settings.xml - mvn clean package -s ./settings.xml - name: 使用SCP插件(用户名+密码) # SCP插件:通过ssh复制文件或者代码,可选择用户名+密码或私钥,https://docs.cnb.cool/zh/plugins/public/open-source/scp/scp # 想查看更多插件及其用法请移步,【插件市场】https://docs.cnb.cool/zh/plugins.html image: appleboy/drone-scp settings: # 环境变量用法参考,【环境变量】https://docs.cnb.cool/zh/env.html host: - ${REMOTE_HOST} username: ${REMOTE_USERNAME} password: ${REMOTE_PASSWORD} port: ${REMOTE_PORT} target: /test source: ./target/maven-deploy-0.1-SNAPSHOT.jar # - name: 使用SCP插件(私钥) # image: appleboy/drone-scp # settings: # host: # - ${REMOTE_HOST} # key: ${PRIVATE_KEY} # port: ${REMOTE_PORT} # target: /test # source: ./target/maven-deploy-0.1-SNAPSHOT.jar - name: 使用SSH插件(用户名+密码) # SSH插件:通过ssh在远端host执行命令,可选择用户名+密码或私钥,https://docs.cnb.cool/zh/plugins/public/open-source/ssh/ssh image: appleboy/drone-ssh settings: host: - ${REMOTE_HOST} username: ${REMOTE_USERNAME} password: ${REMOTE_PASSWORD} port: ${REMOTE_PORT} command_timeout: 2m script: - jps -l # - name: 使用SSH插件(私钥) # image: appleboy/drone-ssh # settings: # host: # - ${REMOTE_HOST} # key: ${PRIVATE_KEY} # port: ${REMOTE_PORT} # command_timeout: 2m # script: # - cd /test/target # - nohup java -jar ./maven-deploy-0.1-SNAPSHOT.jar > output.log 2>&1 &