kind: pipeline
name: default
type:
steps:
  - name: build
    image: maven:3.8.1-openjdk-8
    volumes:
      - name: cache # The Volume's name
        path: /root/.m2 # The path in the container
    commands:
      #- mvn help:effective-settings # check maven
      - ls -hl /root/.m2/
      - mvn -version
      - java -version
      - mvn help:effective-settings
      - mvn clean package -DskipTests
      - pwd
      - ls -hl
      - ls -hl railway-admin
      - ls -hl railway-admin/target
  #- name: docker
  #  image: plugins/docker
  #  volumes:
  #    - name: dockersock
  #      path: /var/run/docker.sock
  ##  settings:
  #    username: iamsee
  #    password: zhuotong
      #        from_secret: zhuotong
  #    debug: true
      #      launch_debug: true
      #insecure: true
  #    mirror: https://mgjrzxtn.mirror.aliyuncs.com
  #    #registry: 192.168.1.100:10000
  #    repo: iamsee/railway-admin
      #      purge: true
  #    tags:
  #      - ${DRONE_COMMIT_SHA:1.0.0}
  #      - ${DRONE_COMMIT}
  #      - v1
  #      - latest
  - name: scp_files
    image: appleboy/drone-scp
    settings:
      host: 172.17.0.1
      username: root
      password: $jgkj001
      debug: true
      target: /www/wwwroot/railway.iamsee.com/release
      source: railway-admin/target/railway-admin.jar
      rm: true
  - name: deploy
    image:  appleboy/drone-ssh
    settings:
      host: deploy.iamsee.com
      username: root
      password: $jgkj001
      debug: true
      script:
        - export PATH=/usr/local/bin:$PATH
        - echo $PATH
        - pkill -9 java
        - nohup java -jar /www/wwwroot/railway.iamsee.com/release/railway-admin/target/railway-admin.jar > /www/wwwroot/railway.iamsee.com/out.log 2>&1 &
trigger:
  branch:
    - dev
volumes:
  - name: cache # The name use in this pipeline,
    host:
      path: /tmp/cache # The path be used in the host.
  - name: dockersock
    host:
      path: /var/run/docker.sock
      
