Skip to content

Commit

Permalink
Jenkinsfile formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Brad Geesaman committed Aug 7, 2019
1 parent 7a3e1b3 commit 988ecc9
Showing 1 changed file with 60 additions and 64 deletions.
124 changes: 60 additions & 64 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,77 +24,73 @@ limitations under the License.
// set up pod label and GOOGLE_APPLICATION_CREDENTIALS (for Terraform)
def label = "k8s-infra"
def containerName = "k8s-node"
def GOOGLE_APPLICATION_CREDENTIALS = '/home/jenkins/dev/jenkins-deploy-dev-infra.json'
def GOOGLE_APPLICATION_CREDENTIALS = '/home/jenkins/dev/jenkins-deploy-dev-infra.json'
def jenkins_container_version = env.JENKINS_CONTAINER_VERSION

podTemplate(label: label,
containers: [
containerTemplate(name: "${containerName}",
image: "gcr.io/pso-helmsman-cicd/jenkins-k8s-node:${jenkins_container_version}",
command: 'tail -f /dev/null',
resourceRequestCpu: '1000m',
resourceLimitCpu: '2000m',
resourceRequestMemory: '1Gi',
resourceLimitMemory: '2Gi'
)
],
volumes: [secretVolume(mountPath: '/home/jenkins/dev',
secretName: 'jenkins-deploy-dev-infra'
)
]
) {
node(label) {
try {
// Options covers all other job properties or wrapper functions that apply to entire Pipeline.
properties([disableConcurrentBuilds()])
// set env variable GOOGLE_APPLICATION_CREDENTIALS for Terraform
env.GOOGLE_APPLICATION_CREDENTIALS=GOOGLE_APPLICATION_CREDENTIALS
containers: [
containerTemplate(name: "${containerName}",
image: "gcr.io/pso-helmsman-cicd/jenkins-k8s-node:${jenkins_container_version}",
command: 'tail -f /dev/null',
resourceRequestCpu: '1000m',
resourceLimitCpu: '2000m',
resourceRequestMemory: '1Gi',
resourceLimitMemory: '2Gi'
)
],
volumes: [secretVolume(mountPath: '/home/jenkins/dev',
secretName: 'jenkins-deploy-dev-infra'
)]
) {
node(label) {
try {
// Options covers all other job properties or wrapper functions that apply to entire Pipeline.
properties([disableConcurrentBuilds()])
// set env variable GOOGLE_APPLICATION_CREDENTIALS for Terraform
env.GOOGLE_APPLICATION_CREDENTIALS = GOOGLE_APPLICATION_CREDENTIALS

stage('Setup') {
container(containerName) {
// checkout code from scm i.e. commits related to the PR
checkout scm
stage('Setup') {
container(containerName) {
// checkout code from scm i.e. commits related to the PR
checkout scm

// Setup gcloud service account access
sh "gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS}"
sh "gcloud config set compute/zone ${env.ZONE}"
sh "gcloud config set core/project ${env.PROJECT_ID}"
sh "gcloud config set compute/region ${env.REGION}"
}
}
stage('Lint') {
container(containerName) {
sh "make lint"
}
}
// Setup gcloud service account access
sh "gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS}"
sh "gcloud config set compute/zone ${env.ZONE}"
sh "gcloud config set core/project ${env.PROJECT_ID}"
sh "gcloud config set compute/region ${env.REGION}"
}
}
stage('Lint') {
container(containerName) {
sh "make lint"
}
}

stage('Create') {
container(containerName) {
sh "make create"
}
}
stage('Create') {
container(containerName) {
sh "make create"
}
}

stage('Validate') {
container(containerName) {
sh "make validate"
}
}

stage('Validate') {
container(containerName) {
sh "make validate"
} catch (err) {
// if any exception occurs, mark the build as failed
// and display a detailed message on the Jenkins console output
currentBuild.result = 'FAILURE'
echo "FAILURE caught echo ${err}"
throw err
} finally {
stage('Teardown') {
container(containerName) {
sh "make teardown"
}
}
}
}

}
catch (err) {
// if any exception occurs, mark the build as failed
// and display a detailed message on the Jenkins console output
currentBuild.result = 'FAILURE'
echo "FAILURE caught echo ${err}"
throw err
}
finally {
stage('Teardown') {
container(containerName) {
sh "make teardown"
sh "gcloud auth revoke"
}
}
}
}
}

0 comments on commit 988ecc9

Please sign in to comment.