Sending Notifications from Pipelines

JFrog Pipelines Documentation

ft:sourceType
Paligo

You can send notifications through an external service such as Slack or email when a step starts, succeeds, fails or completes. This can be configured by using the utility function send_notification in the onStart, onSuccess, onFailure, onComplete sections of your step definition.

JFrog Pipelines connects your notification services through Integrations for those services. This provides Pipelines with the credentials needed to send notifications on your behalf, and keeps thissensitive information abstracted from your Pipeline source files and hidden from other users.

This page explains how to send a Slack notification and an email notification. Similarly, you can use the utility function send_notification to send notifications through other integrations, such as Airbrake, Jira, or NewRelic.

Sending Notifications to a Slack Channel or User

You can send any text to a Slack channel or user, including color settings and an identifying icon. You can also send JSON payloads for the Slack Web API.

  1. Add a Slack integration

    Follow instructions to create a Slack integration. You will need to set up permissions on the Slack account to enable incoming webhooks and create an incoming webhook URL to provide this integration. Write down the friendly name that you gave your integration.

  2. Update YAML to send notifications

    You can now update your Pipeline source file.

    • Specify an integrationssection with the friendly name of your Slack integration.

    • In the executionsection, use thesend_notificationutility function as shown below.

Sending notifications

pipelines:
  - name: pipe1
    steps:
      - name: test_step_1
        type: Bash
        configuration:
          integrations:
                        - name: notifySlack       # replace with friendly name of your Slack integration
                execution:
                  onStart:
                    - send_notification notifySlack --text "starting test_step_1" --recipient "#myChannel" 
          onExecute:
            - #test commands
            - send_notification notifySlack --text "in onexecute, past test commands" --recipient "@user5"
                  onSuccess:
                    - # can use send_notification command here
                  onFailure:
                    - # can use send_notification command here
                  onComplete:
                    - # can use send_notification command here

You can customize additional things like username, pretext, text, payload, and more as shown in the usage description for send_notification.

Sending Notifications to Email

You can send text to an email address through SMTP.

  1. Add an SMTP Credentials integration

    Follow instructions to create an SMTP Credentials integration. You will need to provide email user credentials to send an email message.

  2. Update YAML to send notifications

    You can now update your Pipeline source file.

    • Specify an integrationssection with the friendly name of your SMTP Credentials integration.

    • In the executionsection, use thesend_notificationutility function as shown below.

Sending notifications

pipelines:
  - name: pipe1
    steps:
      - name: test_step_1
        type: Bash
        configuration:
          integrations:
                        - name: notifySMTP       # replace with friendly name of your SMTP Credentials integration
                execution:
                  onSuccess:
                        - send_notification notifySMTP --recipients "buildalerts@mycompany.com" --subject "Build Succeeded" --body "built docker image 112.32.101.173:8081/docker-local/demo:$PIPELINE_NAME.$RUN_NUMBER"
                  onFailure:
                        - send_notification notifySMTP --recipients "buildalerts@mycompany.com" --subject "Build Failed" --body "FAILED: docker image 112.32.101.173:8081/docker-local/demo:$PIPELINE_NAME.$RUN_NUMBER"
                  onComplete:
                    - # can use send_notification command here

You can also add attachments, such as log files, as described in the usage description for send_notification.