참고 링크
## 젠킨스 파이프라인 문법
https://www.jenkins.io/doc/pipeline/steps/workflow-scm-step/
## freestyle porject 에서 깃 머지
https://www.edureka.co/community/68544/how-to-merge-two-branch-in-github-using-jenkins
## pipe line 에서 깃 머지
https://stackoverflow.com/questions/17696653/how-to-auto-merge-git-branches-prior-to-a-jenkins-build
## ff , no-ff 옵션
https://minemanemo.tistory.com/46
## 머지 오류에 대해서
https://on1ystar.github.io/git/2021/02/22/Git-2/
https://github.com/jenkins-x/jx/issues/3897
## git merge 하는법
https://wotres.tistory.com/entry/git-merge-%ED%95%98%EB%8A%94-%EB%B2%95
##
오류 메시지
## Please tell me who you are. 메시지 출력
깃에서 머지를 실행 할 시 아래와 같이 출력됨
====================================================================================================
+ git merge dev
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident name (for <jenkins@p-stest-tk1-e02.(none)>) not allowed
====================================================================================================
해결 방안은 아래와 같이 설정 등록
https://playground-in-home.tistory.com/3
https://git-scm.com/book/ko/v2/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0-Git-%EC%B5%9C%EC%B4%88-%EC%84%A4%EC%A0%95
====================================================================================================
sh 'git config user.name "kimsungchul"'
sh 'git config user.email gnew@DESKTOP-MT075B9'
====================================================================================================
--global 옵션으로 설정하는 것은 딱 한 번만 하면 됨.
해당 시스템에서 해당 사용자가 사용할 때는 이 정보를 사용한다.
만약 프로젝트마다 다른 이름과 이메일 주소를 사용하고 싶으면 --global 옵션을 빼고 명령을 실행한다.
--global 옵션 적용, 근데 이거는 글로벌 설정이라서 사용하면 안댐. 혼자쓸꺼면 해도됨
====================================================================================================
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
====================================================================================================
아래의 오류메시지가 출력됨
git push origin master_old
fatal: could not read Username for 'https://github.com/kkimsungchul/stock.git': No such device or address
====================================================================================================
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git credentialsId: 'ksc_git', url: 'https://github.com/kkimsungchul/stock.git', branch: 'master_old'
git credentialsId: 'ksc_git', url: 'https://github.com/kkimsungchul/stock.git', branch: 'dev'
}
}
stage('merge') {
steps {
sh 'git checkout master_old'
sh 'git branch '
sh 'git config user.name "kimsungchul"'
sh 'git config user.email gnew@DESKTOP-MT075B9'
sh 'git merge dev'
sh 'git log -p -2'
sh 'git push origin master_old'
}
}
}
}
====================================================================================================
- 아래의 스크립트 실행시 오류 발생
====================================================================================================
hudson.plugins.git.GitException: Command "git rev-parse dev/master_old^{commit}" returned status code 128:
stdout: dev/master_old^{commit}
stderr: fatal: ambiguous argument 'dev/master_old^{commit}': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
====================================================================================================
====================================================================================================
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git credentialsId: 'ksc_git', url: 'https://github.com/kkimsungchul/stock.git', branch: 'master_old'
git credentialsId: 'ksc_git', url: 'https://github.com/kkimsungchul/stock.git', branch: 'dev'
}
}
stage('merge') {
steps {
checkout(
[
$class: 'GitSCM',
extensions: [
[
$class: "PreBuildMerge",
options: [
mergeTarget: "master_old",
fastForwardMode: "FF",
mergeRemote: "dev",
mergeStrategy: "RECURSIVE_THEIRS"
],
],
[
$class: 'UserIdentity',
email: 'gnew@DESKTOP-MT075B9',
name: 'kimsungchul'
],
],
userRemoteConfigs: [[credentialsId: 'ksc_git', url: 'https://github.com/kkimsungchul/stock']]
]
)
}
}
}
}
====================================================================================================
====================================================================================================
pipeline {
agent any
stages {
stage('Checkout') {
steps {
checkout([$class: 'GitSCM',
branches: [[name: 'dev']],
extensions: [],
userRemoteConfigs: [[credentialsId: 'ksc_git', url: 'https://github.com/kkimsungchul/stock.git']]
])
}
}
}
}
====================================================================================================