-
-
Save wololock/990c27d08241a863886ef80b68e6ac0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!groovy | |
pipeline { | |
agent { | |
label "docker" | |
} | |
stages { | |
stage("Build") { | |
steps { | |
script { | |
def params = [ | |
'-v $HOME/.m2/settings.xml:/var/maven/.m2/settings.xml:ro', | |
'-v $HOME/.m2/repository/:/var/maven/.m2/repository/:rw,z', | |
"-e MAVEN_CONFIG=/var/maven/.m2" | |
] | |
docker.image("maven:3.6.3-jdk-11-slim").inside(params.join(" ")) { | |
// HERE GOES OUR DEFAULT MVN BUILD COMMAND. THE ONE BELOW IS JUST A DUMMY PLACEHOLDER. | |
sh "mvn -version" | |
} | |
} | |
} | |
} | |
// SOME OTHER STAGES HERE. | |
stage("Deploy") { | |
when { | |
expression { | |
env.BRANCH_NAME in ["master", "develop"] | |
} | |
} | |
environment { | |
CREDENTIALS_ID = "89251094-612c-4546-aec3-0644c217f47d" | |
SERVICE_ACCOUNT = "jenkins@micronaut-demo-app.iam.gserviceaccount.com" | |
} | |
steps { | |
script { | |
ws { | |
withCredentials([file(credentialsId: env.CREDENTIALS_ID, variable: "FILE")]) { | |
docker.image("google/cloud-sdk:277.0.0-slim").inside("--entrypoint='' -v $FILE:/credentials.json:ro -u root") { | |
sh "gcloud auth activate-service-account ${env.SERVICE_ACCOUNT} --key-file=/credentials.json" | |
// HERE GOES OUR DEFAULT GCLOUD DEPLOY COMMAND. THE ONE BELOW IS JUST A DUMMY PLACEHOLDER. | |
sh "gcloud projects list" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment