{"id":48464,"date":"2017-05-30T18:03:48","date_gmt":"2017-05-30T12:33:48","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=48464"},"modified":"2017-05-30T19:18:47","modified_gmt":"2017-05-30T13:48:47","slug":"integrating-and-managing-old-artifacts-through-jenkins","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/integrating-and-managing-old-artifacts-through-jenkins\/","title":{"rendered":"Integrating and Managing Old Artifacts through Jenkins"},"content":{"rendered":"<p style=\"text-align: justify;\">Continuous Integration (CI) and Continuous Deployment (CD) has now become the first and foremost necessity in <a href=\"http:\/\/www.tothenew.com\/blog\/12-agile-principles-we-follow-for-rapid-product-engineering\/\">Agile methodology<\/a>. <span style=\"color: #000000;\">Developer&#8217;s\u00a0<\/span>life has now become much easier as they can now focus on automating other tasks. Managing the artifactory using CI\/CD tools is also important to <a href=\"http:\/\/www.tothenew.com\/blog\/6-tips-for-aws-cost-optimization\/\">optimize storage cost<\/a> for the system. It is observed that the artifacts are managed using storage tools like AWS S3, JFrog artifactory, etc. integrated with CI\/CD tools like Jenkins. These storage options provide an unlimited storage, and one can move forward without worrying about the setup of storage servers. However, the question is, what about managing the old artifacts that are no longer required?<\/p>\n<p style=\"text-align: justify;\">To find out the solution of the above use case, let us understand what an artifactory is and how can we speed up the <a title=\"Deployment Automation\" href=\"http:\/\/www.tothenew.com\/devops-automation-consulting\">deployment process<\/a> using such artifactories with CI\/CD tools?<\/p>\n<p style=\"text-align: justify;\">Artifactories are used to store the artifacts (build packages) onto a storage service. The build artifacts can then be downloaded and deployed to the instances. So for each deployment, the build artifacts will be pushed to the artifactory. The server scripts will then download these artifactories to the respective servers and deploy. It also helps in managing the older artifacts and reverting to them in the case of buggy deployment. Let us first understand, how to integrate an artifactory with Jenkins.<\/p>\n<p style=\"text-align: justify;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-48465 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/Jenkins-Jfrog.jpg\" alt=\"Jenkins-Jfrog\" width=\"571\" height=\"174\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/Jenkins-Jfrog.jpg 571w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Jenkins-Jfrog-300x91.jpg 300w\" sizes=\"(max-width: 571px) 100vw, 571px\" \/><\/p>\n<h2 style=\"text-align: justify;\">Integrating JFrog artifactory with Jenkins<\/h2>\n<div style=\"text-align: justify;\">\u00a0The following is the process to integrate the artifactory with Jenkins:<\/div>\n<div style=\"text-align: justify;\"><\/div>\n<ul style=\"text-align: justify;\">\n<li>Go to the Jenkins console and navigate to <strong>Manage Jenkins<\/strong>. We will be installing the plugin to integrate JFrog artifactory.<\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-48674 \" src=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-12.51.36-PM.png\" alt=\"Screen Shot 2017-05-19 at 12.51.36 PM\" width=\"560\" height=\"293\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-12.51.36-PM.png 1706w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-12.51.36-PM-300x156.png 300w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-12.51.36-PM-1024x535.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-12.51.36-PM-624x326.png 624w\" sizes=\"(max-width: 560px) 100vw, 560px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li>Click on\u00a0<strong>Manage Plugins. <\/strong>It will open up the console to integrate new plugins.<\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-48676 \" src=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-12.55.35-PM-1024x278.png\" alt=\"Screen Shot 2017-05-19 at 12.55.35 PM\" width=\"570\" height=\"155\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-12.55.35-PM-1024x278.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-12.55.35-PM-300x81.png 300w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-12.55.35-PM-624x169.png 624w\" sizes=\"(max-width: 570px) 100vw, 570px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li>Go to Available tab and search for Artifactory Plugin. Install the plugin and wait for the Jenkins to restart.<\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-48677 \" src=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-12.55.11-PM-1024x256.png\" alt=\"Screen Shot 2017-05-19 at 12.55.11 PM\" width=\"569\" height=\"142\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-12.55.11-PM-1024x256.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-12.55.11-PM-300x75.png 300w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-12.55.11-PM-624x156.png 624w\" sizes=\"(max-width: 569px) 100vw, 569px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li>After the Jenkins restarts, create a new Jenkins job or configure the existing job. You will start getting options for artifactory in the configuration. Before configuring the Jenkins job, the configuration should be done globally from <strong>Manage Jenkins<\/strong>\u00a0<strong>-&gt; Configure System.<\/strong><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-48680 \" src=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-2.53.25-PM.png\" alt=\"Screen Shot 2017-05-19 at 2.53.25 PM\" width=\"566\" height=\"230\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-2.53.25-PM.png 1610w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-2.53.25-PM-300x121.png 300w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-2.53.25-PM-1024x415.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-19-at-2.53.25-PM-624x253.png 624w\" sizes=\"(max-width: 566px) 100vw, 566px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li>After configuring the Jenkins global settings, the Job can be configured. Under\u00a0build configuration, choose\u00a0<strong>Generic-Artifactory Integration.\u00a0<\/strong>Configure the Job as shown below:<\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-48681 \" src=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/jenkins_conf-1024x563.jpg\" alt=\"jenkins_conf\" width=\"563\" height=\"310\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/jenkins_conf-1024x563.jpg 1024w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/jenkins_conf-300x165.jpg 300w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/jenkins_conf-624x343.jpg 624w\" sizes=\"(max-width: 563px) 100vw, 563px\" \/><\/p>\n<p style=\"text-align: justify;\">The artifacts will then get saved to the artifactory, and it can easily be managed from the JFrog repository.<\/p>\n<p style=\"text-align: justify;\">Now consider a use case, where you are building a war file using Jenkins and then publishing it to the JFrog artifactory. The job builds a war file of around 100 MB\u00a0on every\u00a0commit. There are around 20 commits per day which lead to around 2 GB of storage cost. After the deployment of the war file, the older artifacts are no longer needed. It can be said\u00a0that if 20th commit to the build is being deployed to the environment, we would no longer need the build of 1st to 15th commit.<\/p>\n<p style=\"text-align: justify;\">We can delete the build artifacts created for these commits and optimize the cost to a much greater extent. We must pay for the required memory storage. For instance, if we need a lesser storage space like 500 MB then there is no point of purchasing 2GB storage. It has been observed that the older artifacts are managed using some automation scripts. The unwanted artifacts are deleted using some cron scripts and some command line interfaces. It also increases the overheads of monitoring these cron scripts. If these scripts fail, then it will increase\u00a0the storage cost, and a complete tested mechanism needs to be implemented to delete the artifacts. Another issue with JFrog artifactory is that, on deleting particular folders using CLI, it deletes the files but leaves the folders empty. This way, it becomes difficult to identify the folders whose files have been deleted. To solve this\u00a0issue, various integrations are available in JFrog but may not be suitable for the team who is not interested in installing extra integrations.<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-size: 1rem;\">Jenkins provides an option to manage the older artifacts. It provides an integration wherein you can use the\u00a0<\/span><strong style=\"font-size: 1rem;\">Discard Old Build Plugin<\/strong><span style=\"font-size: 1rem;\"> to manage the artifacts in the artifactory. This plugin is used to manage the builds of a Jenkins job. One can decide the number of build data of a job to be stored. For example, it can be defined to store last 5 build information to the Jenkins Job. The more information about the plugin can be obtained from this link <\/span><a style=\"font-size: 1rem;\" href=\"https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/Discard+Old+Build+plugin\">https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/Discard+Old+Build+plugin<\/a><\/p>\n<p style=\"text-align: justify;\">This plugin functionality can be extended to manage the artifacts. For example, after installing the plugin, you will get the option as shown below to manage the build data of your Jenkins job:<\/p>\n<p style=\"text-align: justify;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-48469 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-17-at-10.20.04-AM.png\" alt=\"Discard old builds\" width=\"1342\" height=\"184\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-17-at-10.20.04-AM.png 1342w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-17-at-10.20.04-AM-300x41.png 300w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-17-at-10.20.04-AM-1024x140.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-17-at-10.20.04-AM-624x85.png 624w\" sizes=\"(max-width: 1342px) 100vw, 1342px\" \/><\/p>\n<p style=\"text-align: justify;\">One can handle the build data depending upon the last number of builds or number of days. \u00a0The job can be configured as shown below:<\/p>\n<p style=\"text-align: justify;\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-48470 \" src=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-17-at-11.10.42-AM.png\" alt=\"Discard old artifacts Jenkins\" width=\"614\" height=\"291\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-17-at-11.10.42-AM.png 1676w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-17-at-11.10.42-AM-300x142.png 300w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-17-at-11.10.42-AM-1024x485.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-17-at-11.10.42-AM-624x295.png 624w\" sizes=\"(max-width: 614px) 100vw, 614px\" \/><\/p>\n<p style=\"text-align: justify;\">One can define the\u00a0days to keep the builds, a maximum number of builds to keep, days to keep artifacts or the max number of builds to keep with artifacts. All options are self-explanatory.<\/p>\n<p style=\"text-align: justify;\">After defining the above options, it is also desired to manage the artifacts generated through the execution of Jenkins job. This can be managed through the Artifactory configuration as shown below:<\/p>\n<p style=\"text-align: justify;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-48471 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-17-at-10.20.33-AM.png\" alt=\"Screen Shot 2017-05-17 at 10.20.33 AM\" width=\"1392\" height=\"186\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-17-at-10.20.33-AM.png 1392w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-17-at-10.20.33-AM-300x40.png 300w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-17-at-10.20.33-AM-1024x136.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/Screen-Shot-2017-05-17-at-10.20.33-AM-624x83.png 624w\" sizes=\"(max-width: 1392px) 100vw, 1392px\" \/><\/p>\n<p style=\"text-align: justify;\">After configuring these options, builds and artifacts will be managed accordingly. There is no need to install the artifactory CLI and setting up automation scripts to manage the older artifacts and job details.<\/p>\n<p style=\"text-align: justify;\">Hope this blog will help you integrate and manage old artifacts through Jenkins in a faster and better way.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Continuous Integration (CI) and Continuous Deployment (CD) has now become the first and foremost necessity in Agile methodology. Developer&#8217;s\u00a0life has now become much easier as they can now focus on automating other tasks. Managing the artifactory using CI\/CD tools is also important to optimize storage cost for the system. It is observed that the artifacts [&hellip;]<\/p>\n","protected":false},"author":163,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":20},"categories":[1993,2348,1],"tags":[4574,4573,248,4252,1892,1682,4582,65,590],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/48464"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/163"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=48464"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/48464\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=48464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=48464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=48464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}