-
Notifications
You must be signed in to change notification settings - Fork 70
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
How to use with declarative pipeline? #22
Comments
I have the same question too. I believe you may have to use scripted pipeline instead of declarative.
I wonder if you can wrap |
I'm having trouble with this too, there has to be a way to use it in a declarative pipeline! |
I am facing the exactly the same issue. I am starting a new project, and I would certainly like to use a declarative pipeline, but not having support for AWS credentials is a problem. |
I have done the following and it works: environment {
AWS_BIN = '/home/ec2-user/.local/bin/aws'
}
// ...
stage('deploy') {
steps {
withCredentials([[
$class: 'AmazonWebServicesCredentialsBinding',
credentialsId: 'jenkins',
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
]]) {
sh 'AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} AWS_DEFAULT_REGION=us-east-1 ${AWS_BIN} ecs update-service --cluster default --service test-deploy-svc --task-definition test-deploy:2 --desired-count 0'
sh 'sleep 1m' // SOOOO HACKY!!!
sh 'AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} AWS_DEFAULT_REGION=us-east-1 ${AWS_BIN} ecs update-service --cluster default --service test-deploy-svc --task-definition test-deploy:2 --desired-count 1'
}
}
} |
In addition to @brightgarden's solution I had to use double quotation marks.
Otherwise the command would result in an |
Is there any status on this? I don't want to have to wrap EVERY call to a script that needs aws access with withCredentials. Also, withCredentials doesn't work with my groovy classes I import that use the aws sdk because withCredentials only injects into external shell environments not the main one the pipeline runs in. Im going to have to use two regular secret text credentials as a workaround so I have one cred for the ID and one for the access key and I do this:
This is pretty gnarly, disorganized (because I'll have two creds for each aws user), and I can't use the other aws cred provider features like builtin support for assume role. wahhh |
Here's another solution/workaround that worked for me. Then you can define an
|
Hi, @warhod According to the docs [1] the variable names are a bit different. I'm adding this so we don't spread bad knowledge.
I've tested and they work ok with environment block like this (@zkanda: notice environment is placed bellow pipleine not in stage):
|
Thanks @ieugen I've updated my example |
Is it possible to add multiple images within a pod. ` agent {
` I have tried the above but only the last image defined is loaded. A workaround is to define separate agents for each stage. Cheers |
I solved my issue. This works for multiple containers in a pod. ` options {
` |
Just a heads up for any one having weird issues when using withCredentials, I had move all my other lines this steps block into the withCredentials block.
This fails with
This was a little baffling but maybe I just missed some docs saying that you are supposed to wrap everything in withCredentials instead of just the lines needing creds. Idk ¯_(ツ)_/¯ |
…ugin#22 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1869714 13f79535-47bb-0310-9956-ffa450edef68
…ugin#22 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1869714 13f79535-47bb-0310-9956-ffa450edef68
I tried using it with declarative pipeline and it giving me error.
If it's not yet possible, what's the recommended workaround?
The text was updated successfully, but these errors were encountered: