How to use the command 'fly' (with examples)

How to use the command 'fly' (with examples)

The fly command-line tool is used for interacting with Concourse CI. It allows users to manage pipelines, authenticate with targets, and perform other related tasks. In this article, we will explore different use cases of the fly command with examples.

Use case 1: Authenticate with and save Concourse target

Code:

fly --target target_name login --team-name team_name -c https://ci.example.com

Motivation: Authenticating with a Concourse target is necessary to perform any actions on the target, such as managing pipelines. By saving the target, you can easily reference it in subsequent commands without specifying the target details again.

Explanation:

  • --target target_name: Specifies the name of the target to authenticate with.
  • login: Indicates that we want to authenticate with the target.
  • --team-name team_name: Specifies the name of the team within the target.
  • -c https://ci.example.com: Specifies the Concourse web URL.

Example output:

logging in to team 'team_name'

target saved

Use case 2: List targets

Code:

fly targets

Motivation: Listing targets can be useful to see the available targets and their respective details. It allows you to verify the saved targets and switch between them if needed.

Explanation:

  • targets: Lists all the saved targets.

Example output:

name        url
target1     https://concourse1.example.com
target2     https://concourse2.example.com

Use case 3: List pipelines

Code:

fly -t target_name pipelines

Motivation: Listing pipelines gives you an overview of all the pipelines configured on a specific target. It helps you quickly identify the pipelines you are interested in and perform related actions.

Explanation:

  • -t target_name: Specifies the name of the target to interact with.
  • pipelines: Lists all the pipelines configured on the given target.

Example output:

name        paused  public
pipeline1   true    false
pipeline2   false   true

Use case 4: Upload or update a pipeline

Code:

fly -t target_name set-pipeline --config pipeline.yml --pipeline pipeline_name

Motivation: Uploading or updating a pipeline allows you to define or modify the configuration of the pipeline. This is useful when making changes to the CI/CD process, introducing new tests, or updating the deployment strategy.

Explanation:

  • -t target_name: Specifies the name of the target to interact with.
  • set-pipeline: Indicates that we want to upload or update a pipeline.
  • --config pipeline.yml: Specifies the configuration file for the pipeline.
  • --pipeline pipeline_name: Specifies the name of the pipeline.

Example output:

uploading pipeline...
pipeline created!

Use case 5: Unpause pipeline

Code:

fly -t target_name unpause-pipeline --pipeline pipeline_name

Motivation: Unpausing a pipeline is necessary to resume the execution of the pipeline. If a pipeline is paused, the resources associated with the pipeline will no longer trigger new builds or deployments.

Explanation:

  • -t target_name: Specifies the name of the target to interact with.
  • unpause-pipeline: Indicates that we want to unpause a pipeline.
  • --pipeline pipeline_name: Specifies the name of the pipeline to unpause.

Example output:

unpaused 'pipeline_name'

Use case 6: Show pipeline configuration

Code:

fly -t target_name get-pipeline --pipeline pipeline_name

Motivation: Showing the pipeline configuration helps you understand how the pipeline is defined and what resources, jobs, and tasks it consists of. It allows you to review the pipeline configuration before making any changes.

Explanation:

  • -t target_name: Specifies the name of the target to interact with.
  • get-pipeline: Indicates that we want to retrieve the configuration of a pipeline.
  • --pipeline pipeline_name: Specifies the name of the pipeline.

Example output:

resources:
  - name: resource1
    type: git
    source:
      uri: https://github.com/repository1.git
      branch: master

jobs:
  - name: job1
    plan:
      - get: resource1
      - task: build
        file: tasks/build.yml

Use case 7: Update local copy of fly

Code:

fly -t target_name sync

Motivation: Updating the local copy of the fly command ensures that you have the latest version of the tool. This is important to have access to new features or bug fixes introduced in newer versions of Concourse CI.

Explanation:

  • -t target_name: Specifies the name of the target to interact with.
  • sync: Updates the local copy of fly.

Example output:

syncing from team 'main'

fetching version <latest-version-of-fly>
sync succeeded

Use case 8: Destroy pipeline

Code:

fly -t target_name destroy-pipeline --pipeline pipeline_name

Motivation: Destroying a pipeline removes it from the Concourse CI target. This can be useful when a pipeline is no longer needed or needs to be recreated from scratch.

Explanation:

  • -t target_name: Specifies the name of the target to interact with.
  • destroy-pipeline: Indicates that we want to destroy a pipeline.
  • --pipeline pipeline_name: Specifies the name of the pipeline to destroy.

Example output:

destroying pipeline...
pipeline destroyed!

Conclusion:

The fly command is a powerful tool that allows users to manage pipelines and interact with Concourse CI targets efficiently. By understanding its various use cases and the associated command arguments, users can perform tasks such as authentication, pipeline management, and configuration exploration effectively.

Related Posts

How to use the command 'fisher' (with examples)

How to use the command 'fisher' (with examples)

Fisher is a fish-shell plugin manager that allows users to easily install, update, and remove plugins for their fish shell.

Read More
How to use the command "sg" (with examples)

How to use the command "sg" (with examples)

The sg command is a versatile tool used for code structural search, lint, and rewriting.

Read More
How to use the command `mediamtx` (with examples)

How to use the command `mediamtx` (with examples)

This article provides examples of how to use the mediamtx command, which is a real-time media server and proxy.

Read More