Skip to content

jenkinsci/pipeline-gcp-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pipeline: GCP Steps

Build Status

Introduction

This plugin adds Jenkins pipeline steps to interact with the GCP API.

Getting started

The plugin assumes that you have a GCP account and a project. You will need to create a service account, download the JSON key file locally and upload it to your Jenkins as Secret file. The service account will need to have the necessary permissions to interact with the GCP services you want to use.

Features

withGCP

This step will load the credentials file by the id and set the environment variables for the gcloud command to use. In particular, it will set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of the credentials file. And will also attempt to extract the project_id from the file and set it as CLOUDSDK_CORE_PROJECT environment variable.

withGCP(credentialsId: "credentials-id") {
    // run gcloud commands here
}

createFirewallRule

This step will create a firewall rule with the given configuration. Please refer to the CLI command documentation for more information on the parameters.

Either allow or action must be provided:

createFirewallRule(name: "firewallRuleName", allow: "tcp:22")

or

createFirewallRule(name: "firewallRuleName", action: "DENY", rules: "tcp:22")

Contributing

Refer to our contribution guidelines

LICENSE

Licensed under MIT, see LICENSE