Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions Jenkinsfile-build
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pipeline {
// 빌드를 5개만 유지
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '5', numToKeepStr: '5')
// github 프로젝트 설정
githubProjectProperty(displayName: '', projectUrlStr: 'https://github.com/fastcampus-jenkins/fastcampus-jenkins')
githubProjectProperty(displayName: '', projectUrlStr: 'https://github.com/seongtaemin/fastcampus-jenkins')
}


Expand Down Expand Up @@ -56,7 +56,7 @@ pipeline {
}
}
}


stage('Build') {
steps {
Expand All @@ -70,7 +70,6 @@ pipeline {
}
}


stage('SonarScanner') {
when {
environment name: "GIT_BRANCH", value: "origin/main"
Expand Down Expand Up @@ -104,9 +103,8 @@ pipeline {
junit '**/test-results/**/*.xml'
jacoco sourcePattern: '**/src/main/kotlin'
mineRepository()
emailext attachLog: true, body: email_content(), subject: email_subject(), to: 'junoyoon@gmail.com'
emailext attachLog: true, body: email_content(), subject: email_subject(), to: 'taemni.seong@gmail.com'
slackSend channel: "#jenkins", message: "${custom_msg(currentBuild.currentResult)}"

}

success {
Expand Down Expand Up @@ -150,4 +148,3 @@ def groovy_script() {
return "$BRANCH 가 빌드 됩니다."
}'''
}

16 changes: 8 additions & 8 deletions Jenkinsfile-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ pipeline {

// stages > stage > steps 순으로 구성
stages {
stage("Checking Deployment") {
when {
environment name: 'ARE_YOU_SURE', value: 'false'
}
steps {
error('Executed mistakenly.')
}
}
stage("Checking Deployment") {
when {
environment name: 'ARE_YOU_SURE', value: 'false'
}
steps {
error('Executed mistakenly.')
}
}

stage('Copying from upstream.') {
steps {
Expand Down
94 changes: 43 additions & 51 deletions Jenkinsfile-pr
Original file line number Diff line number Diff line change
@@ -1,67 +1,59 @@
pipeline {
// 어떠한 에이전트에서도 실행 가능함을 표현
agent any



options {
// 빌드를 5개만 유지
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '5', numToKeepStr: '5')
// github 프로젝트 설정
githubProjectProperty(displayName: '', projectUrlStr: 'https://github.com/fastcampus-jenkins/fastcampus-jenkins')
buildDiscarder logRotator(
artifactDaysToKeepStr: '',
artifactNumToKeepStr: '',
daysToKeepStr: '5',
numToKeepStr: '5'
)
githubProjectProperty(
displayName: '',
projectUrlStr: 'https://github.com/seongtaemin/fastcampus-jenkins'
)
}


// stages > stage > steps 순으로 구성
stages {
stage('Prepare') {
steps {
// 어떤 환경변수가 주입되는지 확인
sh "printenv"
script {

properties([
// https://www.jenkins.io/doc/pipeline/steps/params/pipelinetriggers/
pipelineTriggers([
// PR builder trigger
pipelineTriggers([
[
$class : 'GhprbTrigger',
adminlist : 'seongtaemin',
cron : "*/15 * * * *",
permitAll : false,
useGitHubHooks: true,
triggerPhrase : '.*(test this|build this|deploy this).*',
gitHubAuthId : 'ed41fbed-bd5b-48dc-bd22-ac30bb535b1e',
extensions : [
[
$class : 'GhprbTrigger',
adminlist : 'junoyoon',
cron: "*/15 * * * *",
permitAll : false,
useGitHubHooks: true,
triggerPhrase : '.*(test this|build this|deploy this).*',
gitHubAuthId : '0e0e7b1f-09c0-4380-bf6c-c07409bd9f99', // Jenkins 설정 > System > GitHub Pull Request Builder > Auth ID 에서 확인 가능
extensions : [
[
$class : 'GhprbSimpleStatus',
commitStatusContext: 'jenkins',
showMatrixStatus : false
]
]
$class : 'GhprbSimpleStatus',
commitStatusContext: 'jenkins',
showMatrixStatus : false
]
])
])
]
]
])
])
}
}
}


stage('Build') {
steps {
// dir 은 디렉토리 이동
dir("projects/spring-app") {
// withGradle 을 하면, Gradle 로그를 해석
withGradle {
sh "./gradlew build"
}
}
dir("projects/spring-app") {
withGradle {
sh "./gradlew build"
}
}
}
}

}

// post 는 stage 마다 실행시킬 수도 있고, 전체 stages가 완료된 다음에 실행 시킬 수도 있음
post {
always {
scanForIssues tool: ktLint(pattern: '**/ktlint/**/*.xml')
Expand All @@ -71,17 +63,17 @@ pipeline {

success {
script {
script {
if ((env.ghprbCommentBody ?: "").contains("deploy this")) {
archiveArtifacts artifacts: 'projects/spring-app/build/libs/*-SNAPSHOT.jar'
build(
job: 'pipeline-deploy',
parameters: [booleanParam(name: 'ARE_YOU_SURE', value: "true")],
wait: false,
propagate: false
)
}
}
if ((env.ghprbCommentBody ?: "").contains("deploy this")) {
archiveArtifacts artifacts: 'projects/spring-app/build/libs/*-SNAPSHOT.jar'
build(
job: 'pipeline-deploy',
parameters: [
booleanParam(name: 'ARE_YOU_SURE', value: true)
],
wait: false,
propagate: false
)
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# fastcampus-jenkins
# fastcampus-jenkins