The situation
I want to automate the updating of my repository's wiki using Pipelines.
My wiki Markdown files are currently generated programmically from my project repository, and I just need to transfer them to the wiki repository. I need Pipelines to clone both my project repository and my wiki repository for this to work.
The problem
In my BitBucket Pipeline of my project repository, when a step attempts to clone the wiki into the pipeline's build directory, I'm getting the error.
Cloning into 'wiki'...
fatal: could not read Username for '<https://bitbucket.org>': No such device or address
Error: Command failed: git clone http://bitbucket.org/><WORKSPACE>/<MY_REPO>/wiki
Is there perhaps a way to let Pipelines know to clone both the project repo AND the wiki repo right from the get go?
Otherwise, how can I let Pipelines, running from my project repository, clone and make changes to my wiki repository?
Solutions I tried
Changing wiki access permissions
Whether my wiki was public, private or allowed anyone with wiki access to edit the wiki made no change.
HTTP
Since I cannot reuse the REPOSITORY_ACCESS_TOKEN that was used to clone my project into Pipeline's build environment, I tried giving access to the wiki through HTTP by creating a new Repository Access Token (that had all the read/write privileges), and then, in the pipeline, including a step that looks like this:
git clone https://x-token-auth:$NEW_ACCESS_TOKEN@bitbucket.org/><WORKSPACE>/<MY_REPO>.git/wiki
The Access key is valid the first time I use it (during cloning), but if I want to commit, or even clone again, I get this error:
Cloning into 'wiki'...
remote: Your credentials lack one or more required privilege scopes.
fatal: unable to access 'https://x-token-auth:$NEW_ACCESS_TOKEN@bitbucket.org/><WORKSPACE>/<MY_REPO>.git/wiki/': The requested URL returned error: 403
SSH
I also tried using SSH keys in Pipelines by creating a key and then, somewhat recursively, adding the public key into the repository's Access Keys. In Pipelines, running the step
git clone git@bitbucket.org:<WORKSPACE>/<MY_REPO>.git/wiki
gave the following error
Cloning into 'wiki'...
Warning: Permanently added the ECDSA host key for IP address '18.205.93.1' to the list of known hosts.
accessing wiki via an access key is not supported
fatal: Could not read from remote repository
Annex
Here's a copy of my bitbucket-pipelines.yml
image: node:16
pipelines:
branches:
main:
- step:
name: Get Wiki
script:
- git clone <https://x-token-auth:$NEW_ACCESS_TOKEN@bitbucket.org/><WORKSPACE>/<MY_REPO>.git/wiki
- cd wiki
- ls -la