Goal
To learn how to use the CLI for getting more information on a Git integration, also how to modify certain configuration options.
Assumptions
- Access to a project hosted on Upsun
- Your project account has administrator rights
- Knowledge on using the Upsun CLI
Problems
None in particular. This How to is about raising awareness to the usefulness of the CLI tool.
Steps
1. Check what āintegrationā commands are available
upsun list | grep integration integration integration:activity:get View detailed information on a single integration activity integration:activity:list (integration:activities) Get a list of activities for an integration integration:activity:log Display the log for an integration activity integration:add Add an integration to the project integration:delete Delete an integration from a project integration:get View details of an integration integration:list (integrations) View a list of project integration(s) integration:update Update an integration integration:validate Validate an existing integration
2. List the integrations added to your project
upsun integration:list +------------------+--------+-----------------------------------------------------------------------------------------------------+ | ID | Type | Summary | +------------------+--------+-----------------------------------------------------------------------------------------------------+ | <integration id> | github | Repository: ... | | | | Hook URL: https://<region>.platform.sh/api/projects/<project id>/integrations/<integration id>/hook | +------------------+--------+-----------------------------------------------------------------------------------------------------+ View integration details with: upsun integration:get [id] Add a new integration with: upsun integration:add Delete an integration with: upsun integration:delete [id]
3. Get the integration details
upsun integration:get <integration id> +---------------------------------+-------------------------------------------------------------------------------------------+ | Property | Value | +---------------------------------+-------------------------------------------------------------------------------------------+ | id | <integration id> | | type | github | | token | ****** | | repository | ... | | fetch_branches | true | | prune_branches | true | | build_pull_requests | true | | build_pull_requests_post_merge | false | | pull_requests_clone_parent_data | true | | hook_url | https://<region>.platform.sh/api/projects/<project id>/integrations/<integration id>/hook | +---------------------------------+-------------------------------------------------------------------------------------------+
4. Check the options and select which ones to modify
upsun integration:update --help
Command: integration:update
Description: Update an integration
Usage:
upsun integration:update [--type TYPE] [--base-url BASE-URL] [--bitbucket-url BITBUCKET-URL] [--username USERNAME] [--token TOKEN] [--key KEY] [--secret SECRET] [--license-key LICENSE-KEY] [--server-project SERVER-PROJECT] [--repository REPOSITORY] [--build-merge-requests BUILD-MERGE-REQUESTS] [--build-pull-requests BUILD-PULL-REQUESTS] [--build-draft-pull-requests BUILD-DRAFT-PULL-REQUESTS] [--build-pull-requests-post-merge BUILD-PULL-REQUESTS-POST-MERGE] [--build-wip-merge-requests BUILD-WIP-MERGE-REQUESTS] [--merge-requests-clone-parent-data MERGE-REQUESTS-CLONE-PARENT-DATA] [--pull-requests-clone-parent-data PULL-REQUESTS-CLONE-PARENT-DATA] [--resync-pull-requests RESYNC-PULL-REQUESTS] [--fetch-branches FETCH-BRANCHES] [--prune-branches PRUNE-BRANCHES] [--resources-init RESOURCES-INIT] [--url URL] [--shared-key SHARED-KEY] [--file FILE] [--events EVENTS] [--states STATES] [--environments ENVIRONMENTS] [--excluded-environments EXCLUDED-ENVIRONMENTS] [--from-address FROM-ADDRESS] [--recipients RECIPIENTS] [--channel CHANNEL] [--routing-key ROUTING-KEY] [--category CATEGORY] [--index INDEX] [--sourcetype SOURCETYPE] [--protocol PROTOCOL] [--syslog-host SYSLOG-HOST] [--syslog-port SYSLOG-PORT] [--facility FACILITY] [--message-format MESSAGE-FORMAT] [--auth-mode AUTH-MODE] [--auth-token AUTH-TOKEN] [--verify-tls VERIFY-TLS] [--header HEADER] [-p|--project PROJECT] [-W|--no-wait] [--wait] [--] [<id>]
Arguments:
id The ID of the integration to update
Options:
--type=TYPE The integration type ('bitbucket', 'bitbucket_server', 'github', 'gitlab', 'webhook', 'health.email', 'health.pagerduty', 'health.slack', 'health.webhook', 'httplog', 'script', 'newrelic', 'splunk', 'sumologic', 'syslog', 'otlplog')
--base-url=BASE-URL The base URL of the server installation
--bitbucket-url=BITBUCKET-URL The base URL of the Bitbucket Server installation
--username=USERNAME The Bitbucket Server username
--token=TOKEN An authentication or access token for the integration
--key=KEY A Bitbucket OAuth consumer key
--secret=SECRET A Bitbucket OAuth consumer secret
--license-key=LICENSE-KEY The New Relic Logs license key
--server-project=SERVER-PROJECT The project (e.g. 'namespace/repo')
--repository=REPOSITORY The repository to track (e.g. 'owner/repository')
--build-merge-requests=BUILD-MERGE-REQUESTS GitLab: build merge requests as environments [default: true]
--build-pull-requests=BUILD-PULL-REQUESTS Build every pull request as an environment [default: true]
--build-draft-pull-requests=BUILD-DRAFT-PULL-REQUESTS Build draft pull requests [default: true]
--build-pull-requests-post-merge=BUILD-PULL-REQUESTS-POST-MERGE Build pull requests based on their post-merge state [default: false]
--build-wip-merge-requests=BUILD-WIP-MERGE-REQUESTS GitLab: build WIP merge requests [default: true]
--merge-requests-clone-parent-data=MERGE-REQUESTS-CLONE-PARENT-DATA GitLab: clone data for merge requests [default: true]
--pull-requests-clone-parent-data=PULL-REQUESTS-CLONE-PARENT-DATA Clone the parent environment's data for pull requests [default: true]
--resync-pull-requests=RESYNC-PULL-REQUESTS Re-sync pull request environment data on every build [default: false]
--fetch-branches=FETCH-BRANCHES Fetch all branches from the remote (as inactive environments) [default: true]
--prune-branches=PRUNE-BRANCHES Delete branches that do not exist on the remote [default: true]
--resources-init=RESOURCES-INIT The resources to use when initializing a new service ('minimum', 'default', 'manual', 'parent') [default: "parent"]
--url=URL The URL or API endpoint for the integration
--shared-key=SHARED-KEY Webhook: the JWS shared secret key
--file=FILE The name of a local file that contains the script to upload
--events=EVENTS A list of events to act on, e.g. environment.push [default: ["*"]] (multiple values allowed)
--states=STATES A list of states to act on, e.g. pending, in_progress, complete [default: ["complete"]] (multiple values allowed)
--environments=ENVIRONMENTS The environment IDs to include [default: ["*"]] (multiple values allowed)
--excluded-environments=EXCLUDED-ENVIRONMENTS The environment IDs to exclude (multiple values allowed)
--from-address=FROM-ADDRESS [Optional] Custom From address for alert emails
--recipients=RECIPIENTS The recipient email address(es) (multiple values allowed)
--channel=CHANNEL The Slack channel
--routing-key=ROUTING-KEY The PagerDuty routing key
--category=CATEGORY The Sumo Logic category, used for filtering
--index=INDEX The Splunk index
--sourcetype=SOURCETYPE The Splunk event source type
--protocol=PROTOCOL Syslog transport protocol ('tcp', 'udp', 'tls') [default: "tls"]
--syslog-host=SYSLOG-HOST Syslog relay/collector host
--syslog-port=SYSLOG-PORT Syslog relay/collector port
--facility=FACILITY Syslog facility [default: 1]
--message-format=MESSAGE-FORMAT Syslog message format ('rfc3164' or 'rfc5424') [default: "rfc5424"]
--auth-mode=AUTH-MODE Authentication mode ('prefix' or 'structured_data') [default: "prefix"]
--auth-token=AUTH-TOKEN Authentication token
--verify-tls=VERIFY-TLS Whether HTTPS certificate verification should be enabled (recommended) [default: true]
--header=HEADER HTTP header(s) to use in POST requests. Separate names and values with a colon (:). (multiple values allowed)
-p, --project=PROJECT The project ID or URL
-W, --no-wait Do not wait for the operation to complete
--wait Wait for the operation to complete (default)
-h, --help Display this help message
-V, --version Display this application version
-q, --quiet Only print necessary output; suppress other messages and errors. This implies --no-interaction. It is ignored in verbose mode.
-y, --yes Answer "yes" to confirmation questions; accept the default value for other questions; disable interaction
--no-interaction Do not ask any interactive questions; accept default values. Equivalent to using the environment variable: UPSUN_CLI_NO_INTERACTION=1
-v|vv|vvv, --verbose Increase the verbosity of messages
Examples:
Switch on the "fetch branches" option for a specific integration:
upsun integration:update ZXhhbXBsZSB --fetch-branches 1Conclusion
The CLI is a very handy tool for listing information about integrations, also for adding new ones (or modifying those already existing).
Comments
Please sign in to leave a comment.