### Start VSphere Hatchery Source: https://github.com/ovh/cds/blob/master/docs/content/development/contribute/hatchery.md Command to start the VSphere hatchery service with a specified configuration file. This command is used to initialize and run the hatchery component for managing virtual machines in a VSphere environment. ```bash engine start hatchery:vsphere --config config.toml ``` -------------------------------- ### Starting CDS µServices with engine Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/cds_services.md Demonstrates how to start individual CDS microservices using the 'engine' binary. This is useful for managing and deploying different components of the CDS platform. ```bash $engine start api $engine start cdn $engine start ui $engine start hooks $engine start vcs $engine start elasticsearch $engine start repositories $engine start "hatchery:local" $engine start "hatchery:swarm" $engine start "hatchery:openstack" $engine start "hatchery:kubernetes" $engine start "hatchery:vsphere" $engine start migrate ``` -------------------------------- ### Build and Run Golang CDS Example Source: https://github.com/ovh/cds/blob/master/docs/content/development/sdk/golang.md Provides the command to compile and execute the example Go program, requiring a signin token and the CDS API endpoint. ```bash go run main.go --token xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --api http://localhost:8081 ``` -------------------------------- ### Launch CDS Local Hatchery Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/ready-to-run/from-binaries.md Starts the CDS local hatchery service, responsible for spawning and managing workers. Also shows how to start multiple services with a single command. ```bash ./cds-engine start hatchery:local --config $HOME/cds/conf.toml # notice that you can run api, ui, cdn and hatchery with one common only: # ./cds-engine start api ui cdn hatchery:local --config $HOME/cds/conf.toml ``` -------------------------------- ### Starting CDS Repositories Service Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/cds_services.md Command to start an instance of the CDS repositories service. Requires 256MB of RAM per instance. ```shell engine start repositories ``` -------------------------------- ### Install Golang on macOS (Bash) Source: https://github.com/ovh/cds/blob/master/docs/content/development/contribute/development.md Guide to installing a specific version of Golang on macOS, setting environment variables, and verifying the installation. It includes downloading the tarball and extracting it to the GOROOT directory. ```bash #!/bin/bash # Example with version 1.19 on macOS: export GOROOT=~/go export PATH=$PATH:$GOROOT/bin cd ~ curl -O https://dl.google.com/go/go1.19.darwin-amd64.tar.gz tar xzf go1.19.darwin-amd64.tar.gz # Check if Go installation is ok go version ``` -------------------------------- ### Configure and Launch CDS CDN Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/ready-to-run/from-binaries.md Sets up storage paths for CDN logs and buffers in the configuration file and starts the CDS CDN service. ```bash cd $HOME/cds mkdir -p storage/cdn-buffer storage/cdn ./cds-engine config edit conf.toml --output conf.toml \ cdn.storageUnits.storages.local.local.path=$HOME/cds/storage/cdn \ cdn.storageUnits.buffers.local-buffer.local.path=$HOME/cds/storage/cdn-buffer ./cds-engine start cdn --config $HOME/cds/conf.toml ``` -------------------------------- ### Start Individual CDS Engine Services Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/ready-to-run/from-binaries.md This demonstrates starting each CDS Engine service (API, CDN, UI, Hooks, VCS) and various Hatchery types (local, Docker, Swarm, Marathon, OpenStack, vSphere) as dedicated processes. This approach is recommended for production environments for better resource management and stability. ```bash $ ./cds-engine start api --config config.toml $ ./cds-engine start cdn --config config.toml $ ./cds-engine start ui --config config.toml $ ./cds-engine start hooks --config config.toml $ ./cds-engine start vcs --config config.toml $ ./cds-engine start hatchery:local --config config.toml $ ./cds-engine start hatchery:docker --config config.toml $ ./cds-engine start hatchery:swarm --config config.toml $ ./cds-engine start hatchery:marathon --config config.toml $ ./cds-engine start hatchery:openstack --config config.toml $ ./cds-engine start hatchery:vsphere --config config.toml ``` -------------------------------- ### Install and Launch Redis (Bash) Source: https://github.com/ovh/cds/blob/master/docs/content/development/contribute/development.md Steps to download, compile, and launch a local Redis server for CDS development. It covers downloading the release tarball, extracting it, compiling with 'make', and starting the server. ```bash #!/bin/bash # Example with version 4.0.11: wget http://download.redis.io/releases/redis-4.0.11.tar.gz tar xzf redis-4.0.11.tar.gz cd redis-4.0.11 make # launch redis-server src/redis-server # you should add src/ to your PATH ``` -------------------------------- ### Start All CDS Engine Services Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/ready-to-run/from-binaries.md This command starts all CDS Engine services (API, UI, CDN, Hooks, and a local Hatchery) using a specified configuration file. It's suitable for development or testing environments where a single process is sufficient. ```bash $ ./cds-engine start api ui cdn hooks hatchery:local --config config.toml Reading configuration file config.toml Starting service api Starting service ui Starting service cdn Starting service hooks Starting service vcs Starting service hatchery:local ``` -------------------------------- ### Launch CDS UI Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/ready-to-run/from-binaries.md Downloads the CDS UI assets and starts the UI service, making it accessible via a web browser at `http://localhost:8080/`. ```bash cd $HOME/cds ./cdsctl signup verify --api-url ... # Get this command from the API Logs ./cds-engine download ui --config conf.toml ./cds-engine start ui --config conf.toml ``` -------------------------------- ### Starting CDS CDN Service Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/cds_services.md Command to start an instance of the CDS CDN service. Requires 3GB of RAM and 4GB of Redis. ```shell engine start cdn ``` -------------------------------- ### Starting CDS API Service Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/cds_services.md Command to start an instance of the CDS API service. Requires 3GB of RAM and 128MB of Redis. ```shell engine start api ``` -------------------------------- ### Launch CDS UI (Bash) Source: https://github.com/ovh/cds/blob/master/docs/content/development/contribute/development.md Instructions to start the CDS user interface development server. This involves navigating to the UI directory and running 'npm start'. ```bash #!/bin/bash cd $(go env GOPATH)/src/github.com/ovh/cds/ui npm start ``` -------------------------------- ### CDS Application VCS Setup Example (YAML) Source: https://github.com/ovh/cds/blob/master/docs/content/docs/concepts/files/application-syntax.md This YAML configuration snippet shows how to link a CDS application to a Version Control System (VCS), specifying the repository, server, connection type, and associated keys for Git operations. ```yaml version: v1.0 name: myapp repo: myorg/myapp vcs_server: github vcs_connection_type: ssh vcs_ssh_key: proj-ssh-key vcs_pgp_key: proj-pgp-key ``` -------------------------------- ### Starting CDS UI Service Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/cds_services.md Command to start an instance of the CDS UI service. Requires 128MB of RAM per instance. ```shell engine start ui ``` -------------------------------- ### Starting CDS VCS Service Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/cds_services.md Command to start an instance of the CDS VCS service. Requires 256MB of RAM and 256MB of Redis. ```shell engine start vcs ``` -------------------------------- ### CDS Application Configuration Example (YAML) Source: https://github.com/ovh/cds/blob/master/docs/content/docs/concepts/files/application-syntax.md A comprehensive example of a CDS application configuration file in YAML format. It demonstrates the structure for defining version, name, variables, keys, repository details, VCS connection, and deployment settings. ```yaml version: v1.0 name: my-application variables: artifact.name: type: string value: my-application docker.image: value: my-org/my-application docker.registry: value: hub.docker.com keys: app-mySSHKey: type: ssh repo: my-org/my-application vcs_server: github vcs_connection_type: ssh vcs_ssh_key: app-mySSHKey deployments: my-kubernetes-cluster: timeout: value: 180 namespace: my-namespace helm_chart: value: deploy/helm/ helm_values: type: deploy/helm/values.yaml helm_version: type: 2.12.2 ``` -------------------------------- ### Starting CDS Migrate Service Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/cds_services.md Command to start an instance of the CDS migrate service. Requires 128MB of RAM per instance. ```shell engine start migrate ``` -------------------------------- ### Launch CDS API Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/ready-to-run/from-binaries.md Downloads worker binaries and starts the CDS API service, accessible at `http://localhost:8081`. Includes commands to check API status. ```bash cd $HOME/cds ./cds-engine download workers --config conf.toml ./cds-engine start api --config conf.toml # Check that CDS is up and running: curl http://localhost:8081/mon/version curl http://localhost:8081/mon/status ``` -------------------------------- ### Starting CDS Hooks Service Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/cds_services.md Command to start an instance of the CDS hooks service. Requires 256MB of RAM and 256MB of Redis. ```shell engine start hooks ``` -------------------------------- ### Start Docker Swarm Hatchery Source: https://github.com/ovh/cds/blob/master/docs/content/docs/integrations/swarm.md Starts the CDS Swarm hatchery by setting the DOCKER_HOST environment variable to specify the Docker daemon and then executing the 'engine start' command with the hatchery configuration. ```bash export DOCKER_HOST=tcp://xx.xx.xx.xx:2375 engine start hatchery:swarm --config config.toml ``` -------------------------------- ### Starting CDS Elasticsearch Service Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/cds_services.md Command to start an instance of the CDS elasticsearch service. Requires 256MB of RAM per instance. ```shell engine start elasticsearch ``` -------------------------------- ### Start CDS VCS Microservice Source: https://github.com/ovh/cds/blob/master/docs/content/docs/integrations/gerrit.md Commands to start the Version Control System (VCS) microservice for CDS. It can be started individually or alongside the CDS API within the same process. ```bash $ engine start vcs ``` ```bash # you can also start CDS api and vcs in the same process: $ engine start api vcs ``` -------------------------------- ### Install Dependencies (npm) Source: https://github.com/ovh/cds/blob/master/ui/README.md Installs project dependencies using npm. Requires Node.js 6.9.0+ and npm 3+. ```bash npm install ``` -------------------------------- ### Start PostgreSQL with Docker Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/ready-to-run/from-binaries.md Launches a PostgreSQL 14.0 instance in a Docker container, configured with user 'cds', password 'cds', and database 'cds' on port 5432 for CDS to use. ```bash docker run --name cds-db -e POSTGRES_PASSWORD=cds -e POSTGRES_USER=cds -e POSTGRES_DB=cds -p 127.0.0.1:5432:5432 -d postgres:14.0 ``` -------------------------------- ### CDS Initialization Script Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/ready-to-run/docker-compose/full-example.md This bash script initializes CDS by setting environment variables, pulling Docker images, configuring the database, and starting the CDS services. It also configures the CDS domain name, GitHub OAuth credentials, and downloads the cdsctl CLI. Replace placeholders with your specific values. ```bash #!/bin/bash set -ex export CDS_DOMAIN_NAME="your-cdsdemo.domain" export CDS_GITHUB_CLIENT_ID="xxxxxxxxxxx" export CDS_GITHUB_CLIENT_SECRET="xxxxxxxxxxx" mkdir -p tools/smtpmock curl https://raw.githubusercontent.com/ovh/cds/{{< param "version" "master" >}}/docker-compose.yml -o docker-compose.yml export HOSTNAME=$(hostname) export CDS_DOCKER_IMAGE=ovhcom/cds-engine:{{< param "version" "latest" >}} docker pull ovhcom/cds-engine:{{< param "version" "latest" >}} docker-compose up -d cds-db cds-cache elasticsearch dockerhost sleep 3 docker-compose logs| grep 'database system is ready to accept connections' docker-compose up cds-db-init docker-compose up cds-migrate sleep 3 docker-compose up cds-prepare export CDS_EDIT_CONFIG="vcs.servers.github.github.clientId=${CDS_GITHUB_CLIENT_ID} vcs.servers.github.github.clientSecret=${CDS_GITHUB_CLIENT_SECRET} " docker-compose up cds-edit-config export CDS_EDIT_CONFIG="api.url.api=http://localhost:8081 api.url.ui=https://${CDS_DOMAIN_NAME} hatchery.swarm.commonConfiguration.api.http.url=http://cds-api:8081" docker-compose up cds-edit-config export CDS_EDIT_CONFIG="hatchery.swarm.commonConfiguration.api.http.url=https://${CDS_DOMAIN_NAME}/cdsapi hooks.urlPublic=https://${CDS_DOMAIN_NAME}/cdshooks ui.hooksURL=http://cds-hooks:8083" docker-compose up cds-edit-config docker-compose up -d cds-api sleep 3 TOKEN_CMD=$(docker logs $(docker-compose ps -q cds-prepare) | grep INIT_TOKEN) && $TOKEN_CMD curl 'http://localhost:8081/download/cdsctl/linux/amd64?variant=nokeychain' -o cdsctl chmod +x cdsctl # this line will ask a password for admin user ./cdsctl signup --api-url http://localhost:8081 --email admin@localhost.local --username admin --fullname admin VERIFY_CMD=$(docker-compose logs cds-api | grep 'cdsctl signup verify' | cut -d '$' -f2 | xargs) && ./$VERIFY_CMD ``` -------------------------------- ### Download and Run CDS with Docker Compose Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/ready-to-run/docker-compose/docker-compose.md This snippet demonstrates how to download the docker-compose.yml file, set environment variables, pull the CDS engine image, and start the necessary services for a local CDS test environment. It includes commands for initializing the database, migrating, preparing the configuration, and starting the API. ```bash $ mkdir /tmp/cdstest && cd /tmp/cdstest $ curl https://raw.githubusercontent.com/ovh/cds/{{< param "version" "master" >}}/docker-compose.yml -o docker-compose.yml $ export HOSTNAME=$(hostname) $ export CDS_DOCKER_IMAGE=ovhcom/cds-engine:{{< param "version" "latest" >}} # Get the latest version $ docker pull ovhcom/cds-engine:{{< param "version" "latest" >}} # Create PostgreSQL database, redis and elasticsearch $ docker-compose up -d cds-db cds-cache elasticsearch dockerhost # check if database is up, the logs must contain "LOG: database system is ready to accept connections" $ docker-compose logs| grep 'database system is ready to accept connections' # you should have this line after few seconds: cds-db_1 | LOG: database system is ready to accept connections $ docker-compose up cds-db-init $ docker-compose up cds-migrate # You should have this log: "cdstest_cds-migrate_1 exited with code 0" # prepare initial configuration. $ docker-compose up cds-prepare # run API $ docker-compose up -d cds-api # the INIT_TOKEN variable will be used by cdsctl to create first admin user $ TOKEN_CMD=$(docker logs $(docker-compose ps -q cds-prepare) | grep INIT_TOKEN) && $TOKEN_CMD # if you have this error: "command too long: export INIT_TOKEN=....", # you can manually execute the command "export INIT_TOKEN=...." ``` -------------------------------- ### Install PostgreSQL Client and Query Database Source: https://github.com/ovh/cds/blob/master/docs/content/docs/tutorials/service-requirement-pg.md A bash script that updates package lists, installs the PostgreSQL client, and then uses `psql` to connect to a PostgreSQL service running on `mypg` and execute a query. It requires `postgresql-client` to be installed and uses environment variables for authentication. ```bash #!/bin/bash set -ex apt-get update apt-get install -y postgresql-client PGPASSWORD=mypassword psql -U myuser -h mypg < No worker") } else { fmt.Println("Current Workers:") for _, w := range workers { fmt.Printf("> %s\n", w.Name) } } } ``` -------------------------------- ### Install Docker and Docker Compose on Debian VM (Bash) Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/ready-to-run/docker-compose/full-example.md Installs Docker CE, containerd.io, and a specific version of Docker Compose on a Debian VM. It also configures user permissions for Docker and updates the hosts file. Assumes SSH access to the VM. ```bash # get server public IP openstack server list # connect to the vm with ssh debian@ip-of-your-virtual-machine # go to root sudo su # then install docker apt-get update && \ apt-get install -y apt-transport-https ca-certificates software-properties-common curl git netcat make binutils bzip2 gnupg haproxy telnet htop && \ curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - && \ add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" && \ apt-get -y update && \ apt-get -y upgrade && \ apt-get install -y --allow-unauthenticated docker-ce docker-ce-cli containerd.io && \ curl -L https://github.com/docker/compose/releases/download/1.14.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose && \ chmod +x /usr/local/bin/docker-compose && \ usermod -aG docker debian && \ echo "127.0.0.11 cdsdemo cdsdemo" >> /etc/hosts ``` -------------------------------- ### Start Development Server (npm) Source: https://github.com/ovh/cds/blob/master/ui/README.md Launches a local development server for the CDS UI. The app automatically reloads on source file changes. ```bash npm start ``` -------------------------------- ### Start CDS API with Consul Configuration Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/configuration.md Starts the CDS API server by fetching its configuration from Consul KV. Requires Consul to be running and accessible. ```bash $PATH_TO_CDS/engine start api --remote-config localhost:8500 --remote-config-key cds/config.api.toml ``` -------------------------------- ### Hugo Configuration Example Source: https://github.com/ovh/cds/blob/master/docs/layouts/shortcodes/matrix.html This snippet shows a basic Hugo configuration using a Go template. It initializes a configuration object with a version and demonstrates how to retrieve parameters like 'linkMore' and 'title'. ```Go Template {{ $\_hugo\_config := `{ \"version\": 1 }` }} {{- $linkMore := $.Get \"linkMore\" | default \"\" -}} {{- $title := $.Get \"title\" | default \"\" -}} {{ if $title }} {{ $title}} ----------- {{ end }} ``` -------------------------------- ### Deploying CDS Services with Docker Compose Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/ready-to-run/docker-compose/full-example.md This snippet shows commands to manage the deployment of CDS services (api, ui, etc.) using docker-compose. It includes starting, stopping, removing, and updating services, along with setting environment variables for configuration. ```bash export CDS_EDIT_CONFIG="api.url.api=https://${CDS_DOMAIN_NAME}/cdsapi api.url.ui=https://${CDS_DOMAIN_NAME}" docker-compose up cds-edit-config docker-compose stop cds-api docker-compose rm -f cds-api docker-compose up -d cds-api sleep 3 docker-compose up -d cds-ui cds-cdn cds-hooks cds-elasticsearch cds-hatchery-swarm cds-vcs cds-repositories sleep 5 ``` -------------------------------- ### Start CDS API with Local Configuration Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/configuration.md Starts the CDS API server using a local TOML configuration file. This is the standard way to run CDS in a development or self-hosted environment. ```bash $PATH_TO_CDS/engine start api --config my_conf_file.toml ``` -------------------------------- ### Start Kubernetes Hatchery Source: https://github.com/ovh/cds/blob/master/docs/content/docs/integrations/kubernetes/kubernetes_compute.md Starts the Kubernetes hatchery service using the 'engine' command. Requires a configuration file (e.g., config.toml) which should contain the generated API token. ```bash engine start hatchery:kubernetes --config config.toml ``` -------------------------------- ### Start CDS Local Hatchery Source: https://github.com/ovh/cds/blob/master/docs/content/docs/components/hatchery/local.md Starts the CDS local hatchery using the `engine` command. This command requires a configuration file (e.g., `config.toml`) to be specified, which should contain the generated API token. ```bash engine start hatchery:local --config config.toml ``` -------------------------------- ### Implementing Hatchery Interface for vSphere Source: https://github.com/ovh/cds/blob/master/docs/content/development/contribute/hatchery.md Demonstrates the implementation of the Hatchery interface required for vSphere integration. This includes methods like Init, ID, ModelType, Hatchery, Client, NeedRegistration, WorkersStartedByModel, and WorkersStarted. ```go package vsphere import ( "github.com/ovh/cds/sdk" "github.com/ovh/cds/sdk/hatchery" ) // HatcheryVSphere implements the hatchery.Interface for vSphere. type HatcheryVSphere struct { hatchery.Hatchery } // Init initializes the vSphere hatchery. func (h *HatcheryVSphere) Init(cfg hatchery.CommonConfiguration) error { // Initialization logic here return nil } // ID returns the hatchery ID. func (h *HatcheryVSphere) ID() int { // Return hatchery ID return 0 } // ModelType returns the hatchery model type. func (h *HatcheryVSphere) ModelType() string { return sdk.VSphere } // Hatchery returns the hatchery struct. func (h *HatcheryVSphere) Hatchery() interface{} { return h } // Client returns the CDS SDK client. func (h *HatcheryVSphere) Client() interface{} { // Return CDS SDK client return nil } // NeedRegistration checks if registration is needed for a worker model. func (h *HatcheryVSphere) NeedRegistration(workerModel *sdk.Model) bool { // Check if registration is needed return false } // WorkersStartedByModel returns workers started by a specific model. func (h *HatcheryVSphere) WorkersStartedByModel(model *sdk.Model) ([]string, error) { // Return list of worker names return nil, nil } // WorkersStarted returns all workers that have started. func (h *HatcheryVSphere) WorkersStarted() ([]string, error) { // Return list of all worker names return nil, nil } ``` -------------------------------- ### Execute CDS Reinstallation Script Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/ready-to-run/docker-compose/full-example.md This command executes the 'boot.sh' script, which is assumed to handle the reinstallation and setup of CDS after the previous cleanup steps. This script is essential for bringing up a fresh CDS environment. ```shell # run boot.sh file ./boot.sh ``` -------------------------------- ### Export OpenStack Variables and Create VM (Bash) Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/ready-to-run/docker-compose/full-example.md Sets environment variables for OpenStack authentication and then creates a virtual machine instance named 'cdsdemo' using the 'openstack server create' command. Requires OpenStack client to be installed and configured. ```bash export OS_AUTH_URL=https://auth.cloud.ovh.net/v3/ export OS_IDENTITY_API_VERSION=3 export OS_TENANT_ID=your-tenant-id export OS_TENANT_NAME="your-tenant-name" export OS_USERNAME="your-openstack-username" export OS_PASSWORD="your-openstack-password" export OS_REGION_NAME="opentack-region" # create virtual machine. openstack server create --flavor b2-15-flex --image "Debian 10" --key-name="your-key-name" --nic net-id=Ext-Net cdsdemo ``` -------------------------------- ### List Workers, Users, and Workflow Runs with Golang SDK Source: https://github.com/ovh/cds/blob/master/docs/content/development/sdk/golang.md Shows examples of using the initialized CDS client to perform common read operations such as listing workers, users, and workflow runs. ```go // list workers workers, err := client.WorkerList() // list users users, err := client.UserList() // list workflow runs runs, err := client.WorkflowRunList(...) ``` -------------------------------- ### CDS Pipeline Configuration Example Source: https://github.com/ovh/cds/blob/master/docs/content/docs/concepts/files/pipeline-syntax.md A complete CDS pipeline configuration file demonstrating a two-stage continuous delivery pipeline with compile, test, and package jobs. It includes details on parameters, stages, jobs, steps, and requirements. ```yaml version: v1.0 name: build parameters: param_name: type: string default: default_value stages: - Compile - Package jobs: - job: Build UI stage: Compile steps: - gitClone: branch: '{{.git.branch}}' commit: '{{.git.hash}}' directory: cds url: '{{.git.url}}' - script: - echo {{.cds.pip.param_name}} - cd cds/ui - npm set registry https://registry.npmjs.org - npm install - ng build -prod --aot - tar cfz ui.tar.gz dist - artifactUpload: path: cds/ui/ui.tar.gz tag: '{{.cds.version}}' requirements: - binary: git - memory: "1024" - model: Node8.9.1 - job: Test UI stage: Compile enabled: false requirements: - binary: git - memory: "1024" - model: Node8.9.1 steps: - gitClone: branch: '{{.cdsbuildgitbranch}}' commit: '{{.git.hash}}' directory: cds password: "" privateKey: "" url: '{{.cds.app.repo}}' user: "" - script: - export CHROME_BIN=chromium - npm set registry https://registry.npmjs.org - cd cds/ui - npm install - npm test - jUnitReport: ./cds/ui/tests/**/results.xml - job: Package UI stage: Package requirements: - binary: docker steps: - artifactDownload: path: . - CDS_DockerPackage: dockerfileDirectory: . imageName: ovh/cds-ui imageTag: '{{.cds.version}}' ``` -------------------------------- ### Signup and Verify User with cdsctl Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/ready-to-run/from-binaries.md Initiates a user signup using `cdsctl` and demonstrates how to obtain and use an initialization token from CDS API logs for verification. ```bash export INIT_TOKEN=`./cds-engine config init-token --config conf.toml` ./cdsctl signup --api-url http://localhost:8081 --email admin@localhost.local --username admin --fullname admin # If email service is not configured, get the verification command from API logs: # cd $HOME/cds # ./cdsctl signup verify --api-url ... # Get this command from the API Logs ``` -------------------------------- ### Login to CDS using cdsctl Source: https://github.com/ovh/cds/blob/master/docs/content/docs/tutorials/init_workflow_with_cdsctl.md This command logs you into your CDS instance using the cdsctl command-line tool. Ensure you have cdsctl installed and replace placeholders with your CDS API URL and repository path. ```bash cd cdsctl login -H ``` -------------------------------- ### Install and use SSH key with worker CLI Source: https://github.com/ovh/cds/blob/master/docs/actions/builtin-script.part.md This example shows how to install an SSH key using the 'worker key install' command and then use the private key with an SSH command. The path to the private key is captured and used as an argument for the ssh command. ```bash PKEY=`worker key install proj-mykey` ssh -i $PKEY myuser@myhost echo "test" #PKEY only works with SSH key ``` -------------------------------- ### Verifying CDS Service Status with docker ps Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/ready-to-run/docker-compose/full-example.md This command lists all running Docker containers, providing details about their image, command, status, ports, and names, which is useful for confirming that all CDS services have started correctly. ```bash $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 02b60d3f98c0 ovhcom/cds-engine:latest "sh -c '/app/cds-eng… 33 seconds ago Up 32 seconds (healthy) 0.0.0.0:8080->8080/tcp debian_cds-ui_1 ae8e87c60e2b ovhcom/cds-engine:latest "sh -c '/app/cds-eng… 35 seconds ago Up 33 seconds (healthy) debian_cds-vcs_1 c2b8852e487a ovhcom/cds-engine:latest "sh -c '/app/cds-eng… 35 seconds ago Up 33 seconds (healthy) 127.0.0.1:8083->8083/tcp debian_cds-hooks_1 fe2fcbee96aa ovhcom/cds-engine:latest "sh -c '/app/cds-eng… 35 seconds ago Up 33 seconds (healthy) debian_cds-repositories_1 f2eb7b8c4329 ovhcom/cds-engine:latest "sh -c '/app/cds-eng… 35 seconds ago Up 33 seconds (healthy) debian_cds-elasticsearch_1 22dc66a1b2a2 ovhcom/cds-engine:latest "sh -c '/app/cds-eng… 35 seconds ago Up 33 seconds (healthy) debian_cds-hatchery-swarm_1 958ab1703f16 ovhcom/cds-engine:latest "sh -c '/app/cds-eng… 39 seconds ago Up 39 seconds (healthy) 0.0.0.0:8081->8081/tcp debian_cds-api_1 9223395500ab postgres:14.0 "docker-entrypoint.s… 2 minutes ago Up About a minute 5432/tcp debian_cds-db_1 c9b58ce83003 docker.elastic.co/elasticsearch/elasticsearch:6.7.2 "/usr/local/bin/dock… 2 minutes ago Up About a minute 9200/tcp, 9300/tcp debian_elasticsearch_1 08cfe15c3e2c bobrik/socat "socat TCP4-LISTEN:2… 2 minutes ago Up About a minute 127.0.0.1:2375->2375/tcp debian_dockerhost_1 fc2ac075c000 redis:alpine "docker-entrypoint.s… 2 minutes ago Up About a minute 6379/tcp debian_cds-cache_1 ``` -------------------------------- ### Start CDN Service and Migration Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/upgrade/migrate_0.48.md Initiates the CDN service and the log migration process. The `migrate` command processes activated projects. The status of the migration can be monitored using `cdsctl admin cdn status`. ```sh $ cdsctl admin cdn migrate ``` ```sh $ cdsctl admin cdn status ``` -------------------------------- ### Configure SSL with Certbot and HAProxy (Bash) Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/ready-to-run/docker-compose/full-example.md Obtains a standalone SSL certificate using Certbot for a specified domain and then concatenates the certificate and private key into a single PEM file for HAProxy. Requires Certbot and HAProxy to be installed. ```bash export DOMAIN='your-cdsdemo.domain' export YOUR_MAIL='admin@localhost.local' apt-get install certbot certbot certonly --standalone -d ${DOMAIN} --non-interactive --agree-tos --email ${YOUR_MAIL} --http-01-port=80 # then generate pem file mkdir /etc/haproxy/certs/ cat /etc/letsencrypt/live/$DOMAIN/fullchain.pem /etc/letsencrypt/live/$DOMAIN/privkey.pem > /etc/haproxy/certs/$DOMAIN.pem chmod -R go-rwx /etc/haproxy/certs ``` -------------------------------- ### Configure Max Attempts for Spawning Worker (TOML) Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/upgrade/migrate_0.50.md Configures the maximum number of attempts a hatchery can make to start a job before failing. An example is provided for `hatchery.local`. ```toml [hatchery.local.commonConfiguration.provision] # Maximum attempts to start a same job. -1 to disable failing jobs when too many attempts # maxAttemptsNumberBeforeFailure = 5 ``` -------------------------------- ### Install Node.js on macOS (Bash) Source: https://github.com/ovh/cds/blob/master/docs/content/development/contribute/development.md Instructions for downloading and setting up a specific version of Node.js on macOS for CDS development. It involves using curl to download the tarball and extracting it. ```bash #!/bin/bash # Example with version 16.4.2 on macOS: curl -O https://nodejs.org/dist/v16.4.2/node-v16.4.2-darwin-x64.tar.gz tar xzf node-v16.4.2-darwin-x64.tar.gz # directory node-v16.4.2-darwin-x64 is created # You should add node-v16.4.2-darwin-x64/bin to your PATH ``` -------------------------------- ### vSphere Worker Model Configuration (YAML) Source: https://github.com/ovh/cds/blob/master/docs/content/docs/tutorials/worker_model-vsphere.md This YAML defines a vSphere worker model named 'testvsphere'. It includes setup for the operating system (Debian 8), Docker installation, and CDS worker binary download and execution. The 'pre_cmd' script prepares the environment, including installing necessary packages and Docker, and fetching the CDS worker. The 'cmd' specifies how to run the worker, and 'post_cmd' shuts down the VM. ```yaml name: testvsphere type: vsphere description: "my worker model" group: shared.infra image: debian8 pre_cmd: | #!/bin/bash set +e export CDS_FROM_WORKER_IMAGE={{.FromWorkerImage}} export CDS_API={{.API}} export CDS_TOKEN={{.Token}} export CDS_NAME={{.Name}} export CDS_MODEL={{.Model}} export CDS_HATCHERY={{.Hatchery}} export CDS_HATCHERY_NAME={{.HatcheryName}} export CDS_BOOKED_WORKFLOW_JOB_ID={{.WorkflowJobID}} export CDS_INSECURE={{.HTTPInsecure}} # Basic build binaries cd $HOME apt-get -y --force-yes update >> /tmp/user_data 2>&1 apt-get -y --force-yes install curl git >> /tmp/user_data 2>&1 apt-get -y --force-yes install binutils >> /tmp/user_data 2>&1 # Docker installation (FOR DEBIAN) if [[ "x{{.FromWorkerImage}}" = "xtrue" ]]; then echo "$(date) - CDS_FROM_WORKER_IMAGE == true - no install docker required " else # Install Docker apt-get install -y --force-yes apt-transport-https ca-certificates >> /tmp/user_data 2>&1 apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D mkdir -p /etc/apt/sources.list.d sh -c "echo deb https://apt.dockerproject.org/repo debian-jessie main > /etc/apt/sources.list.d/docker.list" apt-get -y --force-yes update >> /tmp/user_data 2>&1 apt-cache policy docker-engine >> /tmp/user_data 2>&1 apt-get install -y --force-yes docker-engine >> /tmp/user_data 2>&1 service docker start >> /tmp/user_data 2>&1 # Non-root access groupadd docker >> /tmp/user_data 2>&1 gpasswd -a ${USER} docker >> /tmp/user_data 2>&1 service docker restart >> /tmp/user_data 2>&1 fi; curl -L "{{.API}}/download/worker/linux/$(uname -m)" -o worker --retry 10 --retry-max-time 120 -C - >> /tmp/user_data 2>&1 chmod +x worker cmd: "PATH=$PATH ./worker" post_cmd: sudo shutdown -h now ``` -------------------------------- ### Import Workflow Template using cdsctl Source: https://github.com/ovh/cds/blob/master/contrib/workflow-templates/demo-usage-service-postgresql/README.md This command imports the 'demo-usage-service-postgresql' workflow template into your CDS instance. Ensure you have the 'cdsctl' command-line tool installed and configured. ```sh cdsctl template push https://raw.githubusercontent.com/ovh/cds/master/contrib/workflow-templates/demo-usage-service-postgresql/demo-usage-service-postgresql.yml ``` -------------------------------- ### SonarScanner CDS Action with Parameters and Plugins Source: https://github.com/ovh/cds/blob/master/docs/content/docs/concepts/files/action-syntax.md Configures a CDS action for running SonarQube analysis using the SonarScanner CLI. It includes numerous parameters with default values, advanced settings, and utilizes 'plugin-download' and 'plugin-archive' for managing the SonarScanner installation. ```yml version: v1.0 name: CDS_SonarScanner description: Run Sonar analysis. You must have a file sonar-project.properties in your source directory. parameters: sonar-project.properties: type: text default: |- sonar.projectKey={{.cds.application}} sonar.projectName={{.cds.application}} sonar.projectVersion={{.git.hash}} sonar.sources=. sonar.exclusions=*_test.go,**/vendor/** sonar.tests=. sonar.test.inclusions=*_test.go sonar.test.exclusions=**/vendor/** description: sonar-project.properties file sonarBranch: type: string default: '{{.git.branch}}' description: The Sonar branch (e.g. master) sonarDownloadURL: type: string default: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-{{.sonarVersion}}-linux.zip description: The download URL of Sonar CLI advanced: true sonarPassword: type: string default: '{{.cds.proj.sonarPassword}}' description: The Sonar server's password advanced: true sonarURL: type: string default: '{{.cds.proj.sonarURL}}' description: The URL of the Sonar server advanced: true sonarUsername: type: string default: '{{.cds.proj.sonarUsername}}' description: The Sonar server's username advanced: true sonarVersion: type: string default: 3.2.0.1227 description: SonarScanner's version to use advanced: true workspace: type: string default: '{{.cds.workspace}}' description: The directory where your project is (e.g. /go/src/github.com/ovh/cds) requirements: - binary: bash - plugin: plugin-archive - plugin: plugin-download steps: - name: Initialization script: - '#!/bin/bash' - set -x - '# Installation' - mkdir -p {{.workspace}}/opt - plugin-download: filepath: '{{.workspace}}/opt/sonar-scanner-cli-{{.sonarVersion}}-linux.zip' url: '{{.sonarDownloadURL}}' - plugin-archive: action: uncompress destination: '{{.workspace}}/opt/' source: '{{.workspace}}/opt/sonar-scanner-cli-{{.sonarVersion}}-linux.zip' - script: - '#!/bin/bash' - set -x - "" - '# Installation' - ln -s {{.workspace}}/opt/sonar-scanner-{{.sonarVersion}}-linux {{.workspace}}/opt/sonar - export PATH="${PATH}:{{.workspace}}/opt/sonar/bin" - "" - '# Runtime' - export SONAR_SCANNER_OPTS "-Xmx1024m" - cd {{.workspace}} - cat < sonar-project.properties - '{{.sonar-project.properties}}' - EOF - "" - sonar-scanner -Dsonar.host.url={{.sonarURL}} -Dsonar.login={{.sonarUsername}} -Dsonar.password={{.sonarPassword}} -Dsonar.branch={{.sonarBranch}} -Dsonar.scm.disabled=true ``` -------------------------------- ### Lua Script with Regular Expression Matching Source: https://github.com/ovh/cds/blob/master/docs/content/docs/concepts/workflow/run-conditions.md This Lua script example shows how to use regular expressions for advanced run conditions in OVH CDS. It demonstrates importing the 're' module and using the `re.match` function to check if a variable (`cds_application`) starts with a specific pattern. ```lua -- this example checks if current application beginning with 'abc' -- don't forget to import the regular expression module local re = require("re") return re.match(cds_application, "abc.*") == cds_application ``` -------------------------------- ### Generate CDS Documentation with Hugo Source: https://github.com/ovh/cds/blob/master/docs/content/development/contribute/documentation.md This snippet demonstrates how to generate documentation for CDS components using Hugo. It requires cloning the CDS repository, ensuring Hugo is installed and in the PATH, and then executing specific make targets and Hugo commands. ```bash cd ${CDS_SOURCES} make install GEN_PATH=${CDS_SOURCES}/docs/content/docs/components make doc cd ${CDS_SOURCES}/docs hugo server ``` -------------------------------- ### Generate Migrate Service Configuration Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/upgrade/migrate_0.48.md Generates an example configuration for the CDS migrate service, which now manages SQL migrations for both API and CDN databases. This command helps in updating existing configurations to the new format. ```sh $ engine config new migrate ``` -------------------------------- ### Import CDS Demo Workflow Skeleton Template Source: https://github.com/ovh/cds/blob/master/contrib/workflow-templates/demo-workflow-skeleton/README.md Imports the demo workflow skeleton template from GitHub using the cdsctl command-line interface. Ensure you have CDS Administrator privileges and cdsctl installed. ```sh cdsctl template push https://raw.githubusercontent.com/ovh/cds/master/contrib/workflow-templates/demo-workflow-skeleton/demo-workflow-skeleton.yml ``` -------------------------------- ### Creating and Running a CDS Project and Workflow Source: https://github.com/ovh/cds/blob/master/docs/content/hosting/ready-to-run/docker-compose/full-example.md This sequence of commands uses cdsctl to create a new project named 'DEMO', apply a workflow template to it, and then trigger the execution of that workflow. ```bash ./cdsctl project create DEMO FirstProject ./cdsctl template apply DEMO MyFirstWorkflow shared.infra/demo-workflow-hello-world --force --import-push --quiet ./cdsctl workflow run DEMO MyFirstWorkflow ```