Gist for https://www.youtube.com/watch?v=Zy_FQEYkaRw
pipeline {
agent any
stages {
stage('test') {
steps {
sh '''
gcloud version
'''
}
}
}
}
pipeline {
agent any
stages {
stage('test') {
steps {
sh '''
gcloud version
gcloud compute zones list
'''
}
}
}
}
pipeline {
agent any
stages {
stage('test') {
steps {
withCredentials([file(credentialsId: 'gcloud-creds', variable: 'GCLOUD_CREDS')]) {
sh '''
gcloud version
gcloud auth activate-service-account --key-file="$GCLOUD_CREDS"
gcloud compute zones list
'''
}
}
}
}
}
pipeline {
agent any
environment {
CLOUDSDK_CORE_PROJECT='x:y'
}
stages {
stage('test') {
steps {
withCredentials([file(credentialsId: 'gcloud-creds', variable: 'GCLOUD_CREDS')]) {
sh '''
gcloud version
gcloud auth activate-service-account --key-file="$GCLOUD_CREDS"
gcloud compute zones list
'''
}
}
}
}
}
pipeline {
agent any
environment {
CLOUDSDK_CORE_PROJECT='x:y'
CLIENT_EMAIL='a@a.com'
}
stages {
stage('test') {
steps {
withCredentials([file(credentialsId: 'gcloud-creds', variable: 'GCLOUD_CREDS')]) {
sh '''
gcloud version
gcloud auth activate-service-account --key-file="$GCLOUD_CREDS"
gcloud compute zones list
'''
}
}
}
}
post {
always {
sh 'gcloud auth revoke $CLIENT_EMAIL'
}
}
}
pipeline {
agent any
environment {
CLOUDSDK_CORE_PROJECT='x:y'
CLIENT_EMAIL='a@a.com'
GCLOUD_CREDS=credentials('gcloud-creds')
}
stages {
stage('test') {
steps {
sh '''
gcloud version
gcloud auth activate-service-account --key-file="$GCLOUD_CREDS"
gcloud compute zones list
'''
}
}
}
post {
always {
sh 'gcloud auth revoke $CLIENT_EMAIL'
}
}
}