added jenkinsfile
This commit is contained in:
Vendored
+142
@@ -0,0 +1,142 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
environment {
|
||||
WORKSPACE_DIR = '/home/jenkins/prod/authn'
|
||||
WORKSPACE_DEV_DIR = '/home/jenkins/dev/authn'
|
||||
WORKSPACE_UAT_DIR = '/home/jenkins/uat/authn'
|
||||
WORKSPACE_SQA_DIR = '/home/jenkins/sqa/authn'
|
||||
WORKSPACE_VAPT_DIR = '/home/jenkins/vapt/authn'
|
||||
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Build') {
|
||||
steps {
|
||||
script {
|
||||
def SCANNER_HOME = tool 'SonarScanner'
|
||||
|
||||
stage('SonarQube Analysis') {
|
||||
|
||||
withSonarQubeEnv('SonarQube') {
|
||||
sh "${SCANNER_HOME}/bin/sonar-scanner"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
stage('Quality Gate') {
|
||||
|
||||
script {
|
||||
timeout(time: 5, unit: 'MINUTES') {
|
||||
def qualityGate = waitForQualityGate abortPipeline: true
|
||||
if (qualityGate.status != 'OK') {
|
||||
error "Quality Gate failed: ${qualityGate.status}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
stage('Clean Workspace') {
|
||||
cleanWs()
|
||||
}
|
||||
|
||||
|
||||
switch(env.BRANCH_NAME) {
|
||||
case 'main':
|
||||
node('uess-prod-agent') {
|
||||
echo "Building on branch ${env.BRANCH_NAME}"
|
||||
|
||||
stage('Git Pull') {
|
||||
dir(WORKSPACE_DIR) {
|
||||
withCredentials([gitUsernamePassword(credentialsId: 'gitlab')]) {
|
||||
sh 'git stash push main.go && git status && git fetch && git pull && git stash pop'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Docker') {
|
||||
sh 'go run main.go'
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'develop':
|
||||
node('uess-dev-agent') {
|
||||
echo "Building on branch ${env.BRANCH_NAME}"
|
||||
|
||||
stage('Git Pull') {
|
||||
dir(WORKSPACE_DEV_DIR) {
|
||||
withCredentials([gitUsernamePassword(credentialsId: 'gitlab')]) {
|
||||
sh 'git stash push main.go && git status && git fetch && git pull && git stash pop'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Docker') {
|
||||
sh 'go run main.go'
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'uat':
|
||||
node('uess-uat-agent') {
|
||||
echo "Building on branch ${env.BRANCH_NAME}"
|
||||
|
||||
stage('Git Pull') {
|
||||
dir(WORKSPACE_UAT_DIR) {
|
||||
withCredentials([gitUsernamePassword(credentialsId: 'gitlab')]) {
|
||||
sh 'git stash push main.go && git status && git fetch && git pull && git stash pop'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Docker') {
|
||||
sh 'go run main.go'
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'sqa':
|
||||
node('uess-sqa-agent') {
|
||||
echo "Building on branch ${env.BRANCH_NAME}"
|
||||
|
||||
stage('Git Pull') {
|
||||
dir(WORKSPACE_SQA_DIR) {
|
||||
withCredentials([gitUsernamePassword(credentialsId: 'gitlab')]) {
|
||||
sh 'git stash push main.go && git status && git fetch && git pull && git stash pop'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Docker') {
|
||||
sh 'go run main.go'
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'vapt':
|
||||
node('uess-vapt-agent') {
|
||||
echo "Building on branch ${env.BRANCH_NAME}"
|
||||
|
||||
stage('Git Pull') {
|
||||
dir(WORKSPACE_VAPT_DIR) {
|
||||
withCredentials([gitUsernamePassword(credentialsId: 'gitlab')]) {
|
||||
sh 'git stash push main.go && git status && git fetch && git pull && git stash pop'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Docker') {
|
||||
sh 'go run main.go'
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
error "Branch ${env.BRANCH_NAME} is not supported."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user