Created
April 6, 2016 23:40
-
-
Save martinda/b2ece95c2c71ddb4d4a762f0a02561b3 to your computer and use it in GitHub Desktop.
Jenkins Pipeline DSL code to demonstrate git merge before build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Jenkins Pipeline DSL to demonstrate git merge before build | |
node { | |
String path = '/tmp/jenkins/upstream-repo' | |
sh "rm -rf ${path}" | |
ws(path) { | |
sh 'git --version' | |
sh 'git init' | |
sh 'touch README.md; git add README.md; git commit -m "init"' | |
sh 'git checkout -b pull-requests/1/from' | |
sh 'touch file.txt; git add file.txt; git commit -m "Add file"' | |
} | |
// sh "git clone ${path} ." | |
sh 'pwd; tree; ls;' | |
checkout([ | |
$class: 'GitSCM', | |
branches: [[name: 'refs/heads/master']], | |
userRemoteConfigs: [[ | |
name: 'origin', | |
refspec: 'pull-requests/1/from', | |
url: path | |
]], | |
extensions: [ | |
[ | |
$class: 'PreBuildMerge', | |
options: [ | |
fastForwardMode: 'NO_FF', | |
mergeRemote: 'origin', | |
mergeStrategy: 'MergeCommand.Strategy', | |
mergeTarget: 'master' | |
] | |
], | |
[ | |
$class: 'LocalBranch', | |
localBranch: 'master' | |
]] | |
]) | |
sh 'git log -n 10 --graph --pretty=oneline --abbrev-commit --all --decorate=full' | |
} |
I need to merge develop to master branch and I am using this approach. Do I need to push to git or this is done automatically at the end of my pipeline?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
could please help me out, git-merge-after-build.dsl help me