Giter Site home page Giter Site logo

jenkinsci / google-source-plugin Goto Github PK

View Code? Open in Web Editor NEW
5.0 7.0 11.0 76 KB

This plugin provides the credential provider to use Google Cloud Platform OAuth Credentials (provided by the Google OAuth Plugin) to access source code from https://source.developer.google.com as well as https://googlesource.com.

Home Page: https://plugins.jenkins.io/google-source-plugin/

License: Apache License 2.0

Java 100.00%

google-source-plugin's Introduction

Jenkins Google Source Plugin

Read more: http://wiki.jenkins-ci.org/display/JENKINS/Google+Source+Plugin

This plugin provides the credential provider to use Google Cloud Platform OAuth Credentials (provided by the Google OAuth Plugin) to access source code from https://source.developer.google.com as well as https://*.googlesource.com. It supports both kinds of credentials provided by Google OAuth Plugin: Google Service Account from metadata as well as Google Service Account from private key.

  1. In order to use a Git repository hosted on https://source.developer.google.com, your credential will need the scope https://www.googleapis.com/auth/source.read_write. Your service account will need to have access to the repository’s Google Cloud Platform project.

  2. In order to use https://*.googlesource.com, your credential will need the scope https://www.googleapis.com/auth/gerritcodereview. Your service account will need to be whitelisted by the maintainers of that repository.

Usage

First, configure your OAuth credentials per instructions from Google OAuth Plugin.

Then, when configuring the Git repository for your Jenkins job, if you enter a https://*.googlesource.com address in the “Repository URL” text area, your Credentials drop box will automatically be populated with credentials having the https://www.googleapis.com/auth/gerritcodereview scope

Similarly, if you enter a https://source.developer.google.com Git repository, your Credentials box will be populated with credentials having the https://www.googleapis.com/auth/source.read_write scope.

Select the required credential, then your job is ready to go!

Development

How to build

mvn clean verify

Creates the plugin HPI package for use with Jenkins.

License

(The Apache v2 License)

Copyright 2013 Google Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

google-source-plugin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-source-plugin's Issues

Plugin crashes on null pointer for builds

Not sure when my predecessor installed this plugin, or why we saw this now, but builds started failing a null check with this stack:

java.io.IOException: Failed to parse changelog
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:628)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:532)
    at hudson.model.Run.execute(Run.java:1741)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:408)
Caused by: java.lang.NullPointerException
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:187)
    at com.google.jenkins.plugins.metadata.scm.SourceMetadata.<init>(SourceMetadata.java:62)
    at com.google.jenkins.plugins.metadata.scm.SourceMetadataExtractor$FromGitBuildActions.getSourceMetadata(SourceMetadataExtractor.java:242)
    at com.google.jenkins.plugins.metadata.scm.SourceMetadataExtractor$FromBuildActions.extract(SourceMetadataExtractor.java:139)
    at com.google.jenkins.plugins.metadata.scm.SourceMetadataExtractor.extract(SourceMetadataExtractor.java:101)
    at com.google.jenkins.plugins.metadata.scm.SourceMetadataBuildListener.onChangeLogParsed(SourceMetadataBuildListener.java:50)
    at hudson.model.listeners.SCMListener.onChangeLogParsed(SCMListener.java:120)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:626)

SourceMetadata.java and others are from this repo, with correct line numbers. Also, uninstalling this plugin fixed that issue.

Checkout is faling on latest Jenkins

Using Jenkins 2.187, this plugin now fails upon attempting and "checkout scm" in the Jenkinsfile:

java.lang.IllegalStateException: Jenkins.instance is missing. Read the documentation of Jenkins.getInstanceOrNull to see what you are doing wrong.
    at jenkins.model.Jenkins.get(Jenkins.java:772)
    at hudson.model.Hudson.getInstance(Hudson.java:77)
    at com.google.jenkins.plugins.source.GoogleRobotUsernamePassword.areOnMaster(GoogleRobotUsernamePassword.java:146)
    at com.google.jenkins.plugins.source.GoogleRobotUsernamePassword.readObject(GoogleRobotUsernamePassword.java:180)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1058)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2136)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2027)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
    at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1933)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1529)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2245)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2169)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2027)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:422)
    at hudson.remoting.UserRequest.deserialize(UserRequest.java:245)
    at hudson.remoting.UserRequest.perform(UserRequest.java:159)

Sometimes crashes on agent (areOnMaster)

Sometimes we receive an error on a Jenkins agent

java.lang.IllegalStateException: Jenkins.instance is missing. Read the documentation of Jenkins.getInstanceOrNull to see what you are doing wrong.
	at jenkins.model.Jenkins.get(Jenkins.java:772)
	at hudson.model.Hudson.getInstance(Hudson.java:77)
	at com.google.jenkins.plugins.source.GoogleRobotUsernamePassword.areOnMaster(GoogleRobotUsernamePassword.java:146)
	at com.google.jenkins.plugins.source.GoogleRobotUsernamePassword.readObject(GoogleRobotUsernamePassword.java:180)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1058)
	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2136)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2027)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
	at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1933)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1529)
	at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2245)
	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2169)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2027)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:422)
	at hudson.remoting.UserRequest.deserialize(UserRequest.java:245)
	at hudson.remoting.UserRequest.perform(UserRequest.java:159)

It looks like we shouldn't be calling Hudson.getInstance to determine whether we're running on a Jenkins agent. There may be other classes that shouldn't be called/remoted from this plugin.

OAuth Scope and Service Account Role

Hello,
we are trying to use that plugin to checkout sources from Google Cloud Repositories with GCE instances. Our instances have a Service Account attached that has the permission to check out repositories.
When to manually configure the according Git credential helper for the Jenkins user, the checkout of our sources works without specifying credentials. Unfortunately this is not following Jenkins best-practices as they recommend to not configure any credential helper and use Jenkins credentials instead.
By working scopes as this plugin suggests, we cannot use a custom service account.
Would it be possible to develop the plugin in a way that takes both cases into account:

  • Default Service Account with attached Scope
  • Custom Service Account with attached Permissions

Thanks
Eric

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.