Skip to content
Open
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
102 changes: 55 additions & 47 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def registry = 'https://valaxy01.jfrog.io'
def imageName = 'valaxy01.jfrog.io/valaxy-docker-local/ttrend'
def version = '2.1.2'
def registry = 'https://kummi.jfrog.io/'
def imageName = 'kummi.jfrog.io/kummi-docker-local/ttrend'
def version = '2.0.2'
pipeline {
agent {
node {
Expand All @@ -9,55 +9,64 @@ pipeline {
}

environment {
PATH = "/opt/apache-maven-3.9.1/bin:$PATH"
PATH = "/opt/apache-maven-3.9.2/bin:$PATH"
}
stages {
stage('build'){
steps {
echo '------------------- Build Started -------------'
sh 'mvn clean deploy -Dmaven.test.skip=true'
echo '------------------- Build Completed -------------'

stage('build the code'){
steps{
echo '----------------------------------------------Build Started--------------------------'
sh 'mvn clean deploy -Dmaven-test-skip=true'
echo '----------------------------------------------Build Completed--------------------------'
}
}

stage('Unit Test') {
steps{
echo '------------------- Unit Test Started -------------'
echo '----------------------------------------------Unit Test Started--------------------------'
sh 'mvn surefire-report:report'
echo '------------------- Unit Test Completed -------------'
echo '----------------------------------------------Unit Test Completed--------------------------'
}
}

stage('SonarQube analysis') {
environment {
scannerHome = tool 'Valaxy-SonarScanner'
}
steps {
echo '------------------- Sonar Started -------------'
withSonarQubeEnv('Valaxy-SonarQube-Server') { // If you have configured more than one global server connection, you can specify its name
sh "${scannerHome}/bin/sonar-scanner"
}
echo '------------------- Sonar Analysis Completed -------------'
}
}
stage("Quality Gate"){
steps {
script {
timeout(time: 1, unit: 'HOURS') { // Just in case something goes wrong, pipeline will be killed after a timeout
def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}



stage("SonarQube Analysis"){
environment {
scannerHome = tool 'SonarScanner'
}
steps
{
echo '----------------------------------------------SonarQube Started--------------------------'
withSonarQubeEnv('Sonarqube-server'){
sh '${scannerHome}/bin/sonar-scanner'
echo '----------------------------------------------Sonarqube Analysis Completed--------------------------'
}
}
}

stage("Jar Publish") {

stage("Quality Gate"){
steps {
script {
timeout(time: 1, unit: 'HOURS'){
def qg = waitForQualityGate()
if (qg.status != 'OK'){
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
}




stage("Jar Publish") {
steps {
script {
echo '<--------------- Jar Publish Started --------------->'
def server = Artifactory.newServer url:registry+"/artifactory" , credentialsId:"artifactory_token"
def server = Artifactory.newServer url:registry+"/artifactory" , credentialsId:"jfrog-artifact"
def properties = "buildid=${env.BUILD_ID},commitid=${GIT_COMMIT}";
def uploadSpec = """{
"files": [
Expand All @@ -78,6 +87,7 @@ environment {
}
}
}

stage(" Docker Build ") {
steps {
script {
Expand All @@ -86,26 +96,24 @@ environment {
echo '<--------------- Docker Build Ends --------------->'
}
}
}
}



stage (" Docker Publish "){
steps {
script {
echo '<--------------- Docker Publish Started --------------->'
docker.withRegistry(registry, 'artifactory_token'){
docker.withRegistry(registry, 'jfrog-artifact'){
app.push()
}
echo '<--------------- Docker Publish Ended --------------->'
}
}
}


}
stage (" deployment "){
steps {
script {
sh 'helm install ttrend-v2 ttrend-0.1.0.tgz'
}
}
}


}
}

18 changes: 18 additions & 0 deletions Jenkinsfilebyme
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pipeline {
agent {
node {
label 'maven-agent'
}
}

environment {
PATH = "/opt/apache-maven-3.9.2/bin:$PATH"
}
stages {
stage('build the code'){
steps{
sh 'mvn clean deploy'
}
}
}
}
111 changes: 111 additions & 0 deletions jenkinsdefaultfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
def registry = 'https://valaxy01.jfrog.io'
def imageName = 'valaxy01.jfrog.io/valaxy-docker-local/ttrend'
def version = '2.1.2'
pipeline {
agent {
node {
label 'maven-agent'
}
}

environment {
PATH = "/opt/apache-maven-3.9.1/bin:$PATH"
}
stages {
stage('build'){
steps {
echo '------------------- Build Started -------------'
sh 'mvn clean deploy -Dmaven.test.skip=true'
echo '------------------- Build Completed -------------'
}
}

stage('Unit Test') {
steps{
echo '------------------- Unit Test Started -------------'
sh 'mvn surefire-report:report'
echo '------------------- Unit Test Completed -------------'
}
}

stage('SonarQube analysis') {
environment {
scannerHome = tool 'Valaxy-SonarScanner'
}
steps {
echo '------------------- Sonar Started -------------'
withSonarQubeEnv('Valaxy-SonarQube-Server') { // If you have configured more than one global server connection, you can specify its name
sh "${scannerHome}/bin/sonar-scanner"
}
echo '------------------- Sonar Analysis Completed -------------'
}
}
stage("Quality Gate"){
steps {
script {
timeout(time: 1, unit: 'HOURS') { // Just in case something goes wrong, pipeline will be killed after a timeout
def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
}

stage("Jar Publish") {
steps {
script {
echo '<--------------- Jar Publish Started --------------->'
def server = Artifactory.newServer url:registry+"/artifactory" , credentialsId:"artifactory_token"
def properties = "buildid=${env.BUILD_ID},commitid=${GIT_COMMIT}";
def uploadSpec = """{
"files": [
{
"pattern": "jarstaging/(*)",
"target": "libs-release-local/{1}",
"flat": "false",
"props" : "${properties}",
"exclusions": [ "*.sha1", "*.md5"]
}
]
}"""
def buildInfo = server.upload(uploadSpec)
buildInfo.env.collect()
server.publishBuildInfo(buildInfo)
echo '<--------------- Jar Publish Ended --------------->'

}
}
}
stage(" Docker Build ") {
steps {
script {
echo '<--------------- Docker Build Started --------------->'
app = docker.build(imageName+":"+version)
echo '<--------------- Docker Build Ends --------------->'
}
}
}
stage (" Docker Publish "){
steps {
script {
echo '<--------------- Docker Publish Started --------------->'
docker.withRegistry(registry, 'artifactory_token'){
app.push()
}
echo '<--------------- Docker Publish Ended --------------->'
}
}
}
stage (" deployment "){
steps {
script {
sh 'helm install ttrend-v2 ttrend-0.1.0.tgz'
}
}
}

}
}

8 changes: 4 additions & 4 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
sonar.verbose=true
sonar.projectKey=valaxy-ttrend
sonar.organization=valaxy01
sonar.projectName=twittertrend
sonar.projectKey=kummi-ttrend
sonar.organization=kummi
sonar.projectName=twitter_trend
sonar.language=java
sonar.sourceEncoding=UTF-8
sonar.sources=.
sonar.java.binaries=target/classes
sonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml
sonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml
1 change: 1 addition & 0 deletions texts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
my_new text