--- tags: CICD --- # CI/CD Basic ## Jenkins Installation [Download Jenkins](https://www.jenkins.io/download/) [安裝參考](https://www.cnblogs.com/dotnet261010/p/11495762.html) **更換安裝路徑** (方便管理,但安全性會下降) * 移除目前的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**  **Setup Basic tools (git msbuild.exe)**  ## Create Jenkins Job **FreeStyle** 1. Create new job  2. Setup git and workspace  3. Build c# project  **Pipeline** [Groovy Formatter](https://codebeautify.org/javaviewer/cbacc095) 1. Create new job  2. Use sample groovy  3. Pipeline Syntax 3.1 Checkout Source  3.2 Nuget restore(PowerShell)  3.3 Build: use msbuild.exe command ``` pipeline { agent any stages { stage('CheckoutSource') { steps { dir('D:\\JenkinsWorkspace\\DemoPipeline') { git credentialsId: 'sshuser', url: 'ssh://git@gitlab.net:8022/monitor.git' } } } stage('restore nuget') { steps { dir('D:\\JenkinsWorkspace\\DemoPipeline') { powershell 'nuget restore' } } } stage('build') { steps { powershell 'msbuild D:\\JenkinsWorkspace\\DemoPipeline\\SupportMonitor.sln' } } } } ``` ## Add Credential Dashboard -> Manage Jenkins -> Credentials click Jenkins -> click Global credentials -> Add Credentials   Add SSH private Key  ## Jenkins management console **Change home directory**  **Default view**  **Executors**  **JenkinsURL**  **Shared Library**  **Parsing rules** 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up