Bitbucket pipeline - possibility to merge one branch to another
bitbucket, bitbucket-pipelines
Solution
In the “script” section of the YAML configuration, you can do more or less anything you can do at the shell, so (although I’ve never tried it) don’t see a reason why this shouldn’t be possible.
In other words, you’d have to:
- Switch the branch to `master`
- Merge dev (optionally, using the predefined `BITBUCKET_COMMIT` environment variable, which identifies your `dev` commit)
- Commit to `master` (and probably also push)
As `git` is available in `script`, you can use normal git commands and do not need anything specific to Bb Pipelines, like so:
script:
- git fetch
- git checkout -b master
- git merge Dev
- git push -v --tags origin master:master
To make sure this is only done when your Ant job is successful, you should make sure that in case of an error you’ll get a non-zero exit status (which, I assume, is Ant’s default behaviour).
Problem
I have a repository with two branches: master and Dev and I want to configure that pipline in such a way that when I push code to Dev branch and code build was successfull, the Dev was merged to master. Unfortunatly I can't find any information about merge in bitbucket piplines docs. That's my yml file: ``` pipelines: branches: Dev: - step: script: - ant deployCodeCheckOnly -Dsf.username=$SF_USERNAME -Dsf.password=$SF_PASSWORD ``` Could somebody help me with that case? If it possible? --Edit I try to change script as sugest: ``` pipelines: branches: Dev: - step: script: - ant deployCodeCheckOnly -Dsf.username=$SF_USERNAME -Dsf.password=$SF_PASSWORD - git remote -v - git fetch - git checkout master - git merge Dev - git push -v --tags origin master:master ``` Result: ``` git remote -v + git remote -v origin git@bitbucket.org:repository/project.git (fetch) origin git@bitbucket.org:repository/project.git (push) git fetch origin + git fetch origin Warning: Permanently added the RSA host key for IP address ..... to the list of known hosts. ``` And error: ``` + git checkout master error: pathspec 'master' did not match any file(s) known to git. ``` --Solution ``` Dev: - step: script: - ant deployCodeCheckOnly -Dsf.username=$SF_USERNAME Dsf.password=$SF_PASSWORD - git fetch - git checkout -b master - git merge Dev - git push -v --tags origin master:master ```