grafana/integration-grafana-publisher

Verified Publisher

By Grafana Labs

Updated 9 months ago

Used during publishing plugins to grafana.com

Image
Integration & delivery
API management
Monitoring & observability
1

10K+

grafana/integration-grafana-publisher repository overview

Grafana Publisher

This utility can be used to publish a plugin to grafana.com either from the commandline or by running inside CircleCI.

Usage

Running the application with no arguments will provide help/usage output, which looks like this:

Usage: grafana-publisher [options] [command]

Grafana Plugin Publisher

Options:
  -V, --version                                              output the version number
  -a, --auto                                                 Run without prompts
  -l, --log [logfile]                                        log to file
  --loglevel [info|debug]                                    log level
  -d, --dryrun                                               Run but do not apply actions
  -h, --help                                                 display help for command

Commands:
  validate                                                   Detect environment settings required to run this
                                                             application
  info <pluginid> [pluginPath] [pluginVersion]               Gathers and displays known information about specified
                                                             plugin
  inforemote <pluginid> [pluginVersion]                      Gathers and displays known information about specified
                                                             plugin
  stage <pluginid> [pluginVersion]                           Performs publish to staging environment
  stageremote <pluginRepo> [pluginVersion]                   Performs remote publish to staging
  publish <pluginid> [pluginVersion] [pluginPath]            Performs local publish to production
  publishremote <pluginRepo> [pluginVersion]                 Performs remote publish to production
  setdependency <pluginid> <pluginVersion> <grafanaVersion>  Sets grafanaDependency attribute (>=7.0.0)
  help [command]                                             display help for command

Flags

The following flags can assist with debugging/troubleshooting the publish process. --auto intended for use inside CircleCI, it will "answer" yes to any prompts. --dryrun this is a good commandline test to see what will happen if you attempt to publish. No action will be taken by the script, but it should let you know if the publish will succeed. --loglevel set this to debug for more output

Command Overview

The application provides mutiple commands to help all aspects of the publishing process.

Environment Variables
ENVIRONMENT VARPurpose
GCOM_PUBLISH_TOKENAPI Key with rights to publish to grafana.com
GCOM_ADMIN_TOKENAPI Key with admin rights to grafana.com (only for setdependency, not required for normal usage)
GITHUB_TOKENAPI Token with release/write privileges to github repo
GCLOUD_SERVICE_KEYA JSON file with permission to write to integration-artifacts bucket in GCS

These variable values can be found in 1Password, and are preset inside each CircleCI project.

validate

This command will verify if your environment variables are present and work with the APIs. This is automatically run during a dryrun and with a publish.

grafana-publisher.js validate

Output:

OK: Publish to GCOM Key found in environment setting
OK: GCS Authentication found in environment setting
OK: GIT Key found in environment setting
[2020-07-25T05:51:54.047] [DEBUG] publisher - GCOM testing GET to https://grafana.com/api/plugins/table
OK: GCOM is working
Validation Successful
info

This will give you a summary of a released plugin based on a local repo. Only a "plugin.json" needs to be local and must match the plugin-id.

grafana-publisher info grafana-newrelic-datasource dist/plugin.json 2.0.5
[2020-07-21T14:23:01.860] [INFO] publisher - Gathering data for grafana-newrelic-datasource
[2020-07-21T14:23:01.863] [DEBUG] publisher - Checking testdata/newrelic/plugin.json
[2020-07-21T14:23:01.863] [DEBUG] publisher - Found file, reading...
[2020-07-21T14:23:01.863] [DEBUG] publisher - Read file, found id grafana-newrelic-datasource
[2020-07-21T14:23:01.863] [DEBUG] publisher - PluginID: grafana-newrelic-datasource
[2020-07-21T14:23:01.863] [DEBUG] publisher - Checking for grafana-newrelic-datasource for ./git/config
[2020-07-21T14:23:01.863] [DEBUG] publisher - Git Repo from predefined list:
[2020-07-21T14:23:01.863] [DEBUG] publisher - Git Repo: newrelic-datasource
[2020-07-21T14:23:01.864] [DEBUG] publisher - Repo: newrelic-datasource
[2020-07-21T14:23:01.864] [DEBUG] publisher - No dependency specified
[2020-07-21T14:23:01.864] [WARN] publisher - Dependency: Not Found!
[2020-07-21T14:23:01.864] [DEBUG] publisher - Fetching info for newrelic-datasource from https://api.github.com/repos/grafana/newrelic-datasource/releases/latest
[2020-07-21T14:23:02.158] [DEBUG] publisher - Release Tag URL: https://github.com/grafana/newrelic-datasource/releases/tag/v2.0.5
[2020-07-21T14:23:02.158] [INFO] publisher - RepoURL: https://github.com/grafana/newrelic-datasource/
[2020-07-21T14:23:02.158] [INFO] publisher - Version Detected: 2.0.5
[2020-07-21T14:23:02.158] [DEBUG] publisher - GetReleaseCommitSHA: Fetching info for newrelic-datasource version 2.0.5
[2020-07-21T14:23:02.599] [INFO] publisher - Commit Hash: 95d9fed4226f14d0f5c612b64c872470104a2870
inforemote

This will give you a summary of a published plugin identified by plugin id. A specific version can also be requested, default is latest.

stage

Currently not implemented

stageremote

Currently not implemented

publish

This is the main function of the application. It will perform all steps needed to publish a plugin and will only error when there is a problem.

grafana-publisher publish

Output:

grafana-publisher publish grafana-newrelic-datasource 2.0.5 dist/plugin.json

Output:

This can also be used in docker/circleci:

docker run \
  -e GCOM_PUBLISH_TOKEN=$GCOM_PUBLISH_TOKEN \
  -e GITHUB_TOKEN=$GITHUB_TOKEN \
  -e GCLOUD_SERVICE_KEY=$GCLOUD_SERVICE_KEY \
  grafana/integration-plugin-publisher:latest grafana-publisher.js validate

Output:

publishremote
setdependency

This is a single-purpose command to set the grafanaDependency value for a plugin. Value should in the form >=7.0.0

grafana-publisher setdependency grafana-newrelic-datasource 2.0.5 '>=7.0.0'

Output:

Publishing from commandline

Locally checked out release branch

Here's an example of publishing the New Relic plugin. This would be run inside the checked-out release branch, where dist is available.

grafana-publisher grafana-newrelic-datasource '>=7.0.0'
Publishing with all remote resources

By specifying a repo url and a version number, the script publish to gcom without needing to have the repo checked out.

grafana-publisher https://github.com/grafana/grafana-polystat-panel 1.0.0

Publishing within CircleCI

Docker image

The docker image is grafana/integration-plugin-publisher:latest

docker run \
  -e GCOM_PUBLISH_TOKEN=$GCOM_PUBLISH_TOKEN \
  -e GITHUB_TOKEN=$GITHUB_TOKEN \
  -e GCLOUD_SERVICE_KEY=$GCLOUD_SERVICE_KEY \
  grafana/integration-plugin-publisher:latest grafana-publisher.js validate

Output:

OK: Publish to GCOM Key found in environment setting
OK: GCS Authentication found in environment setting
OK: GIT Key found in environment setting
[2020-07-25T05:51:54.047] [DEBUG] publisher - GCOM testing GET to https://grafana.com/api/plugins/table
OK: GCOM is working
Validation Successful

Tag summary

Content type

Image

Digest

sha256:f7f04ef12

Size

319.9 MB

Last updated

9 months ago

docker pull grafana/integration-grafana-publisher

This week's pulls

Pulls:

213

Last week