I'm trying to enable BitBucket Pipelines for a Java-based project to auto-increment the build number following Semantic Versioning. The version incrementing is in place and working well via Maven Versions plugin, the only thing I need to get working is BitBucket Pipelines / Docker image to be able to commit back to the repository...
Here's the relevant section from my BitBucket Pipeline YAML config:
image: maven:3.5.2-jdk-8
pipelines:
default:
- step:
caches:
- maven
script:
- mvn -B -U clean install
- step:
#increment all code version numbers
- snapshotversion=`grep 'build.version' build.properties | awk -F '=' '{print $2}'`
- releaseversion=`echo "$snapshotversion" | cut -f1 -d"-"`
- mvn versions:set -DnewVersion=$snapshotversion
- mvn versions:commit
- mvn -B -U clean install
# Commit any changes back to this "release/x.y.z"... definitely good to here, the rest meh 
- git add .
- git config user.name "$GIT_USERNAME"
- git config user.email "$GIT_EMAIL"
- ssh-copy-id -i ssh-rsa $BITBUCKET_SSH_PUBLIC_KEY git@bitbucket.org:${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}.git
- ssh -i ~/.ssh/config git@bitbucket.org:${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}.git
- commitmsg="[skip ci] Release Candidate for merging to master branch and PROD deployment"
- if [[ -n $(git status -s) ]] ; then filelist=`git status -s` ; git commit -a -m "$commitmsg" -m "$filelist" ; git push origin release/$releaseversion:release/$releaseversion ; else echo "No changes detected"; fi
The error it gives is:
<span>/usr/bin/ssh-copy-id: ERROR: failed to open ID file '<a href="http://ssh-rsa.pub" target="_blank" rel="nofollow noopener noreferrer">ssh-rsa.pub</a>': No such file</span>
So I think its fairly close, the only part I can't figure out is how to add reference to my SSH key (either by file or injecting the whole Public Key as an environment variable for instance), what I'm trying to do is clearly wrong since it errors out. Does anyone have a clear working example of committing ANYTHING back to a BitBucket GIT repo via BitBucket Pipelines?
I've followed the steps suggested here by creating an SSH Key within my BitBucket Cloud settings for the repo, but with no luck:
https://confluence.atlassian.com/bitbucket/use-ssh-keys-in-bitbucket-pipelines-847452940.html
Should the SSH Key really be "automagically available" to its own repo's Pipeline, like some reported, or like others report do you need a very kludgy workaround:\
https://community.atlassian.com/t5/Bitbucket-questions/Trouble-with-SSH-and-Bitbucket-Pipelines/qaq-p/604330
https://bitbucket.org/site/master/issues/13213/push-back-to-remote-from-pipelines
Appreciate these threads as it helps to get suggestions from the community and/or Atlassian. Hoping someone can spot my stupid mistake and that last little push to CD wonderland hah... but seriously, really appreciate any support on this!