diff --git a/Dockerfile b/Dockerfile index ceb6b0a..803f072 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -FROM tomcat -WORKDIR webapps +FROM tomcat:11 +WORKDIR /usr/local/tomcat/webapps COPY target/WebApp.war . RUN rm -rf ROOT && mv WebApp.war ROOT.war ENTRYPOINT ["sh", "/usr/local/tomcat/bin/startup.sh"] diff --git a/Jenkinsfile b/Jenkinsfile index fdfa316..65826ac 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline { environment { Docker_tag = getDockerTag() - account_id = "941277531445" // Replace with your actual AWS account ID + account_id = "941277531445" // Replace with your actual AWS account ID region = "ap-south-1" // Replace with your desired AWS region cluster_name = "jenkins-k8s" // Replace with your EKS cluster name } @@ -45,6 +45,39 @@ pipeline { } } } + + stage('Linting') { + parallel { + stage('Dockerfile Lint') { + steps { + script { + echo "Linting Dockerfile using Hadolint..." + // Uses Hadolint via Docker to check the Dockerfile + sh "docker run --rm -i hadolint/hadolint < Dockerfile" + } + } + } + stage('Kubernetes Lint') { + steps { + script { + echo "Linting Kubernetes Manifests using Kubeconform..." + // Validates your deployment.yaml against Kubernetes schemas + sh "docker run --rm -v \$(pwd):/project -w /project ghcr.io/yannh/kubeconform:latest deployment.yaml" + } + } + } + stage('Java Lint / Checkstyle') { + steps { + script { + echo "Running Java Checkstyle via Maven..." + // Runs Maven Checkstyle plugin to enforce coding standards + sh "mvn checkstyle:check" + } + } + } + } + } + stage('Static code analysis') { steps { script { @@ -118,9 +151,9 @@ pipeline { // Check connection to Kubernetes cluster echo "Checking connection to Kubernetes cluster..." sh "aws eks update-kubeconfig --region ${region} --name ${cluster_name}" - sh "kubectl get po" - sh "kubectl apply -f deployment.yaml" - sh "kubectl rollout status deployment/devops-training" + // sh "kubectl get po" + // sh "kubectl apply -f deployment.yaml" + // sh "kubectl rollout status deployment/devops-training" } } } diff --git a/README.md b/README.md index 78662a2..dd51a17 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ # Build Instruction - ``` mvn clean package and build the instruction . diff --git a/ansible.yaml b/ansible.yaml index a349d7b..785db8c 100644 --- a/ansible.yaml +++ b/ansible.yaml @@ -8,4 +8,4 @@ command: kubectl delete -f /root/deployment.yaml - name: Create a Deployment by reading the definition from a local file command: kubectl apply -f /root/deployment.yaml - +