Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add mirroring doc for bitbucket cloud #294

Merged
merged 1 commit into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ The logs can be explored using [Bunyan CLI](http://trentm.com/node-bunyan/bunyan
- [Generating import data](docs/import-data.md)
- [Mirroring Github.com/Github Enterprise organizations & repos in Snyk](docs/mirror-github.md)
- [Mirroring Gitlab organizations & repos in Snyk](docs/mirror-gitlab.md)
- [Mirroring Bitbucket Server organizations & repos in Snyk](docs/mirror-bitbucket-server.md)
- [Mirroring Bitbucket Cloud organizations & repos in Snyk](docs/mirror-bitbucket-cloud.md)

- [Kicking off an import](docs/import.md)
- [Contributing](.github/CONTRIBUTING.md)
Expand Down
18 changes: 18 additions & 0 deletions docs/mirror-bitbucket-cloud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Mirroring Bitbucket Cloud organizations and repos in Snyk
IlanTSnyk marked this conversation as resolved.
Show resolved Hide resolved
In order to import the entirety of Bitbucket Cloud repos into Snyk you can use the available utils to make it possible in 4 commands.
You will need to configure Bitbucket Cloud username and password and Snyk token as environment variable to proceed.
Please refer to individual documentation pages for more detailed info, however the general steps are:

1. `export BITBUCKET_CLOUD_USERNAME=***`, `export BITBUCKET_CLOUD_PASSWORD=***` and `export SNYK_TOKEN=***`
2. Generate organization data e.g. `snyk-api-import orgs:data --source=bitbucket-cloud --groupId=<snyk_group_id>` [Full instructions](./orgs.md)
3. Create organizations in Snyk `snyk-api-import orgs:create --file=orgs.json` [Full instructions](./orgs.md) will create a `snyk-created-orgs.json` file with Snyk organization ids and integration ids that are needed for import.
4. Generate import data `snyk-api-import import:data --orgsData=snyk-created-orgs.json --source=bitbucket-cloud --integrationType=bitbucket-cloud` [Full instructions](./import-data.md)
5. Run import `DEBUG=*snyk* snyk-api-import import`[Full instructions](./import.md)

## Re-importing new repos & orgs only while Mirroring
Once initial import is complete you may want to periodically check for new repos and make sure they are added into Snyk. To do this a similar flow to what is described above with a few small changes can be used:
1. `export BITBUCKET_CLOUD_USERNAME=***`, `export BITBUCKET_CLOUD_PASSWORD=***` and `export SNYK_TOKEN=***`
2. Generate organization data in Snyk and skip any that do not have any repos via `--skipEmptyOrg` `snyk-api-import orgs:data --source=bitbucket-cloud --groupId=<snyk_group_id> --skipEmptyOrg` [Full instructions](./orgs.md)
3. Create organizations in Snyk and this time skip any that have been created already with `--noDuplicateNames` parameter `snyk-api-import orgs:create --file=orgs.json --noDuplicateNames` [Full instructions](./orgs.md) will create a `snyk-created-orgs.json` file with Snyk organization ids and integration ids that are needed for import.
4. Generate import data `snyk-api-import import:data --orgsData=snyk-created-orgs.json --source=bitbucket-cloud --integrationType=bitbucket-cloud` [Full instructions](./import-data.md)
5. Run import `DEBUG=*snyk* snyk-api-import import`[Full instructions](./import.md)