Skip to content

Commit f414354

Browse files
committed
Adding some notes on querying repo for urls
1 parent bd35ab6 commit f414354

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

code-repositories/code-repositories-with-oci-cli.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,24 @@ Once you have a Project created, you can use the `oci` command line tool to gene
4949

5050
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).
5151

52-
oci devops repository create --name "NAME-OF-PROJECT" --project-id "OCID_FOR_PROJECT" --repository-type HOSTED
52+
oci devops repository create --name "NAME-OF-PROJECT" --project-id "OCID_FOR_PROJECT" --repository-type HOSTED --query 'data.["http-url","ssh-url"]'
5353

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.
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. Adding the `--query` to the end will return the HTTP and SSH urls for the new repository.
5555

56-
You can now retrive the SSH URL for your repository using the `list` command:
56+
You can also retrive the SSH URL for all repositories using the `list` command:
5757

5858
oci devops repository list --project-id "OCID_FOR_PROJECT"
5959

6060
You'll see an entry for `ssh-url` in the response.
6161

62+
Alternatively, you can grab the new ID for your repo at the time of creation and then use `repository get` to retrive the urls:
63+
64+
repoId=$(oci devops repository create --name "NAME-OF-PROJECT" --project-id OCID_FOR_PROJECT --repository-type HOSTED --query 'data.id' | sed s'/[\[",]//g')
65+
66+
Then use `repository get`:
67+
68+
oci devops repository get --repository-id $repoId --query 'data.["http-url","ssh-url"]'
69+
6270
### Using the repository
6371

6472
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].`

0 commit comments

Comments
 (0)