travis_get_vars: Travis CI variables

View source: R/travis-vars.R

travis_get_varsR Documentation

Travis CI variables

Description

Functions around public and private variables available in Travis CI builds.

travis_get_vars() calls the "/settings/env_vars" API.

travis_get_var_id() retrieves the ID for a variable name, or NULL. If multiple variables exist by that name, it returns the ID of the last (with a warning), because this is what seems to be used in Travis CI builds in such a case.

travis_set_var() creates or updates a variable. If multiple variables exist by that name, it updates the last (with a warning), because this is what seems to be used in Travis CI builds in such a case.

travis_delete_var() deletes a variable.

Usage

travis_get_vars(repo = github_repo(), endpoint = get_endpoint(), quiet = FALSE)

travis_get_var_id(
  name,
  repo = github_repo(),
  endpoint = get_endpoint(),
  quiet = FALSE
)

travis_set_var(
  name,
  value,
  public = FALSE,
  repo = github_repo(),
  endpoint = get_endpoint(),
  quiet = FALSE
)

travis_delete_var(
  id,
  repo = github_repo(),
  endpoint = get_endpoint(),
  quiet = FALSE
)

Arguments

repo

[string]
The repository slug to use. Must follow the "user/repo" structure.

endpoint

[string]
Which Travis endpoint to use. Defaults to ".org". Accepted values are ".com" and ".org". Can be set globally via env var R_TRAVIS.

quiet

If TRUE, console output is suppressed.

name

[string]
The name of the variable.

value

[string]
The value for the new or updated variable.

public

[flag]
Should the variable be public or private?

id

[string]
The ID of the variable, by default obtained from travis_get_var_id().

Details

Avoid using travis_set_var() with literal values, because they will be recorded in the .Rhistory file.

Examples

## Not run: 
# List all variables:
travis_get_vars()

## End(Not run)
## Not run: 
# Get the ID of a variable.
travis_get_var_id("secret_var")

## End(Not run)
## Not run: 
# Avoid calling with literal values:
travis_set_var("secret_var", "oh no - this will be recorded in .Rhistory!")

# Set a Travis environment variable without recording it in history
# by reading the value from the console:
travis_set_var("secret_var", readLines(n = 1))

## End(Not run)
## Not run: 
# Delete a variable:
travis_delete_var("secret_var")

## End(Not run)

ropenscilabs/travis documentation built on May 18, 2022, 8:33 p.m.