Update Jenkinsfile
Some checks failed
ecommerce-backend/pipeline/head There was a failure building this commit
Some checks failed
ecommerce-backend/pipeline/head There was a failure building this commit
This commit is contained in:
8
Jenkinsfile
vendored
8
Jenkinsfile
vendored
@@ -4,7 +4,6 @@ pipeline {
|
|||||||
environment {
|
environment {
|
||||||
HARBOR = 'harbor.myriadcara.com'
|
HARBOR = 'harbor.myriadcara.com'
|
||||||
IMAGE = 'harbor.myriadcara.com/vaishnavi-ecommerce/backend'
|
IMAGE = 'harbor.myriadcara.com/vaishnavi-ecommerce/backend'
|
||||||
SONAR_HOST = 'https://sonarqube.myriadcara.com'
|
|
||||||
SONAR_PROJECT = 'ecommerce'
|
SONAR_PROJECT = 'ecommerce'
|
||||||
VERSION_FILE = '/var/jenkins_home/vaishnavi-backend-version.txt'
|
VERSION_FILE = '/var/jenkins_home/vaishnavi-backend-version.txt'
|
||||||
}
|
}
|
||||||
@@ -20,15 +19,12 @@ pipeline {
|
|||||||
} else {
|
} else {
|
||||||
version = '1.0.0'
|
version = '1.0.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
def parts = version.tokenize('.')
|
def parts = version.tokenize('.')
|
||||||
def major = parts[0].toInteger()
|
def major = parts[0].toInteger()
|
||||||
def minor = parts[1].toInteger()
|
def minor = parts[1].toInteger()
|
||||||
def patch = parts[2].toInteger() + 1
|
def patch = parts[2].toInteger() + 1
|
||||||
|
|
||||||
def newVersion = "${major}.${minor}.${patch}"
|
def newVersion = "${major}.${minor}.${patch}"
|
||||||
writeFile file: VERSION_FILE, text: newVersion
|
writeFile file: VERSION_FILE, text: newVersion
|
||||||
|
|
||||||
env.TAG = newVersion
|
env.TAG = newVersion
|
||||||
echo "🏷️ New image tag: v${env.TAG}"
|
echo "🏷️ New image tag: v${env.TAG}"
|
||||||
}
|
}
|
||||||
@@ -37,7 +33,7 @@ pipeline {
|
|||||||
|
|
||||||
stage('SonarQube Scan') {
|
stage('SonarQube Scan') {
|
||||||
steps {
|
steps {
|
||||||
withSonarQubeEnv('SonarQube') {
|
withSonarQubeEnv('SonarQube') { // 'SonarQube' must match Jenkins config name
|
||||||
withCredentials([string(
|
withCredentials([string(
|
||||||
credentialsId: 'sonarqube-token',
|
credentialsId: 'sonarqube-token',
|
||||||
variable: 'SONAR_TOKEN'
|
variable: 'SONAR_TOKEN'
|
||||||
@@ -47,7 +43,7 @@ pipeline {
|
|||||||
-Dsonar.projectKey=${SONAR_PROJECT} \
|
-Dsonar.projectKey=${SONAR_PROJECT} \
|
||||||
-Dsonar.projectName=${SONAR_PROJECT} \
|
-Dsonar.projectName=${SONAR_PROJECT} \
|
||||||
-Dsonar.sources=. \
|
-Dsonar.sources=. \
|
||||||
-Dsonar.login=\$SONAR_TOKEN \
|
-Dsonar.token=\$SONAR_TOKEN \
|
||||||
-Dsonar.projectVersion=${env.TAG}
|
-Dsonar.projectVersion=${env.TAG}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user