GDrive - BredaUniversityGames/JenkinsLib GitHub Wiki

gdrive.deploy()

Uploads your build as a zip archive to Google Drive using a service account.

Usage

stages {
    perforce.sync()
    ue5.build()
    gdrive.deploy()
    discord.alert()
}

Prerequisites

  • A Google Cloud service account with Drive API access
  • Service account JSON key file stored as a Jenkins credential
  • A Shared Drive (not a regular folder) with the service account added as a member

Parameters

Parameter Default Description
GDRIVE_CREDENTIALS_ID (empty) GDrive service account file (dropdown — Secret file credentials)
GDRIVE_FOLDER_ID (empty) Google Drive parent folder ID

Credential Setup

Creating a Google Cloud Project

  1. Go to Google Cloud Console and sign in with your BUas Google Workspace account (Shared Drives require a Workspace account — personal Gmail accounts will not work)
  2. Click the project dropdown at the top of the page (next to "Google Cloud") and click New Project
  3. Enter a project name (e.g., MyGame-Jenkins), leave Organization and Location as "No organization", and click Create (no billing account is required)
  4. Make sure your new project is selected in the project dropdown

Enabling the Google Drive API

  1. Go to APIs & Services > Library (or search "Drive API" in the top search bar)
  2. Find Google Drive API and click Enable

Creating a Service Account

  1. Go to IAM & Admin > Service Accounts
  2. Click Create Service Account
  3. Enter a name (e.g., jenkins-uploader) — the email will be generated automatically
  4. Click Done (no roles or permissions needed)
  5. Click on the newly created service account to open it
  6. Go to the Keys tab, click Add Key > Create new key
  7. Select JSON and click Create — the key file will download automatically

Setting Up a Shared Drive

Service accounts do not have personal storage quota, so uploads must go to a Shared Drive (not a regular "My Drive" folder).

  1. In Google Drive, click Shared drives in the left sidebar
  2. Click New shared drive and give it a name (e.g., Jenkins Builds)
  3. Click Manage members, add the service account email (e.g., [email protected]) with Contributor access
  4. Create a folder inside the Shared Drive for your builds — use this folder's ID as GDRIVE_FOLDER_ID

Adding to Jenkins

  1. Navigate to your team's folder in Jenkins
  2. Credentials > Add Credentials
  3. Kind: Secret file
  4. File: upload the service account JSON key
  5. ID: e.g., gdrive-myproject

Finding the Folder ID

The folder ID is the last part of the Google Drive folder URL:

https://drive.google.com/drive/folders/1AbCdEfGhIjKlMnOpQrStUvWxYz
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                          This is the folder ID

How It Works

  1. Zips the platform-specific build output
  2. Authenticates with Google using the service account credentials (JWT + OAuth2)
  3. Uploads the zip to Google Drive using the resumable upload API (4 MB chunks)
⚠️ **GitHub.com Fallback** ⚠️