Invoke Function
This stage invokes an Oracle Cloud Infrastructure (OCI) function. The Invoke Function stage can be used to run code or custom logic in a serverless manner. For example, you can write a function that validates your application in the staging environment and if successful, deploy the application to the production environment.
Before you begin, you must have a deployment pipeline defined and you must create a function that is invoked when the pipeline is run.
- Open the navigation menu and click Developer Services. Under DevOps, click Projects.
- Select a project and a pipeline associated with that project.
- To add the Integrations stage sequentially or in parallel, click the + icon and select Add stage.
- Select Integrations - Invoke Function, and then click Next.
- Enter a name and description for the stage. Adding a description is optional.
- For Environment, select an existing function to invoke.
The read-only Function name field displays the function that is called in the pipeline.
- (Optional) To select and add artifacts to the stage, click Select Artifact.
Select an existing artifact resource from your DevOps project. The artifact must be generic (universal) file type. Parameters in the artifact must be in JSON format and can have placeholders. You must select the Allow parameterization check box when configuring the DevOps artifact resource to substitute the placeholders with the argument value during deployment. For more information, see Configuring Parameters.
Here's an example of the generic artifact content to pass two user-defined parameters and their values:- Parameters:
test_name
,app_version
- Values:
{"test_name":"verify_production", "app_version":"${app_version}"}
- Parameters:
- For Stage run mode, select to run asynchronously or synchronously.
If you select Run asynchronously, the service invokes the function but does not wait for the function to complete. On selecting Run synchronously, the service invokes the function and waits for the function to complete.
- Select to disable or enable validation.
If the validation is enabled, then the service verifies the return value of the function. The return value is a UTF-8 string literal,
true
orfalse
. If the return value istrue
, then the stage is marked as Succeeded, otherwise the stage is marked as Failed.If the validation is disabled, then the service does not verify the return value.
Validation occurs only if you have selected the option "Run synchronously" for stage run mode.
- (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 that resource.
To add a defined tag, you must have permissions to use the tag namespace.
For more information, see Resource Tags.
- To add the Integrations stage to the pipeline, click Add.
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 invoke a function in the pipeline, run the
create-invoke-function-stage
command:oci devops deploy-stage create-invoke-function-stage
Required parameters for the
create-invoke-function-stage
command:--function-environment-id
--is-async
--is-validation-enabled
--pipeline-id
--stage-predecessor-collection
To get all the commands for
deploy-pipeline
anddeploy-stage
:oci devops deploy-pipeline -h
oci devops deploy-stage -h
To get help for the
create-invoke-function-stage
command:oci devops deploy-stage create-invoke-function-stage -h
To invoke a function in the pipeline, use the
CreateDeployStage
operation. FordeployStageType
attribute, specify theINVOKE_FUNCTION
value.