# You can copy and paste this template into a new `.gitlab-ci.yml` file.
# You should not add this template to an existing `.gitlab-ci.yml` file by using the `include:` keyword.
#
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Bash.gitlab-ci.yml

# See https://docs.gitlab.com/ee/ci/yaml/index.html for all available options

# you can delete this line if you're not using Docker
#image: busybox:latest



#before_script:
#  - echo "Before script section by Cliff"
#  - echo "For example you might run an update here or install a build dependency"
#  - echo "Or perhaps you might print out some debugging details"

#after_script:
#  - echo "After script section"
#  - echo "For example you might do some cleanup here"

job:on-schedule:
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule"
  script:
    - echo "This is a job for schedule"
    - ssh -llhy 192.168.77.168 "cd /workdir/lhy/wanghuo-rc/ && ./do_all.sh -m ft2004 -r rel-v1.0.0-rc2 --download-dir /workdir/lhy/yocto/downloads/ --sstate-dir /workdir/lhy/yocto/sstate-cache/"
    - rm -rf /tftpboot/*
    - scp lhy@192.168.77.168:/workdir/lhy/wanghuo-rc/build_ft2004/tmp/deploy/images/ft2004/uImage /tftpboot
    - scp lhy@192.168.77.168:/workdir/lhy/wanghuo-rc/build_ft2004/tmp/deploy/images/ft2004/wanghuo-image-minimal-ft2004.cpio.gz.u-boot /tftpboot/core.cpio.gz.u-boot
    - scp lhy@192.168.77.168:/workdir/lhy/wanghuo-rc/build_ft2004/tmp/deploy/images/ft2004/ft2004c-devboard-dsk.dtb /tftpboot/ft2004.dtb
    - cd /home/ucas/lhy-test
    - ./ssh-rc.sh
    - ssh -lroot -o StrictHostKeyChecking=no 192.168.77.3 "reboot"
    - cd /home/ucas/lhy-test
    - ./ping.sh
    - sleep 10
    - ./ssh-rc.sh
    - lavacli --uri http://lhy0407:lhy-0407@localhost/RPC2/ jobs submit /home/ucas/lhy-test/yaml/wanghuo-base.yaml

job1:on-schedule:
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule"
  script:
    - echo "This is a job for schedule"
    - ssh -llhy 192.168.77.168 "cd /workdir/lhy/wanghuo-rc/ && ./do_all.sh -m ft2004 -r rel-v1.0.0-rc2 --download-dir /workdir/lhy/yocto/downloads/ --sstate-dir /workdir/lhy/yocto/sstate-cache/"
    - scp lhy@192.168.77.168:/workdir/lhy/wanghuo-rc/build_ft2004/tmp/deploy/images/ft2004/Image /home/ucas/lhy-test/qemu
    - scp lhy@192.168.77.168:/workdir/lhy/wanghuo-rc/build_ft2004/tmp/deploy/images/ft2004//home/phytium/wanghuo-image-minimal-ft2004.ext4 /home/phytium/core-image-minimal-ft2004-evm.ext4
    - lavacli --uri http://lhy0407:lhy-0407@localhost/RPC2/ jobs submit /home/ucas/lhy-test/yaml/test-qemu.yaml


job2:
  only:
    - tags
  script:
    - echo "This is a job for tag"
    - ssh -llhy 192.168.77.168 "cd /workdir/lhy/wanghuo-rc/ && ./do_all.sh -m ft2004 -r rel-v1.0.0-rc2 --download-dir /workdir/lhy/yocto/downloads/ --sstate-dir /workdir/lhy/yocto/sstate-cache/"
    - rm -rf /tftpboot/*
    - scp lhy@192.168.77.168:/workdir/lhy/wanghuo-rc/build_ft2004/tmp/deploy/images/ft2004/uImage /tftpboot
    - scp lhy@192.168.77.168:/workdir/lhy/wanghuo-rc/build_ft2004/tmp/deploy/images/ft2004/wanghuo-image-minimal-ft2004.cpio.gz.u-boot /tftpboot/core.cpio.gz.u-boot
    - scp lhy@192.168.77.168:/workdir/lhy/wanghuo-rc/build_ft2004/tmp/deploy/images/ft2004/ft2004c-devboard-dsk.dtb /tftpboot/ft2004.dtb
    - cd /home/ucas/lhy-test
    - ./ssh-rc.sh
    - ssh -lroot -o StrictHostKeyChecking=no 192.168.77.3 "reboot"
    - cd /home/ucas/lhy-test
    - ./ping.sh
    - sleep 10
    - ./ssh-rc.sh
    - lavacli --uri http://lhy0407:lhy-0407@localhost/RPC2/ jobs submit /home/ucas/lhy-test/yaml/wanghuo-base.yaml

job3:
  only:
    - tags
  script:
    - echo "This is a job for tag"
    - ssh -llhy 192.168.77.168 "cd /workdir/lhy/wanghuo-rc/ && ./do_all.sh -m ft2004 -r rel-v1.0.0-rc2 --download-dir /workdir/lhy/yocto/downloads/ --sstate-dir /workdir/lhy/yocto/sstate-cache/"
    - scp lhy@192.168.77.168:/workdir/lhy/wanghuo-rc/build_ft2004/tmp/deploy/images/ft2004/Image /home/ucas/lhy-test/qemu
    - scp lhy@192.168.77.168:/workdir/lhy/wanghuo-rc/build_ft2004/tmp/deploy/images/ft2004//home/phytium/wanghuo-image-minimal-ft2004.ext4 /home/phytium/core-image-minimal-ft2004-evm.ext4
    - lavacli --uri http://lhy0407:lhy-0407@localhost/RPC2/ jobs submit /home/ucas/lhy-test/yaml/test-qemu.yaml