Show Menu

Jenkins Cheat Sheet by

Notizen zum Jenkins
plugins     jenkins     docker     pipeline     konfiguratiion

Entwic­klu­ngs­umg­ebungen

Pipeline Trigger Job

# Build Trigger - Zeitgesteuert
TZ=Europe/Berlin
@midnight

# Pipeline - Definition Pipelinscript

node {
  stage("mypocketmod"){
    try {
      build 'mypocketmod/master'
    } catch (err) {
      echo "Caught: ${err}"
    }
    try {
      build 'rades-annotations'
    } catch (err) {
      echo "Caught: ${err}"
    }
    try {
      build 'localmod'
    } catch (err) {
      echo "Caught: ${err}"
    }
 }
}

Monitoring API

Simple Job
Buildstatus URL: jenkinsurl/job/jobName/lastBuild/api/json
Beispiel: http://stachel:8090/job/rades-annotations/lastBuild/api/json

Multibranch Pipeline Plugin
Buildstatus URL: jenkinsurl/job/repoName/job/BranchName/lastBuild/api/json
Beispiel: http://stachel:8090/job/mypocketmod/job/master/lastBuild/api/json

Im Response sind die wichtigen Felder:
* response.fullDisplayName
* response.result


{
   "_class": "hudson.model.FreeStyleBuild",
   "actions": [
      {
         "_class": "hudson.model.CauseAction",
         "causes": [
            {
               "_class": "hudson.model.Cause$UpstreamCause",
               "shortDescription": "Gestartet durch vorgelagertes Projekt „NighlyTrigger“, Build 6",
               "upstreamBuild": 6,
               "upstreamProject": "NighlyTrigger",
               "upstreamUrl": "job/NighlyTrigger/"
            }
         ]
      },
      {},
      {
         "_class": "hudson.plugins.git.util.BuildData",
         "buildsByBranchName": {
            "refs/remotes/origin/master": {
               "_class": "hudson.plugins.git.util.Build",
               "buildNumber": 6,
               "buildResult": null,
               "marked": {
                  "SHA1": "d68e6e7cbc7155a549e480e7354a6e64493382fa",
                  "branch": [
                     {
                        "SHA1": "d68e6e7cbc7155a549e480e7354a6e64493382fa",
                        "name": "refs/remotes/origin/master"
                     }
                  ]
               },
               "revision": {
                  "SHA1": "d68e6e7cbc7155a549e480e7354a6e64493382fa",
                  "branch": [
                     {
                        "SHA1": "d68e6e7cbc7155a549e480e7354a6e64493382fa",
                        "name": "refs/remotes/origin/master"
                     }
                  ]
               }
            }
         },
         "lastBuiltRevision": {
            "SHA1": "d68e6e7cbc7155a549e480e7354a6e64493382fa",
            "branch": [
               {
                  "SHA1": "d68e6e7cbc7155a549e480e7354a6e64493382fa",
                  "name": "refs/remotes/origin/master"
               }
            ]
         },
         "remoteUrls": [
            "https://github.com/FunThomas424242/rades-annotations.git"
         ],
         "scmName": ""
      },
      {
         "_class": "hudson.plugins.git.GitTagAction"
      },
      {},
      {},
      {}
   ],
   "artifacts": [],
   "building": false,
   "description": null,
   "displayName": "#6",
   "duration": 28582,
   "estimatedDuration": 47475,
   "executor": null,
   "fullDisplayName": "rades-annotations #6",
   "id": "6",
   "keepLog": false,
   "number": 6,
   "queueId": 39,
   "result": "SUCCESS",
   "timestamp": 1568557708973,
   "url": "http://stachel:8090/job/rades-annotations/6/",
   "builtOn": "",
   "changeSet": {
      "_class": "hudson.plugins.git.GitChangeSetList",
      "items": [],
      "kind": "git"
   },
   "culprits": []
}
 

Spiele­jenkins im Internet bereit­stellen

Lässt sich über Docker für max. 3h realis­ieren:

1. Aufruf der Docker­spi­elw­iese: https:­//l­abs.pl­ay-­wit­h-d­ock­er.com
2. Add new Instanz
3. docker pull jenkins
4. docker run -p 8080:8080 -p 50000:­50000 jenkins
5. Ablesen der IP und Ports der Umgebung
6. Öffnen der Jenkin­sseite über den ausgel­esenen 8080 z.B. http:/­/ip­172­-18­-0-­7-b­mh2­hhl­fhn­200­08g­21v­0-8­080.di­rec­t.l­abs.pl­ay-­wit­h-d­ock­er.c­om­/lo­gin­?fr­om=%2F
7. In der Console nach oben scrollen und das Jenkins admin Passwort heraus­kop­ieren. Sieht etwa so aus: fd8736­2a7­651­4aa­997­363­1c9­925­7ecb4
8. Im geöffneten Jenkins anmelden (mit dem Passwort)
Manchmal machte die Instal­lation mit default Plugins Probleme, daher besser erstmal keine zu instal­lieren und dann manuell später nachholen

Jenkins - Monitore

Chrome Extension
Nur auf Jobebene bei aktiver Authen­tif­izi­erung
Natives Binary
Multi Jenkins Support mit Tray aber die Liste öffnet im extra Fenster
========
======
======
Hudson­Tracker
 
Unters­tützt die Jenkins Author­isi­erung nicht
Natives Binary
Benötigt Download

Zeitge­ste­uerte Ausführung

Pipeline mit Jenkin­sfile
pipeline {
agent any
triggers {
cron('H /4 * 1-5')
}
stages {
stage(­'Ex­ample') {
steps {
echo 'Hello World'
}
}
}
}

`

String cron_s­tring = BRANCH­_NAME == "­mas­ter­" ? "­@ho­url­y" : "­"

pipeline {
agent none
triggers { cron(c­ron­_st­ring) }
stages {
// do something
}
}

`

Download the Jenkins Cheat Sheet

3 Pages
//media.cheatography.com/storage/thumb/funthomas424242_jenkins.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Selenium WebDriver Cheat Sheet Cheat Sheet
          Eclipse Cheat Sheet

          More Cheat Sheets by FunThomas424242

          Spring Boot Cheat Sheet
          Praktische Java Libs Cheat Sheet