Skip to main content

Jenkins [DSP2017 #06]


In this entry I want to introduce tool which should be used in each projects. It covers how to install and configure a simple job.


First of all I started from installation of jenkins in my local machine (Ubuntu). You can download installation package from official page or use jenkins wiki. As like always I met some problem:
 The following packages have unmet dependencies:
 jenkins : Depends: daemon but it is not installed


As a resolving of it I used command apt-get -f install and next apt-get upgrade.

Then we should be able see the page like below on address http://localhost:8080





After unlock and installation some pluggins we should be able to see something like below.






Next I added simple job which will check the repository and run command gradle -p nany-server test. The result is on an image below.

I think that few of us met with lost jobs definitions. What then? We need to define each job manually again. From my point of view the better option is to keep configurations of job as a file on version control. I think that one option can be Jenkins job DSL.


So lets do the same think with DSL. Our current job just check-out code and run command gradle -p nany-server test. The same job can be defined by script like here:






job('DSP-Nany') {
  scm {
    git {
      remote {
      github('SebJak/nanny_dsp')
      credentials('github_sjak')
      }
    }
  }

  triggers {
   scm('H/15 * * * *')
  }
  steps {
   gradle{
     useWrapper(false)
     gradleName('Gradle 3.5')
     tasks('test')
     switches('-p nany-server')}
   }
 }

We can put this code in our repository like here and define a job where this script file will be taken and run for define DSP-Nany job.

After run a defined job probably your receive error:



 
Processing DSL script dspNanyDSL.groovy
ERROR: script not yet approved for use
Finished: FAILURE

The solution of it is to approve the script in Manage Jenkins -> In-process Script Approval. Next build should work and the result should be a new job named DSP-Nany.



Thanks for reading :)

Comments

Popular posts from this blog

How to start with Android development [DSP2017 #07]

In this part I want to show how I started with a first app. My previous experience with creating an Android application was about 4-5 years ago. I've created one or two simple applications during my studies and forgot about this topic. Today when I wanted to create a new app I needed to start from beginning. First of all I need to install tools: Android Studio (I use Intellij with Android extension). Android SDK - I used the sdkmanager but during Android Studio installation sdk should be installed. If you have 64 bits system you need to check: Required libraries for 64-bit machines . If you have installed all above tools you should be able to create simple Android project and run it on your phone. Yes, like always I met few problems with run the application on my phone. #1 The adb can not find my device. Solution : turn phone as MTP mode. 2# Error:Execution failed for task ':app:processDebugResources'. > com.android.ide.common.process.ProcessException:...

Nany - opis projektu [DSP2017 #03]

" Nany " Wymagania: Użytkownik może podłączyć/odłączyć się do detektora wysyłającego powiadomienia. Użytkownik musi zostać poinformowany o dochodzącym dźwięku z pokoju dziecka. Powiadomienia powinny zostać wysłane do wszystkich zarejestrowanych urządzeń. Użytkownik musi zareagować na powiadomienie. Schemat:   Pierwszy etap prac (13.03.2017): [Telefon*] Prosta aplikacja android umożliwiająca odbieranie powiadomień. [Detektor*] Obsługa detekcji dźwięku. *Telefon - urządzenie z systemem android. *Detektor - Raspberry Pi B  wraz z mikrofonem.

Rest API desing [DSP2017 #02]

Rest API best practices During creating an http api we should remember about few rules. As a API designers we must know how to name our endpoints. When we have a library which contains users and their books. As a collection we should use a plural form of verb like books and users. Below we can find examples of endpoints for certain activity and strict HTTP methods Add new book: /users/{userId}/books/{bookId} POST Get book: /users/{userId}/books/{bookId} GET Edit book: /users/{userId}/books/{bookId} PUT Remove book: /users/{userId}/books/{bookId} DELETE   Status codes 200 OK 201 Created 202 Accepted - request has been accepted but not completed. 204 Non content - the request is correct but no content in response body. 400 Bad request 401 Unauthorized 403 Forbidden 404 Not found 408 Request time out 409 - Conflict - duplicate data or invalid data state would occur. 500 Internal server error 501 Not implemented 503 Service unavailable    I th...