{"id":4475,"date":"2019-04-27T11:18:35","date_gmt":"2019-04-27T09:18:35","guid":{"rendered":"http:\/\/blog.via-internet.de\/?p=4475"},"modified":"2019-04-27T11:18:35","modified_gmt":"2019-04-27T09:18:35","slug":"setting-up-and-working-with-jenkins","status":"publish","type":"post","link":"https:\/\/via-internet.de\/blog\/2019\/04\/27\/setting-up-and-working-with-jenkins\/","title":{"rendered":"Jenkins | Getting started"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">What is Jenkins. From the Jenkins Homepage, you will get this:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>The leading open source automation server, Jenkins provides hundreds of plugins to support building, deploying and automating any project.<\/p><p>As an extensible automation server, Jenkins can be used as a simple CI server or turned into the continuous delivery hub for any project.<\/p><\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">This blog will describe, how to setup jenkins and build an environment where we can build and test a simple python app: a <a href=\"https:\/\/github.com\/python-toolbox\/SampleApp-for-Jenkins\">calculator<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Setup Jenkins<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Jenkins is a java application. So, to run jenkins, we need to things:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>a java development kit<\/li><li>a jenkins war file<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Following the requiements rom the jenkins home page, we should use java8 to run jenkins.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To check your java version, open a console an run<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">java -version\nopenjdk version \"1.8.0_242\"\nOpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)\nOpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you need to install the right java version, get it from <a href=\"https:\/\/adoptopenjdk.net\/\">here<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Download WAR<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Next, we need Jenkins. Download the Jenkins <a href=\"https:\/\/jenkins.io\/download\/\">here<\/a>. We will use the weekly generic java package (.war)<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">wget http:\/\/mirrors.jenkins.io\/war\/latest\/jenkins.war<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Create Project Home<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We want to keep jenkins and all related files and services in one place.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, lets create the folder jenkins whereever you want.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First create main folder (we will rever to this as JENKINS_ROOT)<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mkdir \/home\/jenkins<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Next, we create the folder JENKINS_HOME. This will the the home directory for the jenkins serice.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mkdir \/users\/jenkins\/home<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Remember this folders<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">export JENKINS_ROOT=\/home\/jenkins\nexport JENKINS_OME=$JENKINS_ROOT\/home<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Start Jenkins <\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">java -jar jenkins.war &#8211;enable-future-java<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Starting Jenkins this way, you will see all log messages on the console.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At this step, the importen messages are the initial admin password:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"10\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">2020-02-28 16:50:00.749+0000 [id=32]\tINFO\tjenkins.install.SetupWizard#init:\n\n*************************************************************\n*************************************************************\n*************************************************************\n\nJenkins initial setup is required. An admin user has been created and a password generated.\nPlease use the following password to proceed to installation:\n\n6c408145cc964f72ab45cd80e247fa2d\n\nThis may also be found at: \/home\/jenkins\/home(secrets\/initialAdminPassword\n\n*************************************************************\n*************************************************************\n*************************************************************\n\n2020-02-28 16:50:05.848+0000 [id=57]\tINFO\th.m.DownloadService$Downloadable#load: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Start browser and install plugins, create user<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ chrome localhost:\/\/8080<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Shell access to Jenkins docker<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ docker exec -it jenkins-tutorials bash<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Create a Pipeline for a simple Maven Project<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\">Clone the sample maven app<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">git clone https:\/\/github.com\/jenkins-docs\/simple-java-maven-app<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you want to create a new maven app, you could start with the following command<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mvn archetype:generate\n        -DgroupId=com.jcg.maven \n        -DartifactId=HelloWorld \n        -DarchetypeArtifactId=maven-archetype-quickstart \n        -DinteractiveMode=false\n\ncd HelloWorld<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Install and Build package<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mvm clean install<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">mvn package<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Run your app<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">java -cp target\/MavenHelloWorldProject-1.0-SNAPSHOT.jar  com.jcg.maven.App<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">No such DSL method &#8216;withMaven&#8217; found among steps<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This means you don&#8217;t have&nbsp;<code>withMaven<\/code>&nbsp;as an available DSL method. Most of the time this means you don&#8217;t have a plugin installed. In this case, the Pipeline Maven Plugin is required.&nbsp;<a href=\"https:\/\/wiki.jenkins.io\/display\/JENKINS\/Pipeline+Maven+Plugin\">https:\/\/wiki.jenkins.io\/display\/JENKINS\/Pipeline+Maven+Plugin<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Links<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/dzone.com\/articles\/local-continuous-delivery-environment-with-docker\">Local Continuous Delivery Environment With Docker and Jenkins<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Additional Readings<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Using Oracle Java or <a href=\"http:\/\/openjdk.java.net\/install\/index.html\">OpenJDK<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install Java on Mac OS with Homebrew<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ brew tap AdoptOpenJDK\/openjdk<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">brew cask install adoptopenjdk8<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install Jenkins with Homebrew on Mac OS<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">brew install jenkins-lts\nbrew services start jenkins-lts<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install Jenkins with Docker<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ docker run --rm -u root -p 8080:8080  -p 50000:50000 \n  -v jenkins-data:\/var\/jenkins_home \n  -v \/var\/run\/docker.sock:\/var\/run\/docker.sock \n  -v \"$HOME\":\/home \n  jenkinsci\/blueocean<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Introduction What is Jenkins. From the Jenkins Homepage, you will get this: The leading open source automation server, Jenkins provides hundreds of plugins to support building, deploying and automating any project. As an extensible automation server, Jenkins can be used as a simple CI server or turned into the continuous delivery hub for any project. This blog will describe, how to setup jenkins and build an environment where we can build and test a simple python app: a calculator. Setup Jenkins Jenkins is a java application. So, to run jenkins, we need to things: a java development kit a jenkins war [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6126,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[13,40],"tags":[],"class_list":["post-4475","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ci-cd","category-jenkins"],"jetpack_featured_media_url":"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2019\/04\/00_blog_header_jenkins.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts\/4475","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/comments?post=4475"}],"version-history":[{"count":0,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts\/4475\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/media\/6126"}],"wp:attachment":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/media?parent=4475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/categories?post=4475"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/tags?post=4475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}