|
| 1 | +A sample illustration of [Bitbucket Cloud ](https://bitbucket.org/product?&aceid=&adposition=&adgroup=92542404895&campaign=1407242867&creative=544605032325&device=c&keyword=bitbucket%20cloud&matchtype=e&network=g&placement=&ds_kids=p51241240716&ds_e=GOOGLE&ds_eid=700000001551985&ds_e1=GOOGLE&gclid=EAIaIQobChMIsa_OyLy--AIV8pJmAh079go-EAAYASAAEgLsifD_BwE&gclsrc=aw.ds) code repo integration with OCI DevOps. |
| 2 | + |
| 3 | +-------- |
| 4 | + |
| 5 | +#### Objectives |
| 6 | + |
| 7 | +- Create an APP Password on Bitbucket Cloud. |
| 8 | +- Create vault, and policies accordingly. |
| 9 | +- Create a DevOps connection and integrate it with OCI. |
| 10 | +- Test and validate the integrations. |
| 11 | + |
| 12 | +* Specific instruction to clone only this example. |
| 13 | + |
| 14 | + ``` |
| 15 | + $ git init oci-devops-coderepo-with-bitbucketcloud |
| 16 | + $ cd oci-devops-coderepo-with-bitbucketcloud |
| 17 | + $ git remote add origin https://github.com/oracle-devrel/oci-devops-examples |
| 18 | + $ git config core. sparsecheckout true |
| 19 | + $ echo "oci-coderepo-examples/oci-devops-coderepo-with-bitbucketcloud/*">>.git/info/sparse-checkout |
| 20 | + $ git pull --depth=1 origin main |
| 21 | +
|
| 22 | + ``` |
| 23 | +
|
| 24 | +#### Procedure |
| 25 | +
|
| 26 | +- Follow Bitbucket Cloud documentation and do a sign-in. - https://bitbucket.org/product/guides |
| 27 | +- Click `profile` on the top right corner and click `Personal Setting`. |
| 28 | +
|
| 29 | + |
| 30 | +
|
| 31 | +- User `Personal Setting` > make a note of your `user name`. |
| 32 | +
|
| 33 | + |
| 34 | +
|
| 35 | +- In the `left-side menu`, click `App passwords` and then click Create app password. |
| 36 | +- Enter a `Label (name)` for the password. |
| 37 | +- Select the following checkboxes for Permissions: |
| 38 | + - Account: Read |
| 39 | + - Workspace membership: Read |
| 40 | + - Projects: Read |
| 41 | + - Pull requests: Read |
| 42 | + - Webhooks: Read and write |
| 43 | +
|
| 44 | + |
| 45 | +- Click Create. |
| 46 | +- Copy the app password immediately to a secure location, because you cannot retrieve it again after you navigate away from the page. |
| 47 | +
|
| 48 | +- To securely store and orchestrate Gitlab Personal Access token, we will create a new OCI Vault for now. |
| 49 | +
|
| 50 | +- Create a new vault under the concerned compartment. - https://docs.oracle.com/en-us/iaas/Content/KeyManagement/Concepts/keyoverview.htm#Overview_of_Vault |
| 51 | +
|
| 52 | + |
| 53 | +
|
| 54 | +- Create a new `Encryption Key`. |
| 55 | +
|
| 56 | + |
| 57 | +
|
| 58 | +- Create a new secret and store the Bitbucket Cloud App password. |
| 59 | +
|
| 60 | + |
| 61 | +
|
| 62 | +- Create a `Dynamic group` with the below rules. |
| 63 | +
|
| 64 | +``` |
| 65 | +ALL {resource.type = 'devopsconnection', resource.compartment.id = 'ocid1.compartment.oc1..xxxxx'} |
| 66 | +``` |
| 67 | +
|
| 68 | +- Create a policy (Ensure to create it under the ROOT of tenancy) for the dynamic groups with the below policy statement. |
| 69 | +
|
| 70 | +``` |
| 71 | +Allow dynamic-group mr-devops-policy-checker-dg-connection to read secret-family in compartment <compartment name> |
| 72 | +Allow dynamic-group mr-devops-policy-checker-dg-connection to use ons-topics in compartment <compartment name> |
| 73 | +``` |
| 74 | +
|
| 75 | +- Create a notification topic, that will be used for DevOps - https://docs.oracle.com/en-us/iaas/Content/Notification/Tasks/managingtopicsandsubscriptions.htm#createTopic |
| 76 | +
|
| 77 | + |
| 78 | +
|
| 79 | +
|
| 80 | +- Create a DevOps project - https://docs.oracle.com/en-us/iaas/Content/devops/using/create_project.htm#create_a_project |
| 81 | +- Ensure to associate it with a `notification topic` created. |
| 82 | +
|
| 83 | + |
| 84 | +
|
| 85 | +- Under the project click `Enable Logging` and `toggle` and enable the logs. |
| 86 | +
|
| 87 | + |
| 88 | +
|
| 89 | +- Select the logging details and enable. |
| 90 | +
|
| 91 | +- Create a new `external connection` - https://docs.oracle.com/en-us/iaas/Content/devops/using/create_connection.htm |
| 92 | +
|
| 93 | + |
| 94 | +
|
| 95 | +- Select the type as `Bitbucket Cloud`. |
| 96 | +- Provide the `Bitbucket username ` as the username. |
| 97 | +- Associate with the Vault and the `Secret` created |
| 98 | +
|
| 99 | + |
| 100 | +
|
| 101 | +- Use DevOps `Code Repositories` and mirror Bitbucket Cloud to oci DevOps. - https://docs.oracle.com/en-us/iaas/Content/devops/using/mirror_repo.htm |
| 102 | +
|
| 103 | + |
| 104 | +
|
| 105 | +
|
| 106 | +- Select the external connection created and select the Bitbucket Cloud repository. You may mention a custom name (as optional) which will be used when the external repo is cloned to the OCI Code repo. |
| 107 | +- You may alter the Scheduling type to a custom value if needed. The default sync is `15 minutes`. |
| 108 | +
|
| 109 | + |
| 110 | +
|
| 111 | +- After a while, the repo will be available via `OCI Code Repo` |
| 112 | +
|
| 113 | + |
| 114 | +
|
| 115 | + |
| 116 | +
|
| 117 | +Contributors |
| 118 | +=========== |
| 119 | +
|
| 120 | +- Author: Rahul M R. |
| 121 | +- Collaborators: NA |
| 122 | +- Last release: June 2022 |
| 123 | +
|
| 124 | +### Back to examples. |
| 125 | +---- |
| 126 | +
|
| 127 | +- 🍿 [Back to OCI Devops Coderepo sample](./../README.md) |
| 128 | +- 🏝️ [Back to OCI Devops sample](./../../README.md) |
| 129 | +
|
0 commit comments