This code is a Jenkins Shared Library plugin that allows you to run a command with specific gcloud credentials stored in Jenkins by the google-oauth-plugin
Note: You must have the "Google Cloud SDK" plugin installed, and a custom tool called gcloud
setup for the activation to work (though this should work without that if you have another way of getting gcloud onto your slave machine)
Usage:
withGCloudCredentials(<projectName>, <credentialsId>) {
sh "gcloud <command>"
sh "gsutil <command>"
}
credentialsId
is optional, if left out it defaults to the projectName
given as the first arg