Skip to content

Commit bd35ab6

Browse files
committed
Initial version of oci cli code repo piece
1 parent 251caec commit bd35ab6

File tree

8 files changed

+72
-0
lines changed

8 files changed

+72
-0
lines changed
670 KB
Loading
82.4 KB
Loading
86 KB
Loading
100 KB
Loading
30.9 KB
Loading
122 KB
Loading
160 KB
Loading
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
title: "Creating Oracle Code Repositories using the oci CLI"
3+
description: "Fast track repository creation using the oci command line tool."
4+
date: 2023-01-26 12:00
5+
parent: [tutorials]
6+
---
7+
The first thing you need to do to start using Code Repositories is to create a Project to host your new repository. If you already have a project, you'll just need its OCID and you can skip to the next section.
8+
9+
1. Navigate to [cloud.oracle.com][1]
10+
2. Click the "hamburger" icon in the upper left.
11+
3. Type "projects" in the search field, then click "Projects DevOps" on the right.
12+
13+
![Screenshot of: Type "projects" in the search field, then click "Projects DevOps" on the right.][3]
14+
4. Click the "Choose a compartment" field and select your compartment.
15+
16+
![Screenshot of: Click the "Choose a compartment" field and select your compartment.][4]
17+
18+
5. Click "Create devops project"
19+
20+
![Screenshot of: Click "Create devops project"][5]
21+
6. Type a name for your project, in this case I'm using RepositoryDemo
22+
23+
7. Click "Select topic"
24+
25+
8. You need to assign a topic to the project. If you don't have any topics available, you'll need to add at least one to your instance.
26+
27+
![Screenshot of: Click "Select topic"][6]
28+
29+
![Select topic][7]
30+
9. Click "Create devops project"
31+
32+
![Screenshot of: Click "Create devops project"][8]
33+
34+
35+
[1]: https://cloud.oracle.com/
36+
[2]: assets/code-repo-step1.jpg
37+
[3]: assets/code-repo-step2.jpg
38+
[4]: assets/code-repo-step3.jpg
39+
[5]: assets/code-repo-step4.jpg
40+
[6]: assets/code-repo-step5.jpg
41+
[7]: assets/code-repo-step6.jpg
42+
[8]: assets/code-repo-step7.jpg
43+
44+
Take note of the OCID of the new project, you'll need it in the next steps. You can just click on "Copy" next to the OCID label to copy the (rather long) string to your clipboard automatically.
45+
46+
### Creating the repository
47+
48+
Once you have a Project created, you can use the `oci` command line tool to generate a repo. You can do this either in the Cloud Shell, or in you local Terminal if you have `oci` installed.
49+
50+
To create a repository, we'll use [`oci create`](https://docs.oracle.com/iaas/tools/oci-cli/latest/oci_cli_docs/cmdref/devops/repository/create.html).
51+
52+
oci devops repository create --name "NAME-OF-PROJECT" --project-id "OCID_FOR_PROJECT" --repository-type HOSTED
53+
54+
`--name` is the name of the project for which you're creating the new repo. `--project-id` needs to be the OCID for the project, which you can copy from the project overview in the console. The `--repository-type` should be HOSTED to create a repository you can remotely access with SSH.
55+
56+
You can now retrive the SSH URL for your repository using the `list` command:
57+
58+
oci devops repository list --project-id "OCID_FOR_PROJECT"
59+
60+
You'll see an entry for `ssh-url` in the response.
61+
62+
### Using the repository
63+
64+
1. First, create a new directory on your local machine where you want to store your code. This can be done by opening the command prompt or terminal and navigating to the desired location, then using the command `mkdir [directory name].`
65+
2. Next, initialize the directory as a Git repository by using the command `git init` within the newly created directory.
66+
3. Connect your local repository to a remote repository by using the command `git remote add origin [ssh URL from above]`. This allows you to push and pull code from the remote repository to your local machine.
67+
4. Create a new file in the directory, for example, `example.sql` and add some sample code to it.
68+
5. Use the command `git add [file name]` to add the new file to the repository.
69+
6. Use the command `git commit -m [commit message]` to commit the changes to the repository.
70+
7. Finally, use the command `git push origin master` to push the changes to the remote repository.
71+
72+
Your Oracle code repository is now set up and ready to use. You can continue to add and commit code changes as needed, and use the `git pull` command to retrieve updates from the remote repository.

0 commit comments

Comments
 (0)