Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jenkins file update #22

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
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
47 changes: 28 additions & 19 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand All @@ -72,6 +72,15 @@ 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{
Expand Down
41 changes: 41 additions & 0 deletions jfrog.py
Original file line number Diff line number Diff line change
@@ -0,0 +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}")


def main():
mvnBuild()
jfrogUpload()

#########################################################
if __name__ == "__main__":
main()