RStudio Connect Deployments with GitHub Webhooks and Jenkins
This video complements the article at https://medium.com/@kelly.obriant/rstudio-connect-deployments-with-github-webhooks-and-jenkins-c0dd8a82b986 TL;DR: New content management Connect server APIs are easy to integrate with programmatic deployment workflows. ---- Content Management API Resources: - API Reference: https://docs.rstudio.com/connect/api/ - User Guide: https://docs.rstudio.com/connect/user/cookbook.html#recipes (Deploying Content) - Example deployment scripts: https://github.com/rstudio/connect-api-deploy-shiny
image: thumbnail.jpg
Transcript#
This transcript was generated automatically and may contain errors.
Hi, I'm Kelly from RStudio, and this video is a demo of programmatic deployment of a Shiny application to RStudio Connect using Jenkins and GitHub Webhooks.
This deployment pipeline leverages new RStudio Connect server APIs for content management that have just become available in RStudio Connect 1.7.0.
This is the deployment pipeline that I've built using GitHub and Jenkins to move from the RStudio IDE all the way to RStudio Connect.
The application in the IDE and on Connect
So here's the application that I'm interested in programmatically deploying to Connect. I'll show it to you here in the RStudio IDE. You can interact with it here locally, and I'll also show it to you as already deployed to my Connect server. So here it is on the Connect server. You can see here that it's just a basic histogram Shiny application, and I've changed the color of the histogram to red.
Making a code change with a git branching strategy
Now I'll pull up my IDE again and say I'm interested in changing the color from red back to something more subtle like blue. So in order to do that, I'm going to use a git branching strategy. I'm checking out a new branch, which I'm calling new branch, and now I'll be able to commit all of my code changes to this branch before pushing up to GitHub.
So here I'm just changing the color from red to dark blue, and then I'm going to save that and test the app locally. Here it is locally. I like the color.
Pushing to GitHub and opening a pull request
So now I'll push that change up to my GitHub. So to do that, I will add this change and then write a little commit message here about what happened to the code, say I changed the color, and then I'll push my branch up to GitHub.
So now if I go over to my GitHub, my repository here, you'll see I have a new branch that I can then open a pull request on. So here I'm just opening a pull request for this change so that I can merge the branch into master and push that change information over to Jenkins.
I have a pull request ready to go, and at this point, I could request a review from somebody else on my team, but while I'm here, I'll show you in the settings that I have a webhook already pre-set up to talk to Jenkins from my GitHub repo. If you want to see more information about how to set that up, check out the blog in the description below.
But now I'm going to go ahead and merge my PR into master, and that will kick off my Jenkins job.
Jenkins build and deployment to Connect
This is my Jenkins server. I'm going to sign in again real quick here. You can see that I have this Freestyle Jenkins project that's deploying my code changes over to RStudio Connect. Again, for more information on how to set up this Freestyle project, check out the blog in the description below.
I go over to Connect, refresh, and I can see I have a blue histogram instead of a red one. Go back and show you real quick some of the things that you can explore in Jenkins based on each build. If you're interested in looking at what happened, you can always go into your console output in Jenkins and investigate each job. You'll see here that we had a success.