1/1/2024 0 Comments Git change branch tomcat![]() ![]() You can also integrate your job with sonarqube to check the code quality and code coverage. Now, you can browse your application by using the url and you will see the login page as shown below:Ĭongratulations,you have successfully setup the CI/CD process using Jenkins and Ansible. I have used ssh url because my jenkins is already integrated with github Sh "ansible-playbook main.yml -i inventories/dev/hosts - user jenkins -key-file ~/.ssh/id_rsa" Checkout the code, its not required if you directly take the Jenkinsfile from SCM.Name should match as per your jenkins configuration Configure tool maven and ansible which you have configured in your Jenkins.Now we will write Jenkinsfile to run all the tasks together as mentioned above Service: name=tomcat state=started enabled=yesĪlso,you can check more articles on how to manage ansible playbook/inventories/multiple environments Jenkins Pipeline Path: "/opt/apache-tomcat-7.0.61/webapps/samples"Ĭopy: src=./target/LoginWebApp-1.war dest=/opt/apache-tomcat-7.0.61/webapps/Ĭopy: src=tomcat-initscript.sh dest=/etc/init.d/tomcat mode=0755 Template: src=server.xml dest=/usr/share/tomcat/conf/ name: Change ownership of Tomcat installationįile: path=/usr/share/tomcat/ owner=tomcat group=tomcat state=directory recurse=yes Get_url: url= dest=/opt/apache-tomcat-7.0.61.tar.gzĬommand: chdir=/usr/share /bin/tar xvf /opt/apache-tomcat-7.0.61.tar.gz -C /opt/ creates=/opt/apache-tomcat-7.0.61įile: src=/opt/apache-tomcat-7.0.61 path=/usr/share/tomcat state=link User: name= home=/usr/share/tomcat createhome=no Yum: name=java-1.7.0-openjdk state=present Role to install java, configure tomcat and deploy the war file on the tomcat server - name: Install Java 1.7 I have following folder structure to manage ansible playbook for inventories and the variables as shown below Now we will create main.yml file which will call our roles to install tomcat and java - hosts: all If you will not use this file, then when you run your playbook using jenkins it will fail with the error Host key verification is falied This is required to bypass the hostkey checking while making a ssh connection with the tomcat servers. In the git repo, we have created first ansible.cfg file with the below entries Now, we will write the ansible roles to do all the tasks and configure it to run inside a Jenkins job Ansible Playbook Previously, we used to install tomcat and java manually on the server and then copy the war file under webapps folder and restart the service. Now we have generated the war file and we can deploy it on our tomcat server. Clone the git repo and run the mvn command, this will generate a war file under target folder git clone Compile and package the project using MavenĬreated a pom.xml file to compile and package the project in war file. Create a pipeline job in Jenkins and trigger the buildįirstly, create a sample registration and login page in jsp.Deploy the war file on tomcat server using ansible playbook.Create a role in Ansible to install java and tomcat.Make sure ssh connection is already setup between for jenkins user between two AWS EC2 Instances.Integration between Jenkins and Ansible. ![]() Follow Jenkins Installation article if not already installed.Two AWS EC2 instance ( one is Jenkins Server and another is tomcat server).If you want to see the video for this article, click here Prerequisite: At last,this process will help us in achieving continuous integration and continuous deployment for your application. We will deploy the sample java application using Ansible on the tomcat servers. After following these steps, I was able to switch branches.In this blog, we will explore the CI/CD process using Jenkins and Ansible. The full solution began with git update-index -no-assume-unchanged before proceeding with the steps above. no changes should be shown if you push to the main repo, no changes in are included in the push.copy file in question from safe location back into working tree.in working tree, checkout file so that it matches master branch file To rename a local branch from inside another, use 'git branch -m old-name new-name.' To rename a remote branch, delete it with 'git push origin -delete old-name', then push the renamed local branch with 'git push origin -u new-name.' Branching is a trivial exercise in Git.copy file that has your local-only changes to somewhere safe on the filesystem.However, like some above, I struggled with being able to switch between a ticketed branch and the main branch without git complaining even after I had set the -skip-worktree flag on the file whose changes I wanted to remain local. The solution that worked for me was to use -skip-worktree. I ran into the same thing today, and I found a solution that worked from this page (couldn't figure out who the author was so that I could give credit): ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |