Adding version control integration

Adding version control services like Github and Bitbucket to TrueFoundry installation allows a user to directly access public/private repositories of the linked account for deployment.
To allow these integrations in your app, following steps need to be followed.

Github

To enable Github integration in your app, you need to create a github app using your github account. This github app can then be installed on the users's account through our platform.

Follow these steps to create the github app and integrate it with truefoundry:

  • In Github, select your avatar (Your profile and settings) from the navigation bar at the top of the screen. If you want to create app for personal account, select Settings. If you want to create it for an organization, select Your organizations > Settings.
  • On the sidebar, select Developer Settings.
  • On the sidebar, select Github apps.
  • Click the New Github App button and add the following settings:
10571057

Github app settings

- Identifying and authorizing users 
    - Callback URL : https://app.example-org.truefoundry.com/api/svc/v1/vcs/github/callback
    - Check : Expire user authorization tokens
    - Check : Request user authorization (OAuth) during installation
10761076

Github app settings

- Post installation
    - Check : Redirect on update
- Webhook
    - Check : Active
    - Webhook URL : https://app.example-org.truefoundry.com/api/svc/v1/vcs/github/webhook-callback
936936

Github app settings

- Permissions
    - Repository Permissions:
        - Administration: read and write
        - Commit statuses : read and write
        - Contents : read and write
        - Metadata : read-only
        - Pull request: read and write
        - Webhooks: rad and write
11121112

Github app permissions

- Where can this GitHub App be installed? : Any account
10951095

Github app settings

  • Once the app is created, store the GitHub App name and App id.
10041004

Github app properties

  • Navigate to Private Keys section and generate a private key. A PEM file containing private key will be downloaded.
11011101

Github app private key

  • Base 64 encode the entire content of the file. Please make sure to omit any whitelines before or after the text in the file. To base64 encode, use following commands on the command line:
    - Linux : base64 private_key.pem > private_key.b64
    - Windows : certutil -encode private_key.pem tmp.b64 && findstr /v /c:- tmp.b64 > private_key.b64 && del tmp.b64
    - Mac : base64 -i private_key.pem -o private_key.b64
    Please make sure to omit any whitelines before or after the text in the file. Store the file content of private_key.b64 as private_key.
  • Set environment variables using the docs :

Bitbucket

To enable Bitbucket integration in your app, you need to create a Bitbucket consumer using your Bitbucket account. This consumer can then be added to the users's account through our platform.
Follow these steps to create the Bitbucket app and integrate it with truefoundry:

804804

Bitbucket app settings

- Permissions: 
    - Account : email, read
    - Repositories : read, write
    - Workspace membership : read
    - Pull requests : read, write
816816

Bitbucket app permissions

  • Once the consumer is created, click on the consumer and store the key and secret for later use.
740740

Bitbucket app properties

  • Set environment variables using the docs :
    • BITBUCKET_CLIENT_ID=${key}
    • BITBUCKET_CLIENT_SECRET=${secret}