-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usage in pipeline #6
Comments
I too am wondering this. The documentation explains how to setup the credential but not how to use it. |
I think it's not usable as is, google-oauth-plugin doesn't expose anything to pipeline (AFAIK). |
In my despair, I looked at the source code of Google OAuth Credentials Plugin and compared it with others credentials plugins. I found out that other plugins extend |
I've used pretty much the same workaround as @smaftoul. I stopped looking into better solutions as we are considering moving away from Jenkins right now. |
I tried this workaround and got an exception because a secret file couldn't be bound with 'StringBinding'. I used 'FileBinding' instead and it writes the file to a temporary workspace then points the environment variable at it. If you set the variable name to GOOGLE_APPLICATION_CREDENTIALS then the Google client libraries should just work without having to write out the file manually. |
The workaround is to not use the google oath plugin. Just add the
credentials as a standard "secret file", and use them like this:
withCredentials([[$class: 'FileBinding', credentialsId:
"the-id-you-give-it", variable: 'GOOGLE_APPLICATION_CREDENTIALS']])
…On 25 April 2018 at 16:56, barrymac ***@***.***> wrote:
@smaftoul <https://github.com/smaftoul> would like to see your
workaround, struggling to get past this issue even with manually installed
0.6-SNAPSHOT
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#6 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Ageu1YnTdmAbZwG0c_rAYzLn-qaHhMv5ks5tsJyrgaJpZM4MAnk4>
.
|
@Unit2MBailey This does not seem to be working for me. I'm running Jenkins in GKE..is there something different there? Jenkinsfile Stage:
Does anyone know why this won't work? |
@ericuldall Sorry I couldn't say if GKE is different; our Jenkins is hosted internally. We simply wrap our steps in this if we want the python scripts within to be able to use the gcloud API:
|
So I had issues with our GCP Compute VM - I had to create a new service account in Google Clouds' IAM because the key on the compute instance doesn't play nice. In testing I've given the service account the role of editor and Jenkins seems to be building now... I am going to work on cleaning this up, but here's my starter for 10:
|
So I've managed to write a shared library plugin that gives my apps GCloud auth from my Jenkinsfiles. You use it like so:
It's reasonably complicated but we've been using it on v0.7 of google-oauth-plugin for a while now and it mostly works (there are occasional race-conditiony issues when multiple builds run at a time, so it's now flawless). Since 0.8 was released the technique had to change a bit, but I've given examples of both approaches on the gist, which is here: https://gist.github.com/spmason/a53b646ab6219c788b8d04ad959ca940 |
Thanks @spmason for sharing the workaround. Ideally it shouldn't be needed. We have pipeline support scheduled on the roadmap for this quarter. Will send updates as soon as progress is made. |
I ended up opting for a less Jenkins specific solution. I'm just mounting my keys from secrets in my GKE cluster and I can reference them with normal access patterns based on the project name I'm deploying to:
This works well and I don't need to worry about any Jenkins plugins that may or may not work as expected. |
Usage in pipeline should be resolved by #48. Still, I recommend checking out our Jenkins Integration Samples for best practices on using these credentials with our plugins. |
Is it possible to use this plugin in a Jenkinsfile ?
If so, how ? can it work with
withCredentials
?My goal is to execute gsutil commands (in docker containers).
I found a workaround but took quite some time to found it, I'm doing this in my pipeline:
The google-cloud credential is of type
secret file
and it's a base64 encoded json file.The text was updated successfully, but these errors were encountered: