Adding a Shell Stage

Shell stage allows you to run custom commands in the deployment pipeline. This stage can be added at any point in the deployment pipeline.

You must prepare a command specification YAML file containing all the steps that you want to run during the deployment. The command spec is run on a container instance host in the selected compartment and subnet in your tenancy. You have the option to choose different instance configuration before the deployment. See Shell Container Image Runtime Details. When you run the deployment pipeline, you can see the execution of the steps defined in the command spec in the pipeline output and logs. For syntax and example of the command spec, see Command Specification.

Key Benefits of Adding a Shell Stage

  • Automate deployments to OCI platforms such as service mesh and container instances using OCI CLI and other pre-installed tools. See Shell Container Image Runtime Details.

    OCI CLI is pre-authenticated to use the pipeline resource principal to access OCI resources.

  • Run a database schema migration using command line tools such as Oracle SQL Developer Command Line (SQLcl).
  • Use any pipeline parameters by referencing them in the spec. Also replace parameters and variables during the deployment run.
  • Perform integration tests on artifacts before deploying to production.
  • Customize the DevOps workflow. For example, you can wait for some resources to be ready before the pipeline deploys additional resources.

Before you create the pipeline, you must have a DevOps project and a command specification artifact. Artifacts can be defined inline or located in the Artifact Registry.

    1. Open the navigation menu and click Developer Services. Under DevOps, click Projects.
    2. Select a project, and click Create pipeline.
    3. Enter a name and description for the pipeline. Adding a description is optional.
    4. For Pipeline type, select Create a deployment pipeline.
    5. Click Create pipeline.
    6. To add a stage to the new pipeline, click the + icon and select Add stage.
    7. Select Integrations - Shell, and then click Next.
    8. Enter a name and optional description for the stage.
    9. Click Select Artifact, and then select available command specification artifact to deploy.
    10. Select the compartment to create the container instance where the spec is run.

      You can retain the default compartment that is displayed.

    11. Select an availability domain.
    12. Select a shape for the container instance from the given options. You can also select the number of OCPUs and amount of memory for the instance.

      You’re charged for the container instance (based on the selected compute shape) during the deployment based on the pricing model for container instances. See Container Instances Pricing.

      1. Select a Virtual Cloud Network (VCN) and regional subnet in the tenancy. You can select public or private subnet.

        When the command is run, a virtual network interface card (VNIC) is created in the selected subnet. Ensure that the subnet has a network path to the OCI Container Registry. If any command needs to manage other OCI resources, then this must also be handled to ensure that both the network path and policy are set up correctly.

      2. (Optional) For restricting access to your VCN, you can select Network security groups (NSGs) in your VCNs.
      3. (Optional) Enter a timeout value (in seconds) for the stage.
    13. (Optional) To add tags to the pipeline, click Show tagging options. Tagging is a metadata system that lets you organize and track the resources in your tenancy.

      If you have permissions to create a resource, you also have permissions to add free-form tags to it.

      To add a defined tag, you must have permissions to use the tag namespace.

      For more information, see Resource Tags.

    14. To add the stage to the pipeline, click Add.

      A stage preview provides a snapshot of the configuration.

    Add more stages sequentially or in parallel to the pipeline, as needed. To deploy the build output to the target environment, run the deployment pipeline.

    To automatically trigger a deployment from the build pipeline, you can add a Trigger Deployment stage to the build pipeline.

  • To create a deployment pipeline, run the create command:

    oci devops deploy-pipeline create --project-id

    To create a Shell stage, run the create-shell-stage command:

    oci devops deploy-stage create-shell-stage

    Required parameters for the create-shell-stage command:

    • --pipeline-id
    • --stage-predecessor-collection
    • --command-spec-artifact-id
    • --container-config

    To get all the commands for deploy-pipeline and deploy-stage:

    oci devops deploy-pipeline -h
    oci devops deploy-stage -h

    To get help for the create-shell-stage command:

    oci devops deploy-stage create-shell-stage -h
  • To create a deployment pipeline, use the CreateDeployPipeline operation.

    To add a Shell stage to the pipeline, use the CreateDeployStage operation. For deployStageType attribute, specify the SHELL value.