Configuration Secrets used by drone

Keywords: Linux curl github sudo

Repository secrets are used to store passwords, secret keys, tokens and other confidential information.
repository secrets can be configured in the setting interface of the warehouse

Usage:

kind: pipeline
name: default

steps:
- name: build
  image: alpine
  environment:
    USERNAME:
      from_secret: docker_username
    PASSWORD:
      from_secret: docker_password

However, in the case that the secrets of all repositories are the same, the configuration is troublesome every time, and organization secrets is required at this time. Organization secrets can be used by any Repository that belongs to the organization.
To configure Organization secrets, you need to install drone's command-line tools first
Drone's command line is an important tool to provide drone to manage users and repository settings
1. Install drone cli (linux):

curl -L https://github.com/drone/drone-cli/releases/latest/download/drone_linux_amd64.tar.gz | tar zx
sudo install -t /usr/local/bin drone

Other installation methods: https://docs.drone.io/cli/install/
To configure the drone server address and token:

export DRONE_SERVER=http://drone.mycompany.com
export DRONE_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9

Information can be obtained in the user setting interface

Now you can use the drone command line tool
2. Use drone cli
Command line arguments

# drone -h
NAME:
   drone - command line utility

USAGE:
   drone [global options] command [command options] [arguments...]

VERSION:
   1.2.0

COMMANDS:
     build      manage builds
     cron       manage cron jobs
     log        manage logs
     encrypt    encrypt a secret
     exec       execute a local build
     info       show information about the current user
     repo       manage repositories
     user       manage users
     secret     manage secrets
     server     manage servers
     queue      queue operations
     orgsecret  manage organization secrets
     autoscale  manage autoscaling
     fmt        format the yaml file
     convert    convert legacy format
     lint       lint the yaml file
     sign       sign the yaml file
     jsonnet    generate .drone.yml from jsonnet
     starlark   generate .drone.yml from starlark
     plugins    plugin helper functions
     help, h    Shows a list of commands or help for one command

GLOBAL OPTIONS:
   -t value, --token value   server auth token [$DRONE_TOKEN]
   -s value, --server value  server address [$DRONE_SERVER]
   --autoscaler value        autoscaler address [$DRONE_AUTOSCALER]
   --help, -h                show help
   --version, -v             print the version

Detailed command information: https://docs.drone.io/cli/commands/
Create general secrets

$ drone orgsecret add [organization] [name] [data]
//for example
$ drone orgsecret add octocat docker_password pa55word
$ drone orgsecret ls
    docker_password 
    Organization:       octocat
    Pull Request Read:  false
    Pull Request Write: false

Posted by DfyAnt on Fri, 29 Nov 2019 12:09:49 -0800