Support

How to setup Git-backed content deployment from a private repository in RStudio Connect

Follow

Overview

RStudio Connect Publishers can deploy content to RStudio Connect in several ways. One mechanism is to create content directly from a Git repository. 

The User Guide provides instructions for how to perform Git-backed deployment with a Publisher account. The Admin Guide offers information about the components required to support Git-backed content in an RStudio Connect deployment environment. 

This article describes the necessary steps required for enabling deployments from private Git repositories. The configuration also requires assistance from your RStudio Connect systems administrator, as well as a brief period of system downtime.  

Note: The current support for authenticating with private Git repositories is limited to a single set of credentials.

1. Create an access token for your project or organization which will be used for all publishing tasks

Private source repositories can be accessed with authentication based on HTTP basic auth. A common pattern is to set up a personal access token (PAT) for a service account user. Refer to your Git hosting service documentation for guidance on how to create and manage access tokens: 

2. Use the rscadmin utility on the RStudio Connect server to encrypt your access token

Token values cannot be pasted into the RStudio Connect Configuration file as plain-text. To encrypt a token, first stop your RStudio Connect service:

systemctl stop rstudio-connect

Then run the following command:

/opt/rstudio-connect/bin/rscadmin configure --encrypt-config-value

You will be prompted to enter the value you would like to encrypt. Provide the access token by pasting it into your prompt. The entry will be obscured; there is no visual feedback of any text input until you press the enter key.

The encrypted value output will be printed in Base64 format. This value should be used as your ‘Password’ in the configuration file.

3. Create a GitCredential section in the RStudio Connect config file

Open the rstudio-connect.gfcg file located at /etc/rstudio-connect/rstudio-connect.gfcg with an editor and add a new section for your Git Credentials (example):

[GitCredential "Azure DevOps"]
Host = dev.azure.com
Username = example-org
Password = my-encrypted-password
Protocol = https

In this example, we have an Azure DevOps Organization called "example-org". This organization contains one or more Projects for tracking content code (applications, documents, APIs, etc.) that we want to publish to RStudio Connect using git-backed deployment.

The repository URL for each project should look something like this:

https://dev.azure.com/example-org/_git/Shiny-Project

Use the repository URL as a guide for filling out your GitCredential values:

  • The Host is dev.azure.com 
  • The Username, in this case, is the Organization name: example-org
  • The Password is the encrypted value string created from the Azure DevOps access token
  • The Protocol is https

4. Save changes to the RStudio Connect config file and restart the rstudio-connect service

 systemctl start rstudio-connect

5. Have an RStudio Connect Publisher verify functionality

At this stage, git-backed deployment should be working. Have a Publisher test the functionality by executing the steps outlined in the User Guide.

Comments