drone-env-printer

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

README

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

for what

  • this project used to drone CI

Pipeline Settings (.drone.yml)

1.x

steps:
  - name: drone-env-printer
    image: sinlov/drone-env-printer:latest
    pull: if-not-exists
    settings:
      debug: false
      env_printer_print_keys:
        - GOPATH
        - GOBIN
  • full config
steps:
  - name: drone-env-printer
    image: sinlov/drone-env-printer:latest
    pull: if-not-exists
    settings:
      debug: false
      env_printer_print_keys:
        - GOPATH
        - GOBIN
      env_printer_padding_left_max: 42
  • 1.x drone-exec only support env

  • download by https://github.com/sinlov/drone-env-printer/releases to get platform binary, then has local path

  • binary path like C:\Drone\drone-runner-exec\plugins\drone-env-printer.exe can be drone run env like EXEC_DRONE_ENV_PRINTER_PLUGIN_FULL_PATH

  • env:EXEC_DRONE_ENV_PRINTER_PLUGIN_FULL_PATH can set at file which define as DRONE_RUNNER_ENVFILE to support each platform

steps:
  - name: drone-env-printer-exec # must has env EXEC_DRONE_ENV_PRINTER_PLUGIN_FULL_PATH and exec tools
    environment:
      PLUGIN_DEBUG: false
      PLUGIN_ENV_PRINTER_PRINT_KEYS: "GOPATH,GOBIN"
      PLUGIN_ENV_PRINTER_PADDING_LEFT_MAX: 42
    commands:
      - ${EXEC_DRONE_ENV_PRINTER_PLUGIN_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

Features

dev

depends

in go mod project

# warning use private git host must set
# global set for once
# add private git host like github.com to evn GOPRIVATE
$ go env -w GOPRIVATE='github.com'
# use ssh proxy
# set ssh-key to use ssh as http
$ git config --global url."git@github.com:".insteadOf "https://github.com/"
# or use PRIVATE-TOKEN
# set PRIVATE-TOKEN as gitlab or gitea
$ git config --global http.extraheader "PRIVATE-TOKEN: {PRIVATE-TOKEN}"
# set this rep to download ssh as https use PRIVATE-TOKEN
$ git config --global url."ssh://github.com/".insteadOf "https://github.com/"

# before above global settings
# test version info
$ git ls-remote -q https://github.com/sinlov/drone-env-printer.git

- test code

add env then test

```bash
export PLUGIN_MSG_TYPE=post \
  export PLUGIN_WEBHOOK=7138d7b3-abc
make test
  • see help
make dev

update main.go file set env then and run

export PLUGIN_MSG_TYPE= \
  export PLUGIN_WEBHOOK= \
  export DRONE_REPO=sinlov/drone-env-printer \
  export DRONE_REPO_NAME=drone-env-printer \
  export DRONE_REPO_NAMESPACE=sinlov \
  export DRONE_REMOTE_URL=https://github.com/sinlov/drone-env-printer \
  export DRONE_REPO_OWNER=sinlov \
  export DRONE_COMMIT_AUTHOR=sinlov \
  export DRONE_COMMIT_AUTHOR_AVATAR=  \
  export DRONE_COMMIT_AUTHOR_EMAIL=sinlovgmppt@gmail.com \
  export DRONE_COMMIT_BRANCH=main \
  export DRONE_COMMIT_LINK=https://github.com/sinlov/drone-env-printer/commit/68e3d62dd69f06077a243a1db1460109377add64 \
  export DRONE_COMMIT_SHA=68e3d62dd69f06077a243a1db1460109377add64 \
  export DRONE_COMMIT_REF=refs/heads/main \
  export DRONE_COMMIT_MESSAGE="mock message commit" \
  export DRONE_STAGE_STARTED=1674531206 \
  export DRONE_STAGE_FINISHED=1674532106 \
  export DRONE_BUILD_STATUS=success \
  export DRONE_BUILD_NUMBER=1 \
  export DRONE_BUILD_LINK=https://drone.xxx.com/sinlov/drone-env-printer/1 \
  export DRONE_BUILD_EVENT=push \
  export DRONE_BUILD_STARTED=1674531206 \
  export DRONE_BUILD_FINISHED=1674532206
  • then run
make run

docker

# then test build as test/Dockerfile
$ make dockerTestRestartLatest
# if run error
# like this error
# err: missing webhook, please set webhook
#  fix env settings then test

# see run docker fast
$ make dockerTestRunLatest

# clean test build
$ make dockerTestPruneLatest

# see how to use
$ docker run --rm sinlov/drone-env-printer:latest -h

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL