Store other formats in Artifact Registry
Learn how to set up an Artifact Registry generic format repository and upload a YAML file.
Before you begin
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Artifact Registry API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles. -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Artifact Registry API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.
Launch Cloud Shell
In the Google Cloud console, activate Cloud Shell.
At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.
In this quickstart, you will use Cloud Shell to run gcloud commands.
Create a generic repository
To create a generic format repository named
quickstart-generic-repoin the locationus-central1with the descriptionGeneric repository, run the following command:gcloud artifacts repositories create quickstart-generic-repo \ --repository-format=generic \ --location=us-central1 \ --description="Generic repository"To verify that your repository was created, run the following command:
gcloud artifacts repositories listTo simplify
gcloudcommands, run the following commands to set the default repository toquickstart-generic-repoand the default location tous-central1.To set the default repository to
quickstart-generic-repo, run the following command:gcloud config set artifacts/repository quickstart-generic-repoTo set the default location to
us-central1, run the following command:gcloud config set artifacts/location us-central1
After the values are set, you don't need to specify them in
gcloudcommands that require a repository or a location.
Upload an artifact to the repository
In your home directory, create a file to upload to your repository:
echo "hello world" > hello.yamlTo upload the file as an artifact to the repository, run the following command:
gcloud artifacts generic upload \ --source=hello.yaml \ --package=my-package \ --version=1.0.0Where:
hello.yamlis the path of the file to upload.my-packageis the package to upload.1.0.0is the version of the artifact. You can't overwrite an existing version in the repository.
View artifacts in the repository
To verify that your artifact was added to the repository, you can list all artifacts by running the following command:
gcloud artifacts files list
The response includes the file details in the format
PACKAGE:VERSION:FILE_NAME.
In the following example, hello.yaml is the FILE_NAME:
FILE: my-package:1.0.0:hello.yaml
CREATE_TIME: 2023-03-09T20:55:07
UPDATE_TIME: 2023-03-09T20:55:07
SIZE (MB): 0.000
OWNER: projects/my-project/locations/us-central1/repositories/quickstart-generic-repo/packages/my-package/versions/1.0.0
Download a generic artifact
To download a generic artifact from your repository, run the following command:
gcloud artifacts generic download \
--name=hello.yaml \
--package=my-package \
--version=1.0.0 \
--destination=DESTINATION
Where:
hello.yamlis the name of the file to download.my-packageis the package to download.1.0.0is the version of the artifact.
Replace DESTINATION with the directory in your local
file system where you want to save the download. The destination folder must
already exist or the command will fail.
Clean up
To avoid incurring charges to your Google Cloud account for the resources used in this tutorial, either delete the project that contains the resources, or keep the project and delete the repository.
Delete the project
- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
Delete the repository
Before you remove a repository, ensure that any packages that you want to keep are available in another location.
To delete the
quickstart-generic-reporepository, run the following command:gcloud artifacts repositories delete quickstart-generic-repoIf you want to remove the default repository and location settings that you configured for the active
gcloudconfiguration, run the following commands:gcloud config unset artifacts/repository gcloud config unset artifacts/location