diff --git a/Jenkinsfile-build b/Jenkinsfile-build index f52ed39..ef54283 100644 --- a/Jenkinsfile-build +++ b/Jenkinsfile-build @@ -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') } @@ -56,7 +56,7 @@ pipeline { } } } - + stage('Build') { steps { @@ -70,7 +70,6 @@ pipeline { } } - stage('SonarScanner') { when { environment name: "GIT_BRANCH", value: "origin/main" @@ -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 { @@ -150,4 +148,3 @@ def groovy_script() { return "$BRANCH 가 빌드 됩니다." }''' } - diff --git a/Jenkinsfile-deploy b/Jenkinsfile-deploy index 3406586..96d2dad 100644 --- a/Jenkinsfile-deploy +++ b/Jenkinsfile-deploy @@ -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 { diff --git a/Jenkinsfile-pr b/Jenkinsfile-pr index d142f9c..f867fdf 100644 --- a/Jenkinsfile-pr +++ b/Jenkinsfile-pr @@ -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') @@ -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 + ) + } } } } diff --git a/README.md b/README.md index 12a0b7d..fc7f097 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ # fastcampus-jenkins # fastcampus-jenkins + + + +