Sign inSign up

sinlov/drone-file-browser-plugin

By sinlov

Updated about 2 years ago

drone CI to support https://github.com/filebrowser/filebrowser

Image
0

3.1K

sinlov/drone-file-browser-plugin repository overview

go-ubuntu GoDoc GoReportCard codecov docker version semver docker image size docker pulls github release

for what

  • this project used to drone CI to support file browser
  • get file browser host like https://filebrowser.xxx.com
  • this plugin need file browser username
  • and need file browser user need password

Pipeline Settings (.drone.yml)

  • sample
steps:
  - name: drone-file-browser-send
    image: sinlov/drone-file-browser-plugin:latest
    # pull: if-not-exists
    settings:
      # debug: false # plugin debug switch
      file_browser_host: "http://127.0.0.1:80" # must set args, file_browser host like http://127.0.0.1:80
      file_browser_username: # must set args, file_browser username
        # https://docs.drone.io/pipeline/environment/syntax/#from-secrets
        from_secret: file_browser_user_name
      file_browser_user_password: # must set args, file_browser user password
        from_secret: file_browser_user_password
      file_browser_remote_root_path: dist/ # must set args, send to file_browser base path
      file_browser_target_file_globs: # must set args, globs list of send to file_browser under file_browser_target_dist_root_path
        - "**/*.tar.gz"
        - "**/*.sha256"
      file_browser_share_link_expires: 0 # if set 0, will allow share_link exist forever,default: 0
      file_browser_share_link_unit: days # take effect by open share_link, only can use as [ days hours minutes seconds ]
      file_browser_share_link_auto_password_enable: true # password of share_link auto , if open this will cover settings.file_browser_share_link_password. default: false
  • full config
steps:
  - name: drone-file-browser-send
    image: sinlov/drone-file-browser-plugin:latest
    # pull: if-not-exists
    settings:
      debug: false # plugin debug switch
      timeout_second: 10 # api timeout default: 10
      file_browser_timeout_push_second: 60 # push each file timeout push second, must gather than 60.default: 60
      file_browser_host: # must set args, file_browser host like http://127.0.0.1:80
          from_secret: file_browser_host
      file_browser_username: # must set args, file_browser username
          # https://docs.drone.io/pipeline/environment/syntax/#from-secrets
          from_secret: file_browser_user_name
      file_browser_user_password: # must set args, file_browser user password
          from_secret: file_browser_user_password
      file_browser_work_space: "" # file_browser work space. default "" will use env:DRONE_WORKSPACE
      file_browser_work_mode: send # 1.0 only support send
      file_browser_remote_root_path: dist/ # must set args, send to file_browser base path
      file_browser_dist_type: custom # must set args, type of dist file graph only can use: git, custom
      file_browser_dist_graph: "{{ Repo.HostName }}/{{ Repo.GroupName }}/{{ Repo.ShortName }}/s/{{ Build.Number }}/{{ Stage.Name }}-{{ Build.Number }}-{{ Stage.FinishedTime }}" # type of dist custom
      file_browser_target_dist_root_path: dist/ # path of file_browser work on root, can set "". default: ""
      file_browser_target_file_globs: # must set args, globs list of send to file_browser under file_browser_target_dist_root_path
        - "**/*.tar.gz"
        - "**/*.sha256"
      file_browser_target_file_regular: .*.tar.gz # must set args, regular of send to file_browser under file_browser_target_dist_root_path
      file_browser_share_link_enable: true # share dist dir as link, default: true
      file_browser_share_link_expires: 0 # if set 0, will allow share_link exist forever,default: 0
      file_browser_share_link_unit: days # take effect by open share_link, only can use as [ days hours minutes seconds ]
      file_browser_share_link_password: "" # password of share_link, if not set will not use password, default: ""
      file_browser_share_link_auto_password_enable: false # password of share_link auto , if open this will cover settings.file_browser_share_link_password. default: false
    when:
      event: # https://docs.drone.io/pipeline/exec/syntax/conditions/#by-event
        - promote
        - rollback
        - push
        - pull_request
        - tag
      status: # only support failure/success,  both open will send anything
        - failure
        # - success
steps:
  - name: drone-file-browser-send-exec # must has env EXEC_DRONE_FILE_BROWSER_FULL_PATH and exec tools
    environment:
      PLUGIN_DEBUG: false
      # PLUGIN_NTP_TARGET: "pool.ntp.org" # if not set will not sync
      PLUGIN_TIMEOUT_SECOND: 10 # default 10
      PLUGIN_FILE_BROWSER_TIMEOUT_PUSH_SECOND: 60 # push each file timeout push second, must gather than 60.default: 60
      PLUGIN_FILE_BROWSER_HOST: "http://127.0.0.1:80" # must set args, file_browser host like http://127.0.0.1:80
      PLUGIN_FILE_BROWSER_USERNAME: # must set args, file_browser username
        # https://docs.drone.io/pipeline/environment/syntax/#from-secrets
        from_secret: file_browser_user_name
      PLUGIN_FILE_BROWSER_USER_PASSWORD: # must set args, file_browser user password
        from_secret: file_browser_user_password
      # must set args, send to file_browser base path
      PLUGIN_FILE_BROWSER_REMOTE_ROOT_PATH: dist/
      # path of file_browser work on root, can set "". default: ""
      PLUGIN_FILE_BROWSER_TARGET_DIST_ROOT_PATH: ""
      # must set args, globs list of send to file_browser under file_browser_target_dist_root_path
      PLUGIN_FILE_BROWSER_TARGET_FILE_GLOBS: "**/*.tar.gz,**/*.sha256"
      # must set args, regular of send to file_browser under file_browser_target_dist_root_path
#      PLUGIN_FILE_BROWSER_TARGET_FILE_REGULAR: .*.tar.gz
      PLUGIN_FILE_BROWSER_SHARE_LINK_EXPIRES: 0 # if set 0, will allow share_link exist forever,default: 0
      PLUGIN_FILE_BROWSER_SHARE_LINK_UNIT: days # take effect by open share_link, only can use as [ days hours minutes seconds ]
      PLUGIN_FILE_BROWSER_SHARE_LINK_AUTO_PASSWORD_ENABLE: true # password of share_link auto , if open this will cover settings.file_browser_share_link_password. default: false
    commands:
      - ${EXEC_DRONE_FILE_BROWSER_FULL_PATH} `
        ""
    when:
      event: # https://docs.drone.io/pipeline/exec/syntax/conditions/#by-event
        - promote
        - rollback
        - push
        - pull_request
        - tag
      status: # only support failure/success,  both open will send anything
        - failure
        - success
settings.debug
  • if open settings.debug will try send file browser use override for debug.
  • please close settings.debug in production models
file_browser_dist_type
  • if use file_browser_dist_type = git, send to filebrowser file tree like
# not use tag
${file_browser_remote_root_path}/
	{{Repo.HostName}}/
		{{Repo.GroupName}}/
			{{Repo.ShortName}}/
				b/
					{{Build.Number}}/
						{{Commit.Branch}}/
							{{Commit.Sha[0:8]}}

# use tag
${file_browser_remote_root_path}/
	{{Repo.HostName}}/
		{{Repo.GroupName}}/
			{{Repo.ShortName}}/
				tag/
					{{Build.Tag}}/
						{{Build.Number}}/
							{{Commit.Sha[0:8]}}
  • you can use file_browser_dist_type = custom, like
{{ Repo.HostName }}/{{ Repo.GroupName }}/{{ Repo.ShortName }}/s/{{ Build.Number }}/{{ Stage.Name }}-{{ Build.Number }}-{{ Stage.FinishedTime }}

template use struct Drone

Tag summary

Content type

Image

Digest

sha256:27eb06de3

Size

6.4 MB

Last updated

about 2 years ago

docker pull sinlov/drone-file-browser-plugin