
การ Build .net core บน Jenkins นั้น อาจจะแตกต่างกับ build java project อยู่บ้าง แต่ถ้าทำตามขั้นตอนด้านล่างนี้แล้ว รับรองว่าทำได้แน่นอน

เตรียม .net core sdk
ติดตั้ง .net core sdk บนเครื่อง Jenkins Server https://dotnet.microsoft.com/download
หลังจากนั้นให้ restart เครื่องเพื่อให้ Jenkins เข้าถึง .net core sdk file ที่เพิ่ง install ครับ
Config Pipeline script
- สร้าง Pipeline Job ได้ไปที่ New Item แล้วเลือกประเภทโปรเจคเป็น Pipeline
- Copy ตัวอย่าง Code นี้ไปแปะใน Pipeline Script ได้เลย
pipeline {
agent any
stages {
stage('Build') {
steps {
git 'https://github.com/janit/dotnetcore-hello-world.git'
bat "dotnet restore yello.csproj"
bat "dotnet build"
bat "dotnet publish"
}
post {
success {
archiveArtifacts 'bin/Debug/netcoreapp2.0/publish/'
}
}
}
}
}
อธิบาย Pipeline Code
- bat dotnet restore, build, และ publish
bat เป็นการส่ง command ไปรันผ่าน window bat - archiveArtifacts ‘bin/Debug/netcoreapp2.0/publish/’
จัดเก็บ file ต่างๆที่ได้จากการรันคำสั่ง publish

สนใจเรียนคอร์สออนไลน์เพิ่มเติมด้านล่างเลย

CI & CD ด้วย Jenkins Pipeline
เรียนคอร์ส Jenkins Online ก่อนใคร
จาก 3,000 ลดเหลือ 2,499 บาทเท่านั้น!!!