---
# System prepended metadata

title: Jenkins training
tags: [CICD]

---

---
tags: CICD
---
# Jenkins training

## Jenkins installation

[Download Jenkins](https://www.jenkins.io/download/)

**更換安裝路徑** ​
* 移除目前的Jenkins以避免覆蓋 `sc delete jenkins`​
* Copy C:\ProgramData\Jenkins\.jenkins d:\Jenkins​
* Jenkins.xml 、Config.xml => 修改安裝路徑 (
`sc create jenkins binpath= "d:\jenkins\jenkins.exe"`​

**Install plugins** ​
* Keyboard Shortcuts => 熱鍵​
* categorized-view => Job分類​
* Stage view => 執行job的Stage分隔​
* Log Parser => 錯誤訊息判斷​
* Role-based Authorization Strategy =>登入者權限​
* Active directory => AD登入​
* ThinBackup => Jenkins 備份​
* Extended Choice Parameter => Task checkbox套件​
* Pipeline Utility Steps => groovy跑readJSON file的套件

**HotKeys**
![](https://i.imgur.com/8kLH0Gv.jpg)

## Jenkins management console 
**Change home directory**
![](https://i.imgur.com/hf8UArj.jpg)
**Default view**
![](https://i.imgur.com/QUgqfSD.jpg)
**Executors**
![](https://i.imgur.com/6CBW9l7.jpg)
**JenkinsURL**
![](https://i.imgur.com/3JldDwU.jpg)
**Shared Library**
![](https://i.imgur.com/NbTTDgz.jpg)
**Parsing rules**
![](https://i.imgur.com/hMUJptR.jpg)

```
# match line starting with 'error ', case-insensitive
error /(?i)^invalid/
error /(?i)^ierror/
error / [Ee]rror /
error /Access is denied/
error /RETRY LIMIT EXCEEDED/
error /Cannot find any service/
error /cannot be found/
error /Time out has expired/

# list of warnings here...
warning /cannot access the file/
warning /[Ww]arning/
warning /WARNING/
warning /(?i)^Msg/
warning /ERROR [1-9]+/

# create a quick access link to lines in the report containing 'INFO'
info /INFO/

# each line containing 'BUILD' represents the start of a section for grouping errors and warnings found after the line.
# also creates a quick access link.
```
## Jenkins permission control
![](https://i.imgur.com/20mFXUl.jpg)![](https://i.imgur.com/4TYdAL0.jpg)
**Role base permission contorl**
![](https://i.imgur.com/iqrqjfv.jpg)
## Jenkins node
**Find Agent IP**
 `println InetAddress.localHost.canonicalHostName`
 ![](https://i.imgur.com/X5kSFoa.jpg)
