Skip to content
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

ACRFD-53: Update/unify jenkinsfiles. #364

Merged
merged 1 commit into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
def sonarqubePodLabel = "prc-admin-${UUID.randomUUID().toString()}"
podTemplate(label: sonarqubePodLabel, name: sonarqubePodLabel, serviceAccount: 'jenkins', cloud: 'openshift', containers: [
containerTemplate(
name: 'jnlp',
image: '172.50.0.2:5000/openshift/jenkins-slave-python3nodejs',
resourceRequestCpu: '500m',
resourceLimitCpu: '1000m',
resourceRequestMemory: '1Gi',
resourceLimitMemory: '4Gi',
workingDir: '/tmp',
command: '',
args: '${computer.jnlpmac} ${computer.name}',
envVars: [
envVar(key: 'SONARQUBE_URL', value: 'https://sonarqube-prc-tools.pathfinder.gov.bc.ca')
]
)
]) {
node(sonarqubePodLabel) {
stage('checkout code') {
checkout scm
}
stage('exeucte sonar') {
dir('sonar-runner') {
try {
sh 'npm install typescript && ./gradlew sonarqube -Dsonar.host.url=https://sonarqube-prc-tools.pathfinder.gov.bc.ca -Dsonar.verbose=true --stacktrace --info'
} finally {

}
}
}
}
}

pipeline {
agent any
options {
skipDefaultCheckout()
}
stages {
stage('Building: admin (master branch)') {
steps {
Expand Down
100 changes: 35 additions & 65 deletions Jenkinsfile - develop
Original file line number Diff line number Diff line change
@@ -1,79 +1,49 @@
pipeline {
agent any
stages {
stage('build chained angular app build'){
steps {
notifyBuild('STARTED')
openshiftBuild(bldCfg: 'admin-angular-on-nginx-build-angular-app-build', showBuildLogs: 'true')
}
}
stage('build and package admin-angular-on-nginx'){
steps {
openshiftBuild(bldCfg: 'admin-angular-on-nginx-build', showBuildLogs: 'true')
}
}
stage('tag and deploy to dev') {
steps {
openshiftTag(srcStream: 'admin-angular-on-nginx', srcTag: 'latest', destStream: 'admin-angular-on-nginx', destTag: 'dev')
notifyBuild('DEPLOYED:DEV')
}
}
stage('tag and deploy to test') {
steps {
script {
try {
timeout(time: 2, unit: 'MINUTES') {
input "Deploy to TEST?"
openshiftTag(srcStream: 'admin-angular-on-nginx', srcTag: 'dev', destStream: 'admin-angular-on-nginx', destTag: 'test')
notifyBuild('DEPLOYED:TEST')
}
} catch (err) {
notifyBuild('DEPLOYMENT:TEST ABORTED')
}
}
}
agent any
options {
skipDefaultCheckout()
}
stages {
stage('Building: admin (develop branch)') {
steps {
script {
try {
echo "Building: ${env.JOB_NAME} #${env.BUILD_ID}"
notifyBuild("Building: ${env.JOB_NAME} #${env.BUILD_ID}", "YELLOW")
openshiftBuild bldCfg: 'admin-angular-on-nginx-build-angular-app-build', showBuildLogs: 'true'
} catch (e) {
notifyBuild("BUILD ${env.JOB_NAME} #${env.BUILD_ID} ABORTED", "RED")
error('Stopping early…')
}
}
stage('tag and deploy to prod') {
steps {
script {
try {
timeout(time: 2, unit: 'MINUTES') {
input "Deploy to PROD?"
openshiftTag(srcStream: 'admin-angular-on-nginx', srcTag: 'test', destStream: 'admin-angular-on-nginx', destTag: 'prod')
notifyBuild('DEPLOYED:PROD')
}
} catch (err) {
notifyBuild('DEPLOYMENT:PROD ABORTED')
}
}
}
}
}
stage('Deploying: admin (develop branch)') {
steps {
script {
try {
notifyBuild("Deploying: ${env.JOB_NAME} #${env.BUILD_ID}", "YELLOW")
openshiftBuild bldCfg: 'admin-angular-on-nginx-build', showBuildLogs: 'true'
} catch (e) {
notifyBuild("BUILD ${env.JOB_NAME} #${env.BUILD_ID} ABORTED", "RED")
error('Stopping early…')
}
notifyBuild("Deployed ${env.JOB_NAME} #${env.BUILD_ID}", "GREEN")
}
}
}
}
}
def notifyBuild(String buildStatus = 'STARTED') {
// build status of null means successful
buildStatus = buildStatus ?: 'SUCCESSFUL'

// Default values
def colorName = 'RED'
def colorCode = '#FF0000'
def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'"
def summary = "${subject} (${env.BUILD_URL})"
def details = """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at "<a href="${env.BUILD_URL}">${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>"""

// Override default values based on build status
if (buildStatus == 'STARTED' || buildStatus.startsWith("DEPLOYMENT")) {
color = 'YELLOW'
def notifyBuild(String msg = '', String colour = 'GREEN') {
if (colour == 'YELLOW') {
colorCode = '#FFFF00'
} else if (buildStatus == 'SUCCESSFUL' || buildStatus.startsWith("DEPLOYED")) {
color = 'GREEN'
} else if (colour == 'GREEN') {
colorCode = '#00FF00'
} else {
color = 'RED'
colorCode = '#FF0000'
}

// Send notifications
//slackSend (color: colorCode, message: summary)
slackSend (color: colorCode, message: msg)
}
49 changes: 0 additions & 49 deletions Jenkinsfile - master

This file was deleted.