[
  {
    "path": "CODE_OF_CONDUCT.md",
    "content": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nWe as members, contributors, and leaders pledge to make participation in our\ncommunity a harassment-free experience for everyone, regardless of age, body\nsize, visible or invisible disability, ethnicity, sex characteristics, gender\nidentity and expression, level of experience, education, socio-economic status,\nnationality, personal appearance, race, religion, or sexual identity\nand orientation.\n\nWe pledge to act and interact in ways that contribute to an open, welcoming,\ndiverse, inclusive, and healthy community.\n\n## Our Standards\n\nExamples of behavior that contributes to a positive environment for our\ncommunity include:\n\n* Demonstrating empathy and kindness toward other people\n* Being respectful of differing opinions, viewpoints, and experiences\n* Giving and gracefully accepting constructive feedback\n* Accepting responsibility and apologizing to those affected by our mistakes,\n  and learning from the experience\n* Focusing on what is best not just for us as individuals, but for the\n  overall community\n\nExamples of unacceptable behavior include:\n\n* The use of sexualized language or imagery, and sexual attention or\n  advances of any kind\n* Trolling, insulting or derogatory comments, and personal or political attacks\n* Public or private harassment\n* Publishing others' private information, such as a physical or email\n  address, without their explicit permission\n* Other conduct which could reasonably be considered inappropriate in a\n  professional setting\n\n## Enforcement Responsibilities\n\nCommunity leaders are responsible for clarifying and enforcing our standards of\nacceptable behavior and will take appropriate and fair corrective action in\nresponse to any behavior that they deem inappropriate, threatening, offensive,\nor harmful.\n\nCommunity leaders have the right and responsibility to remove, edit, or reject\ncomments, commits, code, wiki edits, issues, and other contributions that are\nnot aligned to this Code of Conduct, and will communicate reasons for moderation\ndecisions when appropriate.\n\n## Scope\n\nThis Code of Conduct applies within all community spaces, and also applies when\nan individual is officially representing the community in public spaces.\nExamples of representing our community include using an official e-mail address,\nposting via an official social media account, or acting as an appointed\nrepresentative at an online or offline event.\n\n## Enforcement\n\nInstances of abusive, harassing, or otherwise unacceptable behavior may be\nreported to the community leaders responsible for enforcement at\n.\nAll complaints will be reviewed and investigated promptly and fairly.\n\nAll community leaders are obligated to respect the privacy and security of the\nreporter of any incident.\n\n## Enforcement Guidelines\n\nCommunity leaders will follow these Community Impact Guidelines in determining\nthe consequences for any action they deem in violation of this Code of Conduct:\n\n### 1. Correction\n\n**Community Impact**: Use of inappropriate language or other behavior deemed\nunprofessional or unwelcome in the community.\n\n**Consequence**: A private, written warning from community leaders, providing\nclarity around the nature of the violation and an explanation of why the\nbehavior was inappropriate. A public apology may be requested.\n\n### 2. Warning\n\n**Community Impact**: A violation through a single incident or series\nof actions.\n\n**Consequence**: A warning with consequences for continued behavior. No\ninteraction with the people involved, including unsolicited interaction with\nthose enforcing the Code of Conduct, for a specified period of time. This\nincludes avoiding interactions in community spaces as well as external channels\nlike social media. Violating these terms may lead to a temporary or\npermanent ban.\n\n### 3. Temporary Ban\n\n**Community Impact**: A serious violation of community standards, including\nsustained inappropriate behavior.\n\n**Consequence**: A temporary ban from any sort of interaction or public\ncommunication with the community for a specified period of time. No public or\nprivate interaction with the people involved, including unsolicited interaction\nwith those enforcing the Code of Conduct, is allowed during this period.\nViolating these terms may lead to a permanent ban.\n\n### 4. Permanent Ban\n\n**Community Impact**: Demonstrating a pattern of violation of community\nstandards, including sustained inappropriate behavior,  harassment of an\nindividual, or aggression toward or disparagement of classes of individuals.\n\n**Consequence**: A permanent ban from any sort of public interaction within\nthe community.\n\n## Attribution\n\nThis Code of Conduct is adapted from the [Contributor Covenant][homepage],\nversion 2.0, available at\nhttps://www.contributor-covenant.org/version/2/0/code_of_conduct.html.\n\nCommunity Impact Guidelines were inspired by [Mozilla's code of conduct\nenforcement ladder](https://github.com/mozilla/diversity).\n\n[homepage]: https://www.contributor-covenant.org\n\nFor answers to common questions about this code of conduct, see the FAQ at\nhttps://www.contributor-covenant.org/faq. Translations are available at\nhttps://www.contributor-covenant.org/translations.\n"
  },
  {
    "path": "Interview_Questions.md",
    "content": "## NOTE: While I have prepared all the questions, to provide better answers in a detailed way, the summary provided below is the collection of my knowledge and information from various sources like Medium, Stack Overflow, ChatGPT.\n\nQ: Can you explain the CICD process in your current project ? or Can you talk about any CICD process that you have implemented ?\n\nA: In the current project we use the following tools orchestrated with Jenkins to achieve CICD.\n   - Maven, Sonar, AppScan, ArgoCD, and Kubernetes\n   \n   Coming to the implementation, the entire process takes place in 8 steps\n    \n    1. Code Commit: Developers commit code changes to a Git repository hosted on GitHub.\n    2. Jenkins Build: Jenkins is triggered to build the code using Maven. Maven builds the code and runs unit tests.\n    3. Code Analysis: Sonar is used to perform static code analysis to identify any code quality issues, security vulnerabilities, and bugs.\n    4. Security Scan: AppScan is used to perform a security scan on the application to identify any security vulnerabilities.\n    5. Deploy to Dev Environment: If the build and scans pass, Jenkins deploys the code to a development environment managed by Kubernetes.\n    6. Continuous Deployment: ArgoCD is used to manage continuous deployment. ArgoCD watches the Git repository and automatically deploys new changes to the development environment as soon as they are committed.\n    7. Promote to Production: When the code is ready for production, it is manually promoted using ArgoCD to the production environment.\n    8. Monitoring: The application is monitored for performance and availability using Kubernetes tools and other monitoring tools.\n   \n\nQ: What are the different ways to trigger jenkins pipelines ?\n\nA: This can be done in multiple ways,\n   To briefly explain about the different options,\n   ```\n     - Poll SCM: Jenkins can periodically check the repository for changes and automatically build if changes are detected. \n                 This can be configured in the \"Build Triggers\" section of a job.\n                 \n     - Build Triggers: Jenkins can be configured to use the Git plugin, which allows you to specify a Git repository and branch to build. \n                 The plugin can be configured to automatically build when changes are pushed to the repository.\n                 \n     - Webhooks: A webhook can be created in GitHub to notify Jenkins when changes are pushed to the repository. \n                 Jenkins can then automatically build the updated code. This can be set up in the \"Build Triggers\" section of a job and in the GitHub repository settings.\n   ```\nQ: How to backup Jenkins ?\n\nA: Backing up Jenkins is a very easy process, there are multiple default and configured files and folders in Jenkins that you might want to backup.\n```  \n  - Configuration: The `~/.jenkins` folder. You can use a tool like rsync to backup the entire directory to another location.\n  \n    - Plugins: Backup the plugins installed in Jenkins by copying the plugins directory located in JENKINS_HOME/plugins to another location.\n    \n    - Jobs: Backup the Jenkins jobs by copying the jobs directory located in JENKINS_HOME/jobs to another location.\n    \n    - User Content: If you have added any custom content, such as build artifacts, scripts, or job configurations, to the Jenkins environment, make sure to backup those as well.\n    \n    - Database Backup: If you are using a database to store information such as build results, you will need to backup the database separately. This typically involves using a database backup tool, such as mysqldump for MySQL, to export the data to another location.\n```\nOne can schedule the backups to occur regularly, such as daily or weekly, to ensure that you always have a recent copy of your Jenkins environment available. You can use tools such as cron or Windows Task Scheduler to automate the backup process.\n\nQ: How do you store/secure/handle secrets in Jenkins ?\n\nA: Again, there are multiple ways to achieve this, \n   Let me give you a brief explanation of all the posible options.\n```  \n   - Credentials Plugin: Jenkins provides a credentials plugin that can be used to store secrets such as passwords, API keys, and certificates. The secrets are encrypted and stored securely within Jenkins, and can be easily retrieved in build scripts or used in other plugins.\n   \n   - Environment Variables: Secrets can be stored as environment variables in Jenkins and referenced in build scripts. However, this method is less secure because environment variables are visible in the build logs.\n   \n   - Hashicorp Vault: Jenkins can be integrated with Hashicorp Vault, which is a secure secrets management tool. Vault can be used to store and manage sensitive information, and Jenkins can retrieve the secrets as needed for builds.\n   \n   - Third-party Secret Management Tools: Jenkins can also be integrated with third-party secret management tools such as AWS Secrets Manager, Google Cloud Key Management Service, and Azure Key Vault.\n```\n\nQ: What is latest version of Jenkins or which version of Jenkins are you using ?\n\nA: This is a very simple question interviewers ask to understand if you are actually using Jenkins day-to-day, so always be prepared for this.\n\nQ: What is shared modules in Jenkins ?\n\nA: Shared modules in Jenkins refer to a collection of reusable code and resources that can be shared across multiple Jenkins jobs. This allows for easier maintenance, reduced duplication, and improved consistency across multiple build processes.\n   For example, shared modules can be used in cases like:\n```\n        - Libraries: Custom Java libraries, shell scripts, and other resources that can be reused across multiple jobs.\n        \n        - Jenkinsfile: A shared Jenkinsfile can be used to define the build process for multiple jobs, reducing duplication and making it easier to manage the build process for multiple projects.\n        \n        - Plugins: Common plugins can be installed once as a shared module and reused across multiple jobs, reducing the overhead of managing plugins on individual jobs.\n        \n        - Global Variables: Shared global variables can be defined and used across multiple jobs, making it easier to manage common build parameters such as version numbers, artifact repositories, and environment variables.\n```\n\nQ: can you use Jenkins to build applications with multiple programming languages using different agents in different stages ?\n\nA: Yes, Jenkins can be used to build applications with multiple programming languages by using different build agents in different stages of the build process.\n\nJenkins supports multiple build agents, which can be used to run build jobs on different platforms and with different configurations. By using different agents in different stages of the build process, you can build applications with multiple programming languages and ensure that the appropriate tools and libraries are available for each language.\n\nFor example, you can use one agent for compiling Java code and another agent for building a Node.js application. The agents can be configured to use different operating systems, different versions of programming languages, and different libraries and tools.\n\nJenkins also provides a wide range of plugins that can be used to support multiple programming languages and build tools, making it easy to integrate different parts of the build process and manage the dependencies required for each stage.\n\nOverall, Jenkins is a flexible and powerful tool that can be used to build applications with multiple programming languages and support different stages of the build process.\n\nQ: How to setup auto-scaling group for Jenkins in AWS ?\n\nA: Here is a high-level overview of how to set up an autoscaling group for Jenkins in Amazon Web Services (AWS):\n```\n    - Launch EC2 instances: Create an Amazon Elastic Compute Cloud (EC2) instance with the desired configuration and install Jenkins on it. This instance will be used as the base image for the autoscaling group.\n    \n    - Create Launch Configuration: Create a launch configuration in AWS Auto Scaling that specifies the EC2 instance type, the base image (created in step 1), and any additional configuration settings such as storage, security groups, and key pairs.\n    \n    - Create Autoscaling Group: Create an autoscaling group in AWS Auto Scaling and specify the launch configuration created in step 2. Also, specify the desired number of instances, the minimum number of instances, and the maximum number of instances for the autoscaling group.\n    \n    - Configure Scaling Policy: Configure a scaling policy for the autoscaling group to determine when new instances should be added or removed from the group. This can be based on the average CPU utilization of the instances or other performance metrics.\n    \n    - Load Balancer: Create a load balancer in Amazon Elastic Load Balancer (ELB) and configure it to forward traffic to the autoscaling group.\n    \n    - Connect to Jenkins: Connect to the Jenkins instance using the load balancer endpoint or the public IP address of one of the instances in the autoscaling group.\n    \n    - Monitoring: Monitor the instances in the autoscaling group using Amazon CloudWatch to ensure that they are healthy and that the autoscaling policy is functioning as expected.\n\n By using an autoscaling group for Jenkins, you can ensure that you have the appropriate number of instances available to handle the load on your build processes, and that new instances can be added or removed automatically as needed. This helps to ensure the reliability and scalability of your Jenkins environment.\n```\n\nQ: How to add a new worker node in Jenkins ?\n\nA: Log into the Jenkins master and navigate to Manage Jenkins > Manage Nodes > New Node. Enter a name for the new node and select Permanent Agent. Configure SSH and click on Launch.\n\nQ: How to add a new plugin in Jenkins ?\n\nA: Using the CLI, \n   `java -jar jenkins-cli.jar install-plugin <PLUGIN_NAME>`\n  \n  Using the UI,\n\n   1. Click on the \"Manage Jenkins\" link in the left-side menu.\n   2. Click on the \"Manage Plugins\" link.\n\nQ: What is JNLP and why is it used in Jenkins ?\n\nA: In Jenkins, JNLP is used to allow agents (also known as \"slave nodes\") to be launched and managed remotely by the Jenkins master instance. This allows Jenkins to distribute build tasks to multiple agents, providing scalability and improving performance.\n\n   When a Jenkins agent is launched using JNLP, it connects to the Jenkins master and receives build tasks, which it then executes. The results of the build are then sent back to the master and displayed in the Jenkins user interface.\n\nQ: What are some of the common plugins that you use in Jenkins ?\n\nA: Be prepared for answer, you need to have atleast 3-4 on top of your head, so that interview feels you use jenkins on a day-to-day basis.\n\n\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2023 Abhishek Veeramalla\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# Jenkins-Zero-To-Hero\n\nAre you looking forward to learn Jenkins right from Zero(installation) to Hero(Build end to end pipelines)? then you are at the right place. \n\n## Installation on EC2 Instance\n\nYouTube Video ->\nhttps://www.youtube.com/watch?v=zZfhAXfBvVA&list=RDCMUCnnQ3ybuyFdzvgv2Ky5jnAA&index=1\n\n\n![Screenshot 2023-02-01 at 5 46 14 PM](https://user-images.githubusercontent.com/43399466/216040281-6c8b89c3-8c22-4620-ad1c-8edd78eb31ae.png)\n\nInstall Jenkins, configure Docker as agent, set up cicd, deploy applications to k8s and much more.\n\n## AWS EC2 Instance\n\n- Go to AWS Console\n- Instances(running)\n- Launch instances\n\n<img width=\"994\" alt=\"Screenshot 2023-02-01 at 12 37 45 PM\" src=\"https://user-images.githubusercontent.com/43399466/215974891-196abfe9-ace0-407b-abd2-adcffe218e3f.png\">\n\n### Install Jenkins.\n\nPre-Requisites:\n - Java (JDK)\n\n### Run the below commands to install Java and Jenkins\n\nInstall Java\n\n```\nsudo apt update\nsudo apt install openjdk-17-jre\n```\n\nVerify Java is Installed\n\n```\njava -version\n```\n\nNow, you can proceed with installing Jenkins\n\n```\ncurl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee \\\n  /usr/share/keyrings/jenkins-keyring.asc > /dev/null\necho deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \\\n  https://pkg.jenkins.io/debian binary/ | sudo tee \\\n  /etc/apt/sources.list.d/jenkins.list > /dev/null\nsudo apt-get update\nsudo apt-get install jenkins\n```\n\n**Note: ** By default, Jenkins will not be accessible to the external world due to the inbound traffic restriction by AWS. Open port 8080 in the inbound traffic rules as show below.\n\n- EC2 > Instances > Click on <Instance-ID>\n- In the bottom tabs -> Click on Security\n- Security groups\n- Add inbound traffic rules as shown in the image (you can just allow TCP 8080 as well, in my case, I allowed `All traffic`).\n\n<img width=\"1187\" alt=\"Screenshot 2023-02-01 at 12 42 01 PM\" src=\"https://user-images.githubusercontent.com/43399466/215975712-2fc569cb-9d76-49b4-9345-d8b62187aa22.png\">\n\n\n### Login to Jenkins using the below URL:\n\nhttp://<ec2-instance-public-ip-address>:8080    [You can get the ec2-instance-public-ip-address from your AWS EC2 console page]\n\nNote: If you are not interested in allowing `All Traffic` to your EC2 instance\n      1. Delete the inbound traffic rule for your instance\n      2. Edit the inbound traffic rule to only allow custom TCP port `8080`\n  \nAfter you login to Jenkins, \n      - Run the command to copy the Jenkins Admin Password - `sudo cat /var/lib/jenkins/secrets/initialAdminPassword`\n      - Enter the Administrator password\n      \n<img width=\"1291\" alt=\"Screenshot 2023-02-01 at 10 56 25 AM\" src=\"https://user-images.githubusercontent.com/43399466/215959008-3ebca431-1f14-4d81-9f12-6bb232bfbee3.png\">\n\n### Click on Install suggested plugins\n\n<img width=\"1291\" alt=\"Screenshot 2023-02-01 at 10 58 40 AM\" src=\"https://user-images.githubusercontent.com/43399466/215959294-047eadef-7e64-4795-bd3b-b1efb0375988.png\">\n\nWait for the Jenkins to Install suggested plugins\n\n<img width=\"1291\" alt=\"Screenshot 2023-02-01 at 10 59 31 AM\" src=\"https://user-images.githubusercontent.com/43399466/215959398-344b5721-28ec-47a5-8908-b698e435608d.png\">\n\nCreate First Admin User or Skip the step [If you want to use this Jenkins instance for future use-cases as well, better to create admin user]\n\n<img width=\"990\" alt=\"Screenshot 2023-02-01 at 11 02 09 AM\" src=\"https://user-images.githubusercontent.com/43399466/215959757-403246c8-e739-4103-9265-6bdab418013e.png\">\n\nJenkins Installation is Successful. You can now starting using the Jenkins \n\n<img width=\"990\" alt=\"Screenshot 2023-02-01 at 11 14 13 AM\" src=\"https://user-images.githubusercontent.com/43399466/215961440-3f13f82b-61a2-4117-88bc-0da265a67fa7.png\">\n\n## Install the Docker Pipeline plugin in Jenkins:\n\n   - Log in to Jenkins.\n   - Go to Manage Jenkins > Manage Plugins.\n   - In the Available tab, search for \"Docker Pipeline\".\n   - Select the plugin and click the Install button.\n   - Restart Jenkins after the plugin is installed.\n   \n<img width=\"1392\" alt=\"Screenshot 2023-02-01 at 12 17 02 PM\" src=\"https://user-images.githubusercontent.com/43399466/215973898-7c366525-15db-4876-bd71-49522ecb267d.png\">\n\nWait for the Jenkins to be restarted.\n\n\n## Docker Slave Configuration\n\nRun the below command to Install Docker\n\n```\nsudo apt update\nsudo apt install docker.io\n```\n \n### Grant Jenkins user and Ubuntu user permission to docker deamon.\n\n```\nsudo su - \nusermod -aG docker jenkins\nusermod -aG docker ubuntu\nsystemctl restart docker\n```\n\nOnce you are done with the above steps, it is better to restart Jenkins.\n\n```\nhttp://<ec2-instance-public-ip>:8080/restart\n```\n\nThe docker agent configuration is now successful.\n\n\n\n\n"
  },
  {
    "path": "java-maven-sonar-argocd-helm-k8s/Argo CD/argocd-basic.yaml",
    "content": "apiVersion: argoproj.io/v1alpha1\nkind: ArgoCD\nmetadata:\n  name: example-argocd\n  labels:\n    example: basic\nspec:\n  server:\n    service:\n      type: NodePort\n"
  },
  {
    "path": "java-maven-sonar-argocd-helm-k8s/README.md",
    "content": "# Jenkins Pipeline for Java based application using Maven, SonarQube, Argo CD, Helm and Kubernetes\n\n![Screenshot 2023-03-28 at 9 38 09 PM](https://user-images.githubusercontent.com/43399466/228301952-abc02ca2-9942-4a67-8293-f76647b6f9d8.png)\n\n\nHere are the step-by-step details to set up an end-to-end Jenkins pipeline for a Java application using SonarQube, Argo CD, Helm, and Kubernetes:\n\nPrerequisites:\n\n   -  Java application code hosted on a Git repository\n   -   Jenkins server\n   -  Kubernetes cluster\n   -  Helm package manager\n   -  Argo CD\n\nSteps:\n\n    1. Install the necessary Jenkins plugins:\n       1.1 Git plugin\n       1.2 Maven Integration plugin\n       1.3 Pipeline plugin\n       1.4 Kubernetes Continuous Deploy plugin\n\n    2. Create a new Jenkins pipeline:\n       2.1 In Jenkins, create a new pipeline job and configure it with the Git repository URL for the Java application.\n       2.2 Add a Jenkinsfile to the Git repository to define the pipeline stages.\n\n    3. Define the pipeline stages:\n        Stage 1: Checkout the source code from Git.\n        Stage 2: Build the Java application using Maven.\n        Stage 3: Run unit tests using JUnit and Mockito.\n        Stage 4: Run SonarQube analysis to check the code quality.\n        Stage 5: Package the application into a JAR file.\n        Stage 6: Deploy the application to a test environment using Helm.\n        Stage 7: Run user acceptance tests on the deployed application.\n        Stage 8: Promote the application to a production environment using Argo CD.\n\n    4. Configure Jenkins pipeline stages:\n        Stage 1: Use the Git plugin to check out the source code from the Git repository.\n        Stage 2: Use the Maven Integration plugin to build the Java application.\n        Stage 3: Use the JUnit and Mockito plugins to run unit tests.\n        Stage 4: Use the SonarQube plugin to analyze the code quality of the Java application.\n        Stage 5: Use the Maven Integration plugin to package the application into a JAR file.\n        Stage 6: Use the Kubernetes Continuous Deploy plugin to deploy the application to a test environment using Helm.\n        Stage 7: Use a testing framework like Selenium to run user acceptance tests on the deployed application.\n        Stage 8: Use Argo CD to promote the application to a production environment.\n\n    5. Set up Argo CD:\n        Install Argo CD on the Kubernetes cluster.\n        Set up a Git repository for Argo CD to track the changes in the Helm charts and Kubernetes manifests.\n        Create a Helm chart for the Java application that includes the Kubernetes manifests and Helm values.\n        Add the Helm chart to the Git repository that Argo CD is tracking.\n\n    6. Configure Jenkins pipeline to integrate with Argo CD:\n       6.1 Add the Argo CD API token to Jenkins credentials.\n       6.2 Update the Jenkins pipeline to include the Argo CD deployment stage.\n\n    7. Run the Jenkins pipeline:\n       7.1 Trigger the Jenkins pipeline to start the CI/CD process for the Java application.\n       7.2 Monitor the pipeline stages and fix any issues that arise.\n\nThis end-to-end Jenkins pipeline will automate the entire CI/CD process for a Java application, from code checkout to production deployment, using popular tools like SonarQube, Argo CD, Helm, and Kubernetes.\n"
  },
  {
    "path": "java-maven-sonar-argocd-helm-k8s/spring-boot-app/Dockerfile",
    "content": "# You can change this base image to anything else\n# But make sure to use the correct version of Java\nFROM adoptopenjdk/openjdk11:alpine-jre\n\n# Simply the artifact path\nARG artifact=target/spring-boot-web.jar\n\nWORKDIR /opt/app\n\nCOPY ${artifact} app.jar\n\n# This should not be changed\nENTRYPOINT [\"java\",\"-jar\",\"app.jar\"]\n"
  },
  {
    "path": "java-maven-sonar-argocd-helm-k8s/spring-boot-app/JenkinsFile",
    "content": "pipeline {\n  agent {\n    docker {\n      image 'abhishekf5/maven-abhishek-docker-agent:v1'\n      args '--user root -v /var/run/docker.sock:/var/run/docker.sock' // mount Docker socket to access the host's Docker daemon\n    }\n  }\n  stages {\n    stage('Checkout') {\n      steps {\n        sh 'echo passed'\n        //git branch: 'main', url: 'https://github.com/iam-veeramalla/Jenkins-Zero-To-Hero.git'\n      }\n    }\n    stage('Build and Test') {\n      steps {\n        sh 'ls -ltr'\n        // build the project and create a JAR file\n        sh 'cd java-maven-sonar-argocd-helm-k8s/spring-boot-app && mvn clean package'\n      }\n    }\n    stage('Static Code Analysis') {\n      environment {\n        SONAR_URL = \"http://34.201.116.83:9000\"\n      }\n      steps {\n        withCredentials([string(credentialsId: 'sonarqube', variable: 'SONAR_AUTH_TOKEN')]) {\n          sh 'cd java-maven-sonar-argocd-helm-k8s/spring-boot-app && mvn sonar:sonar -Dsonar.login=$SONAR_AUTH_TOKEN -Dsonar.host.url=${SONAR_URL}'\n        }\n      }\n    }\n    stage('Build and Push Docker Image') {\n      environment {\n        DOCKER_IMAGE = \"abhishekf5/ultimate-cicd:${BUILD_NUMBER}\"\n        // DOCKERFILE_LOCATION = \"java-maven-sonar-argocd-helm-k8s/spring-boot-app/Dockerfile\"\n        REGISTRY_CREDENTIALS = credentials('docker-cred')\n      }\n      steps {\n        script {\n            sh 'cd java-maven-sonar-argocd-helm-k8s/spring-boot-app && docker build -t ${DOCKER_IMAGE} .'\n            def dockerImage = docker.image(\"${DOCKER_IMAGE}\")\n            docker.withRegistry('https://index.docker.io/v1/', \"docker-cred\") {\n                dockerImage.push()\n            }\n        }\n      }\n    }\n    stage('Update Deployment File') {\n        environment {\n            GIT_REPO_NAME = \"Jenkins-Zero-To-Hero\"\n            GIT_USER_NAME = \"iam-veeramalla\"\n        }\n        steps {\n            withCredentials([string(credentialsId: 'github', variable: 'GITHUB_TOKEN')]) {\n                sh '''\n                    git config user.email \"abhishek.xyz@gmail.com\"\n                    git config user.name \"Abhishek Veeramalla\"\n                    BUILD_NUMBER=${BUILD_NUMBER}\n                    sed -i \"s/replaceImageTag/${BUILD_NUMBER}/g\" java-maven-sonar-argocd-helm-k8s/spring-boot-app-manifests/deployment.yml\n                    git add java-maven-sonar-argocd-helm-k8s/spring-boot-app-manifests/deployment.yml\n                    git commit -m \"Update deployment image to version ${BUILD_NUMBER}\"\n                    git push https://${GITHUB_TOKEN}@github.com/${GIT_USER_NAME}/${GIT_REPO_NAME} HEAD:main\n                '''\n            }\n        }\n    }\n  }\n}\n"
  },
  {
    "path": "java-maven-sonar-argocd-helm-k8s/spring-boot-app/README.md",
    "content": "# Spring Boot based Java web application\n \nThis is a simple Sprint Boot based Java application that can be built using Maven. Sprint Boot dependencies are handled using the pom.xml \nat the root directory of the repository.\n\nThis is a MVC architecture based application where controller returns a page with title and message attributes to the view.\n\n## Execute the application locally and access it using your browser\n\nCheckout the repo and move to the directory\n\n```\ngit clone https://github.com/iam-veeramalla/Jenkins-Zero-To-Hero/java-maven-sonar-argocd-helm-k8s/sprint-boot-app\ncd java-maven-sonar-argocd-helm-k8s/sprint-boot-app\n```\n\nExecute the Maven targets to generate the artifacts\n\n```\nmvn clean package\n```\n\nThe above maven target stroes the artifacts to the `target` directory. You can either execute the artifact on your local machine\n(or) run it as a Docker container.\n\n** Note: To avoid issues with local setup, Java versions and other dependencies, I would recommend the docker way. **\n\n\n### Execute locally (Java 11 needed) and access the application on http://localhost:8080\n\n```\njava -jar target/spring-boot-web.jar\n```\n\n### The Docker way\n\nBuild the Docker Image\n\n```\ndocker build -t ultimate-cicd-pipeline:v1 .\n```\n\n```\ndocker run -d -p 8010:8080 -t ultimate-cicd-pipeline:v1\n```\n\nHurray !! Access the application on `http://<ip-address>:8010`\n\n\n## Next Steps\n\n### Configure a Sonar Server locally\n\n```\nSystem Requirements\nJava 17+ (Oracle JDK, OpenJDK, or AdoptOpenJDK)\nHardware Recommendations:\n   Minimum 2 GB RAM\n   2 CPU cores\nsudo apt update && sudo apt install unzip -y\nadduser sonarqube\nwget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-10.4.1.88267.zip\nunzip *\nchown -R sonarqube:sonarqube /opt/sonarqube\nchmod -R 775 /opt/sonarqube\ncd /opt/sonarqube/bin/linux-x86-64\n./sonar.sh start\n```\n\nHurray !! Now you can access the `SonarQube Server` on `http://<ip-address>:9000` \n\n\n"
  },
  {
    "path": "java-maven-sonar-argocd-helm-k8s/spring-boot-app/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n         xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0</modelVersion>\n\n    <groupId>com.abhishek</groupId>\n    <artifactId>spring-boot-demo</artifactId>\n    <version>1.0</version>\n\n    <name>spring-boot-demo</name>\n    <url></url>\n\n    <parent>\n        <groupId>org.springframework.boot</groupId>\n        <artifactId>spring-boot-starter-parent</artifactId>\n        <version>2.2.4.RELEASE</version>\n    </parent>\n\n    <properties>\n        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n        <maven.compiler.source>11</maven.compiler.source>\n        <maven.compiler.target>11</maven.compiler.target>\n        <java.version>11</java.version>\n    </properties>\n\n    <dependencies>\n\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-web</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-thymeleaf</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-test</artifactId>\n            <scope>test</scope>\n        </dependency>\n\n        <!-- debugging -->\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-devtools</artifactId>\n            <optional>true</optional>\n        </dependency>\n\n    </dependencies>\n\n    <build>\n\n        <finalName>spring-boot-web</finalName>\n\n        <plugins>\n            <plugin>\n                <groupId>org.springframework.boot</groupId>\n                <artifactId>spring-boot-maven-plugin</artifactId>\n            </plugin>\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-compiler-plugin</artifactId>\n                <version>3.8.0</version>\n                <configuration>\n                    <source>${java.version}</source>\n                    <target>${java.version}</target>\n                </configuration>\n            </plugin>\n\n        </plugins>\n    </build>\n\n\n</project>\n"
  },
  {
    "path": "java-maven-sonar-argocd-helm-k8s/spring-boot-app/src/main/java/com/abhishek/StartApplication.java",
    "content": "package com.abhishek;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\nimport org.springframework.stereotype.Controller;\nimport org.springframework.ui.Model;\nimport org.springframework.web.bind.annotation.GetMapping;\n\n@SpringBootApplication\n@Controller\npublic class StartApplication {\n\n    @GetMapping(\"/\")\n    public String index(final Model model) {\n        model.addAttribute(\"title\", \"I have successfuly built a sprint boot application using Maven\");\n        model.addAttribute(\"msg\", \"This application is deployed on to Kubernetes using Argo CD\");\n        return \"index\";\n    }\n\n    public static void main(String[] args) {\n        SpringApplication.run(StartApplication.class, args);\n    }\n\n}\n"
  },
  {
    "path": "java-maven-sonar-argocd-helm-k8s/spring-boot-app/src/main/resources/application.properties",
    "content": "# nothing here yet\n"
  },
  {
    "path": "java-maven-sonar-argocd-helm-k8s/spring-boot-app/src/main/resources/static/css/main.css",
    "content": "body {\n  padding-top: 5rem;\n}\n.starter-template {\n  padding: 3rem 1.5rem;\n  text-align: center;\n}"
  },
  {
    "path": "java-maven-sonar-argocd-helm-k8s/spring-boot-app/src/main/resources/static/js/main.js",
    "content": ""
  },
  {
    "path": "java-maven-sonar-argocd-helm-k8s/spring-boot-app/src/main/resources/templates/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\" xmlns:th=\"http://www.thymeleaf.org\">\n<head>\n    <meta charset=\"utf-8\">\n    <link rel=\"stylesheet\" href=\"https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css\"/>\n    <link data-th-href=\"@{/css/main.css?{id}(id=${timestamp})}\" rel=\"stylesheet\">\n    <title>CI/CD Master Class By Abhishek Veeramalla</title>\n</head>\n<body>\n\n<nav class=\"navbar navbar-expand-md navbar-dark bg-dark fixed-top\">\n    <a class=\"navbar-brand\" href=\"#\">Ultimate CI/CD Pipeline using Java</div></a>\n</nav>\n\n<main role=\"main\" class=\"container\">\n    <div class=\"starter-template\">\n        <h1 th:text=\"${title}\">Default title.</h1>\n        <p th:text=\"${msg}\">Default text.</p>\n    </div>\n</main>\n\n<script data-th-src=\"@{/js/main.js}\"></script>\n</body>\n\n</html>\n"
  },
  {
    "path": "java-maven-sonar-argocd-helm-k8s/spring-boot-app-manifests/deployment.yml",
    "content": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: spring-boot-app\n  labels:\n    app: spring-boot-app\nspec:\n  replicas: 2\n  selector:\n    matchLabels:\n      app: spring-boot-app\n  template:\n    metadata:\n      labels:\n        app: spring-boot-app\n    spec:\n      containers:\n      - name: spring-boot-app\n        image: abhishekf5/ultimate-cicd:replaceImageTag\n        ports:\n        - containerPort: 8080\n"
  },
  {
    "path": "java-maven-sonar-argocd-helm-k8s/spring-boot-app-manifests/service.yml",
    "content": "apiVersion: v1\nkind: Service\nmetadata:\n  name: spring-boot-app-service\nspec:\n  type: NodePort\n  ports:\n  - name: http\n    port: 80\n    targetPort: 8080\n    protocol: TCP\n  selector:\n    app: spring-boot-app\n"
  },
  {
    "path": "multi-stage-multi-agent/Jenkinsfile",
    "content": "pipeline {\n  agent none\n  stages {\n    stage('Back-end') {\n      agent {\n        docker { image 'maven:3.8.1-adoptopenjdk-11' }\n      }\n      steps {\n        sh 'mvn --version'\n      }\n    }\n    stage('Front-end') {\n      agent {\n        docker { image 'node:16-alpine' }\n      }\n      steps {\n        sh 'node --version'\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "multi-stage-multi-agent/README.md",
    "content": "# Multi Stage Multi Agent\n\nSet up a multi stage jenkins pipeline where each stage is run on a unique agent. This is a very useful approach when you have multi language application\nor application that has conflicting dependencies.\n"
  },
  {
    "path": "my-first-pipeline/Jenkinsfile",
    "content": "pipeline {\n  agent {\n    docker { image 'node:16-alpine' }\n  }\n  stages {\n    stage('Test') {\n      steps {\n        sh 'node --version'\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "my-first-pipeline/README.md",
    "content": "# A simple jenkins pipeline to verify if the docker slave configuration is working as expected.\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/Dockerfile",
    "content": "FROM python:3\nRUN pip install django==3.2\n\nCOPY . .\n\nRUN python manage.py migrate\nEXPOSE 8000\nCMD [\"python\",\"manage.py\",\"runserver\",\"0.0.0.0:8000\"]\n\n\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/Jenkinsfile",
    "content": "pipeline {\n    \n    agent any \n    \n    environment {\n        IMAGE_TAG = \"${BUILD_NUMBER}\"\n    }\n    \n    stages {\n        \n        stage('Checkout'){\n           steps {\n                git credentialsId: 'f87a34a8-0e09-45e7-b9cf-6dc68feac670', \n                url: 'https://github.com/iam-veeramalla/cicd-end-to-end',\n                branch: 'main'\n           }\n        }\n\n        stage('Build Docker'){\n            steps{\n                script{\n                    sh '''\n                    echo 'Buid Docker Image'\n                    docker build -t abhishekf5/cicd-e2e:${BUILD_NUMBER} .\n                    '''\n                }\n            }\n        }\n\n        stage('Push the artifacts'){\n           steps{\n                script{\n                    sh '''\n                    echo 'Push to Repo'\n                    docker push abhishekf5/cicd-e2e:${BUILD_NUMBER}\n                    '''\n                }\n            }\n        }\n        \n        stage('Checkout K8S manifest SCM'){\n            steps {\n                git credentialsId: 'f87a34a8-0e09-45e7-b9cf-6dc68feac670', \n                url: 'https://github.com/iam-veeramalla/cicd-demo-manifests-repo.git',\n                branch: 'main'\n            }\n        }\n        \n        stage('Update K8S manifest & push to Repo'){\n            steps {\n                script{\n                    withCredentials([usernamePassword(credentialsId: 'f87a34a8-0e09-45e7-b9cf-6dc68feac670', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {\n                        sh '''\n                        cat deploy.yaml\n                        sed -i '' \"s/32/${BUILD_NUMBER}/g\" deploy.yaml\n                        cat deploy.yaml\n                        git add deploy.yaml\n                        git commit -m 'Updated the deploy yaml | Jenkins Pipeline'\n                        git remote -v\n                        git push https://github.com/iam-veeramalla/cicd-demo-manifests-repo.git HEAD:main\n                        '''                        \n                    }\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/README.md",
    "content": "# django-todo\nA simple todo app built with django\n\n![todo App](https://raw.githubusercontent.com/shreys7/django-todo/develop/staticfiles/todoApp.png)\n\n## CICD Architecture [GitHub -> Jenkins -> k8s Manifests -> Argo CD -> k8s cluster]\n\n![Screenshot 2023-02-01 at 2 48 06 PM](https://user-images.githubusercontent.com/43399466/216001659-74024e94-2c3c-4f1a-8e2e-3ef69b3a88ad.png)\n\n\n\nYou can find the complete details of the setup and configuration in the below video\n\nhttps://www.youtube.com/watch?v=ogrx8G8pClQ\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/deploy/deploy.yaml",
    "content": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: todo-app\n  labels:\n    app: nginx\nspec:\n  replicas: 3\n  selector:\n    matchLabels:\n      app: nginx\n  template:\n    metadata:\n      labels:\n        app: nginx\n    spec:\n      containers:\n      - name: todo\n        image: abhishekf5/todo-app:v1\n        ports:\n        - containerPort: 8000\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/deploy/pod.yaml",
    "content": "apiVersion: v1\nkind: Pod\nmetadata:\n  name: todo-app\nspec:\n  containers:\n  - name: todo-app\n    image: abhishekf5/todoapp:v1\n    ports:\n    - containerPort: 8000\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/deploy/service.yaml",
    "content": "apiVersion: v1\nkind: Service\nmetadata:\n  name: todo-service\nspec:\n  type: NodePort\n  selector:\n    app: nginx\n  ports:\n    - protocol: TCP\n      port: 80\n      targetPort: 8000\n      nodePort: 31000\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/docker-compose.yml",
    "content": "version : \"3.3\"\nservices :\n  web :\n     build : .\n     ports :\n         - \"8000:8000\"\n\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/manage.py",
    "content": "#!/usr/bin/env python\n\"\"\"Django's command-line utility for administrative tasks.\"\"\"\nimport os\nimport sys\n\n\ndef main():\n    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todoApp.settings')\n    try:\n        from django.core.management import execute_from_command_line\n    except ImportError as exc:\n        raise ImportError(\n            \"Couldn't import Django. Are you sure it's installed and \"\n            \"available on your PYTHONPATH environment variable? Did you \"\n            \"forget to activate a virtual environment?\"\n        ) from exc\n    execute_from_command_line(sys.argv)\n\n\nif __name__ == '__main__':\n    main()\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/staticfiles/css/style.css",
    "content": ".page-header {\n  margin-top: 30px;\n}\n\n.fa-trash-alt {\n  color: red;\n  float: right;\n  cursor: pointer;\n}\n\n.todo-complete {\n  text-decoration: line-through;\n}\n\n.todo-status-checkbox {\n  cursor: pointer;\n  margin-right: 10px;\n}"
  },
  {
    "path": "python-jenkins-argocd-k8s/todoApp/__init__.py",
    "content": ""
  },
  {
    "path": "python-jenkins-argocd-k8s/todoApp/settings.py",
    "content": "\"\"\"\nDjango settings for todoApp project.\n\nGenerated by 'django-admin startproject' using Django 2.2.7.\n\nFor more information on this file, see\nhttps://docs.djangoproject.com/en/2.2/topics/settings/\n\nFor the full list of settings and their values, see\nhttps://docs.djangoproject.com/en/2.2/ref/settings/\n\"\"\"\n\nimport os\n\n# Build paths inside the project like this: os.path.join(BASE_DIR, ...)\nBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n\n\n# Quick-start development settings - unsuitable for production\n# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/\n\n# SECURITY WARNING: keep the secret key used in production secret!\nSECRET_KEY = '8)810zj@#^2xp=1=2rkozbv8#)gub6m1a^9qf&)d-9&x9*c2a_'\n\n# SECURITY WARNING: don't run with debug turned on in production!\nDEBUG = True\n\nALLOWED_HOSTS = ['*']\n\n\n# Application definition\n\nINSTALLED_APPS = [\n    'todos.apps.TodosConfig',\n    'django.contrib.admin',\n    'django.contrib.auth',\n    'django.contrib.contenttypes',\n    'django.contrib.sessions',\n    'django.contrib.messages',\n    'django.contrib.staticfiles',\n]\n\nMIDDLEWARE = [\n    'django.middleware.security.SecurityMiddleware',\n    'django.contrib.sessions.middleware.SessionMiddleware',\n    'django.middleware.common.CommonMiddleware',\n    'django.middleware.csrf.CsrfViewMiddleware',\n    'django.contrib.auth.middleware.AuthenticationMiddleware',\n    'django.contrib.messages.middleware.MessageMiddleware',\n    'django.middleware.clickjacking.XFrameOptionsMiddleware',\n]\n\nROOT_URLCONF = 'todoApp.urls'\n\nTEMPLATES = [\n    {\n        'BACKEND': 'django.template.backends.django.DjangoTemplates',\n        'DIRS': [],\n        'APP_DIRS': True,\n        'OPTIONS': {\n            'context_processors': [\n                'django.template.context_processors.debug',\n                'django.template.context_processors.request',\n                'django.contrib.auth.context_processors.auth',\n                'django.contrib.messages.context_processors.messages',\n            ],\n        },\n    },\n]\n\nWSGI_APPLICATION = 'todoApp.wsgi.application'\n\n\n# Database\n# https://docs.djangoproject.com/en/2.2/ref/settings/#databases\n\nDATABASES = {\n    'default': {\n        'ENGINE': 'django.db.backends.sqlite3',\n        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),\n    }\n}\n\n\n# Password validation\n# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators\n\nAUTH_PASSWORD_VALIDATORS = [\n    {\n        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',\n    },\n]\n\n\n# Internationalization\n# https://docs.djangoproject.com/en/2.2/topics/i18n/\n\nLANGUAGE_CODE = 'en-us'\n\nTIME_ZONE = 'Asia/Dhaka'\n\nUSE_I18N = True\n\nUSE_L10N = True\n\nUSE_TZ = True\n\n\n# Static files (CSS, JavaScript, Images)\n# https://docs.djangoproject.com/en/2.2/howto/static-files/\n\nMEDIA_ROOT = os.path.join(BASE_DIR, 'media')\nMEDIA_URL = '/media/'\n\nSTATIC_ROOT = os.path.join(BASE_DIR, 'static')\nSTATIC_URL = '/static/'\n\nSTATICFILES_DIRS = (\n    os.path.join(BASE_DIR, 'staticfiles'),\n)\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/todoApp/urls.py",
    "content": "\"\"\"todoApp URL Configuration\n\nThe `urlpatterns` list routes URLs to views. For more information please see:\n    https://docs.djangoproject.com/en/2.2/topics/http/urls/\nExamples:\nFunction views\n    1. Add an import:  from my_app import views\n    2. Add a URL to urlpatterns:  path('', views.home, name='home')\nClass-based views\n    1. Add an import:  from other_app.views import Home\n    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')\nIncluding another URLconf\n    1. Import the include() function: from django.urls import include, path\n    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))\n\"\"\"\nfrom django.contrib import admin\nfrom django.urls import path, include\nfrom django.conf.urls.static import static\nfrom django.contrib.staticfiles.urls import staticfiles_urlpatterns\nfrom . import settings, views\n\nurlpatterns = [\n    path('todos/', include('todos.urls')),\n    path('admin/', admin.site.urls),\n    path('', views.index)\n] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)\nurlpatterns += staticfiles_urlpatterns()\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/todoApp/views.py",
    "content": "from django.shortcuts import redirect\n\ndef index(request):\n    return redirect('/todos')"
  },
  {
    "path": "python-jenkins-argocd-k8s/todoApp/wsgi.py",
    "content": "\"\"\"\nWSGI config for todoApp project.\n\nIt exposes the WSGI callable as a module-level variable named ``application``.\n\nFor more information on this file, see\nhttps://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/\n\"\"\"\n\nimport os\n\nfrom django.core.wsgi import get_wsgi_application\n\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todoApp.settings')\n\napplication = get_wsgi_application()\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/__init__.py",
    "content": ""
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/admin.py",
    "content": "from django.contrib import admin\nfrom .models import Todo\n\nadmin.site.register(Todo)\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/apps.py",
    "content": "from django.apps import AppConfig\n\n\nclass TodosConfig(AppConfig):\n    name = 'todos'\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/migrations/0001_initial.py",
    "content": "# Generated by Django 2.2.7 on 2019-12-01 17:46\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n    initial = True\n\n    dependencies = [\n    ]\n\n    operations = [\n        migrations.CreateModel(\n            name='Todo',\n            fields=[\n                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),\n                ('name', models.CharField(max_length=100)),\n                ('created_date', models.DateField(verbose_name='Created')),\n                ('deadline', models.DateField(verbose_name='Deadline')),\n                ('description', models.CharField(max_length=200)),\n            ],\n        ),\n    ]\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/migrations/0002_auto_20191201_2357.py",
    "content": "# Generated by Django 2.2.7 on 2019-12-01 18:27\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n    dependencies = [\n        ('todos', '0001_initial'),\n    ]\n\n    operations = [\n        migrations.AlterField(\n            model_name='todo',\n            name='created_date',\n            field=models.DateTimeField(verbose_name='Created'),\n        ),\n        migrations.AlterField(\n            model_name='todo',\n            name='deadline',\n            field=models.DateTimeField(verbose_name='Deadline'),\n        ),\n    ]\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/migrations/0003_auto_20191202_0000.py",
    "content": "# Generated by Django 2.2.7 on 2019-12-01 18:30\n\nfrom django.db import migrations, models\nimport django.utils.timezone\n\n\nclass Migration(migrations.Migration):\n\n    dependencies = [\n        ('todos', '0002_auto_20191201_2357'),\n    ]\n\n    operations = [\n        migrations.RemoveField(\n            model_name='todo',\n            name='created_date',\n        ),\n        migrations.AddField(\n            model_name='todo',\n            name='created_at',\n            field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now, verbose_name='Created'),\n            preserve_default=False,\n        ),\n        migrations.AddField(\n            model_name='todo',\n            name='update_at',\n            field=models.DateTimeField(auto_now=True, verbose_name='Updated'),\n        ),\n    ]\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/migrations/0004_auto_20191202_0004.py",
    "content": "# Generated by Django 2.2.7 on 2019-12-01 18:34\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n    dependencies = [\n        ('todos', '0003_auto_20191202_0000'),\n    ]\n\n    operations = [\n        migrations.AlterField(\n            model_name='todo',\n            name='deadline',\n            field=models.DateTimeField(blank=True, verbose_name='Deadline'),\n        ),\n    ]\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/migrations/0005_auto_20191202_0011.py",
    "content": "# Generated by Django 2.2.7 on 2019-12-01 18:41\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n    dependencies = [\n        ('todos', '0004_auto_20191202_0004'),\n    ]\n\n    operations = [\n        migrations.AlterField(\n            model_name='todo',\n            name='deadline',\n            field=models.DateTimeField(blank=True, null=True, verbose_name='Deadline'),\n        ),\n    ]\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/migrations/0006_remove_todo_deadline.py",
    "content": "# Generated by Django 2.2.7 on 2019-12-01 20:59\n\nfrom django.db import migrations\n\n\nclass Migration(migrations.Migration):\n\n    dependencies = [\n        ('todos', '0005_auto_20191202_0011'),\n    ]\n\n    operations = [\n        migrations.RemoveField(\n            model_name='todo',\n            name='deadline',\n        ),\n    ]\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/migrations/0007_auto_20191202_0323.py",
    "content": "# Generated by Django 2.2.7 on 2019-12-01 21:53\n\nfrom django.db import migrations\n\n\nclass Migration(migrations.Migration):\n\n    dependencies = [\n        ('todos', '0006_remove_todo_deadline'),\n    ]\n\n    operations = [\n        migrations.RenameField(\n            model_name='todo',\n            old_name='name',\n            new_name='title',\n        ),\n    ]\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/migrations/0008_auto_20191202_0809.py",
    "content": "# Generated by Django 2.2.7 on 2019-12-02 02:39\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n    dependencies = [\n        ('todos', '0007_auto_20191202_0323'),\n    ]\n\n    operations = [\n        migrations.RemoveField(\n            model_name='todo',\n            name='description',\n        ),\n        migrations.AddField(\n            model_name='todo',\n            name='isCompleted',\n            field=models.BooleanField(default=False),\n        ),\n    ]\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/migrations/__init__.py",
    "content": ""
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/models.py",
    "content": "from django.db import models\n\nclass Todo(models.Model):\n    title = models.CharField(max_length=100)\n    created_at = models.DateTimeField('Created', auto_now_add=True)\n    update_at = models.DateTimeField('Updated', auto_now=True)\n    isCompleted = models.BooleanField(default=False)\n\n    def __str__(self):\n        return self.title\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/templates/todos/base.html",
    "content": "{% load static %}\n<!doctype html>\n<html lang=\"en\">\n  <head>\n    <!-- Required meta tags -->\n    <meta charset=\"utf-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\n\n    <!-- Bootstrap CSS -->\n    <link rel=\"stylesheet\" href=\"https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css\" integrity=\"sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh\" crossorigin=\"anonymous\">\n    <!--- Our CSS file -->\n    <link rel=\"stylesheet\" href=\"{% static 'css/style.css' %}\">\n\n  {% block title %}\n  {% endblock %}\n  </head>\n  <body>\n    <script src=\"https://code.jquery.com/jquery-3.4.1.slim.min.js\" integrity=\"sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n\" crossorigin=\"anonymous\"></script><script src=\"https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js\" integrity=\"sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo\" crossorigin=\"anonymous\"></script><script src=\"https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js\" integrity=\"sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6\" crossorigin=\"anonymous\"></script> <script src=\"https://kit.fontawesome.com/15974f9624.js\" crossorigin=\"anonymous\"></script>\n    {% block content %}\n    {% endblock %}\n\n  </body>\n</html>"
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/templates/todos/index.html",
    "content": "{% extends 'todos/base.html' %}\n\n{% block title %}\n<title>Todo list</title>\n{% endblock %}\n\n{% block content %}\n<div class=\"container\">\n\n  <!-- title row -->\n  <div class=\"row\">\n    <div class=\"offset-md-2 col-lg-9\">\n      <div class=\"page-header\">\n        <h1>\n          Todo List - Abhishek\n        </h1>\n      </div>\n    </div>\n  </div>\n\n  <!-- Add a todo row -->\n  <div class=\"row\">\n    <div class=\"offset-md-2 col-lg-9\">\n      <form method=\"post\" action=\"{% url 'todos:add' %}\">\n        {% csrf_token %}\n        <div class=\"form-row\">\n          <div class=\"col-md-6\">\n            <input type=\"text\" class=\"form-control\" name=\"title\" placeholder=\"Do laundry\" required>\n          </div>\n          <div class=\"col-md-6\">\n            <button type=\"submit\" name=\"submit\" class=\"btn btn-outline-primary\">\n              Add\n            </button>\n          </div>\n        </div>\n      </form>\n    </div>\n  </div>\n  <hr />\n\n  <!-- todo list row -->\n  <div class=\"row\">\n    <div class=\"offset-md-2 col-lg-6\">\n      <div class=\"list-group\">\n        {% for todo in todo_list %}\n        <div class=\"list-group-item {% if todo.isCompleted %} todo-complete {% endif %}\">\n          <form style=\"display: inline;\" method=\"post\" action=\"{% url 'todos:update' todo.id %}\">\n            {% csrf_token %}\n            <input type=\"checkbox\" name=\"isCompleted\" onchange=\"this.form.submit()\" {% if todo.isCompleted %} checked\n              {% endif %} class=\"todo-status-checkbox\"\n              title=\"{% if not todo.isCompleted %} mark as done {% else %} mark undone {% endif %}\">\n          </form>\n          {{ todo.title }}\n          <a href=\"{% url 'todos:delete' todo.id %}\" title=\"Delete\">\n            <i class=\"far fa-trash-alt\"></i>\n          </a>\n        </div>\n        {% endfor %}\n      </div>\n    </div>\n  </div>\n</div>\n\n{% endblock %}\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/tests.py",
    "content": "from django.test import TestCase\n\n# Create your tests here.\n"
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/urls.py",
    "content": "from django.urls import path\nfrom . import views\n\napp_name='todos'\nurlpatterns = [\n    path('', views.IndexView.as_view(), name='index'),\n    path('<int:todo_id>/delete', views.delete, name='delete'),\n    path('<int:todo_id>/update', views.update, name='update'),\n    path('add/', views.add, name='add')\n]"
  },
  {
    "path": "python-jenkins-argocd-k8s/todos/views.py",
    "content": "from django.shortcuts import render, get_object_or_404, redirect\nfrom django.views import generic\nfrom .models import Todo\nfrom django.http import HttpResponseRedirect\n\nclass IndexView(generic.ListView):\n    template_name = 'todos/index.html'\n    context_object_name = 'todo_list'\n\n    def get_queryset(self):\n        \"\"\"Return all the latest todos.\"\"\"\n        return Todo.objects.order_by('-created_at')\n\ndef add(request):\n    title = request.POST['title']\n    Todo.objects.create(title=title)\n\n    return redirect('todos:index')\n\ndef delete(request, todo_id):\n    todo = get_object_or_404(Todo, pk=todo_id)\n    todo.delete()\n\n    return redirect('todos:index')\n\ndef update(request, todo_id):\n    todo = get_object_or_404(Todo, pk=todo_id)\n    isCompleted = request.POST.get('isCompleted', False)\n    if isCompleted == 'on':\n        isCompleted = True\n    \n    todo.isCompleted = isCompleted\n\n    todo.save()\n    return redirect('todos:index')"
  },
  {
    "path": "shared-libraries/README.md",
    "content": "# Shared Libraries\n\nIn Jenkins, a shared library is a way to store commonly used code(reusable code), such as scripts or functions, that can be used by different \nJenkins pipelines. \n\nInstead of writing the same code again and again in multiple pipelines, you can create a shared library and use it in all the pipelines\nthat need it. This can make your code more organized and easier to maintain. \n\nThink of it like a library of books, Instead of buying the same book over and over again, you can borrow it from the library whenever you need it.\n\n## Advantages\n\n- Standarization of Pipelines\n- Reduce duplication of code\n- Easy onboarding of new applications, projects or teams\n- One place to fix issues with the shared or common code\n- Code Maintainence \n- Reduce the risk of errors\n\n![Screenshot 2023-05-02 at 9 47 24 PM](https://user-images.githubusercontent.com/43399466/235724851-90a5cad6-ac0d-428b-9944-93fffea55180.png)\n"
  },
  {
    "path": "vars/helloWorld.groovy",
    "content": "def call() {\n  sh 'echo Hi From DevOps Team'\n}\n"
  }
]