diff --git a/Jenkinsfile b/Jenkinsfile index d123a85..f009045 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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 { @@ -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": [ @@ -78,6 +87,7 @@ environment { } } } + stage(" Docker Build ") { steps { script { @@ -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' - } - } - } + } -} - diff --git a/Jenkinsfilebyme b/Jenkinsfilebyme new file mode 100644 index 0000000..b8b5935 --- /dev/null +++ b/Jenkinsfilebyme @@ -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' + } + } + } +} diff --git a/jenkinsdefaultfile b/jenkinsdefaultfile new file mode 100644 index 0000000..d123a85 --- /dev/null +++ b/jenkinsdefaultfile @@ -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' + } + } + } + +} +} + diff --git a/sonar-project.properties b/sonar-project.properties index 4ac1b27..708879e 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -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 \ No newline at end of file +sonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml diff --git a/texts.txt b/texts.txt new file mode 100644 index 0000000..9470ab7 --- /dev/null +++ b/texts.txt @@ -0,0 +1 @@ +my_new text