From a0dd7738d5ad48ea96c8590a6293fcb36e6176cc Mon Sep 17 00:00:00 2001 From: Mohit singh <78977366+singhmohit14072002@users.noreply.github.com> Date: Mon, 18 Sep 2023 18:26:00 +0530 Subject: [PATCH 1/7] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 417d86fc..90b4681f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,7 +9,7 @@ pipeline{ choice(name: 'action', choices: 'create\ndelete', description: 'Choose create/Destroy') string(name: 'ImageName', description: "name of the docker build", defaultValue: 'javapp') string(name: 'ImageTag', description: "tag of the docker build", defaultValue: 'v1') - string(name: 'DockerHubUser', description: "name of the Application", defaultValue: 'praveensingam1994') + string(name: 'DockerHubUser', description: "name of the Application", defaultValue: 'singhmohit14072002') } stages{ From d6e5a2f0554ec38d69fa7b0cc66cfcbdd95a468b Mon Sep 17 00:00:00 2001 From: Mohit singh <78977366+singhmohit14072002@users.noreply.github.com> Date: Mon, 18 Sep 2023 18:57:36 +0530 Subject: [PATCH 2/7] Update Jenkinsfile From 57adc0ae06b5244ad6bc8237bc57f4eb9aeff0e8 Mon Sep 17 00:00:00 2001 From: Mohit singh <78977366+singhmohit14072002@users.noreply.github.com> Date: Thu, 28 Sep 2023 23:58:36 +0530 Subject: [PATCH 3/7] update the jenkins file --- Jenkinsfile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 90b4681f..0c5ca059 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -72,6 +72,16 @@ pipeline{ } } } + stage('Push JAR to Jfrog : python'){ + when { expression { params.action == 'create'} } + steps{ + script{ + + jarPush() + } + } + + } stage('Docker Image Build'){ when { expression { params.action == 'create' } } steps{ From 3bd3280a11afa090e459c9a596dfe5bdea07c3d5 Mon Sep 17 00:00:00 2001 From: Mohit singh <78977366+singhmohit14072002@users.noreply.github.com> Date: Fri, 29 Sep 2023 00:18:45 +0530 Subject: [PATCH 4/7] Create jfrog.py --- jfrog.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 jfrog.py diff --git a/jfrog.py b/jfrog.py new file mode 100644 index 00000000..0c6b9b24 --- /dev/null +++ b/jfrog.py @@ -0,0 +1,8 @@ +import requests + +url = "https://myurl.jfrog.io/artifactory/reponame-generic-local" +auth = ("myusername", "mypassword") +file_name = "test.txt" + +response = requests.put(url + "/data/" + file_name, auth=auth, data=open(file_name, "rb")) +print(response.status_code) From cf075ed4266d78de05414d082ff3a811f001f453 Mon Sep 17 00:00:00 2001 From: Mohit singh <78977366+singhmohit14072002@users.noreply.github.com> Date: Fri, 29 Sep 2023 13:56:44 +0530 Subject: [PATCH 5/7] Update Jenkinsfile --- Jenkinsfile | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0c5ca059..c2452477 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -43,26 +43,26 @@ pipeline{ } } } - // stage('Static code analysis: Sonarqube'){ - // when { expression { params.action == 'create' } } - // steps{ - // script{ + stage('Static code analysis: Sonarqube'){ + when { expression { params.action == 'create' } } + steps{ + script{ - // def SonarQubecredentialsId = 'sonarqube-api' - // statiCodeAnalysis(SonarQubecredentialsId) - // } - // } - // } - // stage('Quality Gate Status Check : Sonarqube'){ - // when { expression { params.action == 'create' } } - // steps{ - // script{ + def SonarQubecredentialsId = 'sonarqube-api' + statiCodeAnalysis(SonarQubecredentialsId) + } + } + } + stage('Quality Gate Status Check : Sonarqube'){ + when { expression { params.action == 'create' } } + steps{ + script{ - // def SonarQubecredentialsId = 'sonarqube-api' - // QualityGateStatus(SonarQubecredentialsId) - // } - // } - // } + def SonarQubecredentialsId = 'sonarqube-api' + QualityGateStatus(SonarQubecredentialsId) + } + } + } stage('Maven Build : maven'){ when { expression { params.action == 'create' } } steps{ From 28c2e1faf2f0977873a0bf99a063fd14f76e521f Mon Sep 17 00:00:00 2001 From: Mohit singh <78977366+singhmohit14072002@users.noreply.github.com> Date: Tue, 3 Oct 2023 10:53:51 +0530 Subject: [PATCH 6/7] Update jfrog.py --- jfrog.py | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/jfrog.py b/jfrog.py index 0c6b9b24..fa3703ae 100644 --- a/jfrog.py +++ b/jfrog.py @@ -1,8 +1,41 @@ +#!/usr/bin/env python3 + import requests +import subprocess + +def jfrogUpload(): + url = 'http://54.153.105.80:8082/artifactory/example-repo-local/kubernetes-configmap-reload-0.0.1-SNAPSHOT.jar' + file_path = '/home/ubuntu/Java_app_3.0/target/kubernetes-configmap-reload-0.0.1-SNAPSHOT.jar' + username = 'admin' + password = 'Mohit@14072002' + + with open(file_path, 'rb') as file: + response = requests.put(url, auth=(username, password), data=file) + + if response.status_code == 201: + print("\nPUT request was successful!") + else: + print(f"PUT request failed with status code {response.status_code}") + print("Response content:") + print(response.text) + + +def mvnBuild(): + + maven_command = "mvn clean install -DskipTests" + + try: + subprocess.run(maven_command, check=True, text=True, shell=True) + print("\nMaven build completed successfully.") + + except subprocess.CalledProcessError as e: + print(f"Error: Maven build failed with exit code {e.returncode}") + -url = "https://myurl.jfrog.io/artifactory/reponame-generic-local" -auth = ("myusername", "mypassword") -file_name = "test.txt" +def main(): + mvnBuild() + jfrogUpload() -response = requests.put(url + "/data/" + file_name, auth=auth, data=open(file_name, "rb")) -print(response.status_code) +######################################################### +if __name__ == "__main__": + main() From 9c6a3485fb3b39ca152ca84c4c5a03d79dcdf3ac Mon Sep 17 00:00:00 2001 From: Mohit singh <78977366+singhmohit14072002@users.noreply.github.com> Date: Tue, 3 Oct 2023 10:55:49 +0530 Subject: [PATCH 7/7] Update Jenkinsfile --- Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c2452477..c0599401 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -73,14 +73,13 @@ pipeline{ } } stage('Push JAR to Jfrog : python'){ - when { expression { params.action == 'create'} } + when { expression { params.action == 'create'} } steps{ script{ jarPush() } } - } stage('Docker Image Build'){ when { expression { params.action == 'create' } }