Custom script

3 minute read

A custom script is useful when you want to execute another specific step after or before a deploy step in your pipeline. You can use Shell script, Maven, ANT, or Gradle. You can use Shell script to enhance your team’s business logic to your build pipeline. You can run any script on a Jenkins instance. You can configure a custom script to execute a build step or run another Test configuration such as a Regression test or Performance test from a pipeline, instead of doing it manually.

Create custom script

  • Drag and drop a Custom step to configure an additional build step or a specific test suite run. On the right pane, you can do the following Custom configuration:

    • Custom Tool Name*: Select your Custom tool name from the drop down.

    • Job Name*: Select a job name from the drop down.

      undefined

Add custom script

CloudBees Release Orchestration SaaS platform allows you to create a new pipeline with a Custom Script. When you add a Custom Build step, a new job is created in Jenkins. If Jenkins is not able to access the pipeline definition and enable the pipeline, the agent will throw an error. You can edit the custom script only after enabling the pipeline. The platform first checks if the job exists, then you can edit the script.

Based on the type of script – Shell Script, Maven, Gradle, ANT – Jenkins will create a job.

Add New Script: Click to add a new custom script. Add New Script window opens.

  • In the Add New Script window, enter the following

    • Script Name*: Enter the name of the script.

    • Type of Script: Select the type of script from the drop

    • Add New Custom Script: Enter your new custom script or you can copy and paste your custom script.

  • Click SAVE.

Modify parameters during execution

Enable Modify Parameters during Execution in the right pane allows you to to modify the parameter of the tool during the pipeline execution.

Schedule

  • Enable the check box for a custom script to run at a specific time when a commit happens. You can schedule in the following ways:

    • Force Start: Enable the force start if you need to run the pipeline before Schedule time.

    • Every: Enable the checkbox and select the time (in minutes or hours) to run a custom script.

    • Time: Enter a specific time. When a commit happens, the custom script step waits until the defined time and runs at the specified time.

    • Time Zone: Enter the time zone. The custom script runs at the defined time and in the specified time zone.

    • Recurrence: Enable the check box and define a weekly recurring interval for a custom script to run on a specific day of the week, when a commit happens.

Notification

  • Enable the check box to notify the user upon the completion of a custom script.

    • Success: Enable the check box to notify the user when a custom script is successful.

    • Failure: Enable the check box to notify the user when a custom script has failed.

    • Notify Committer: Enable the check box to notify the user who made the code change and committed. The platform automatically identifies the user who has committed the code change and notifies the committer.

    • Mode: Select the mode of notification

      • Email ID: Select the mail ID of any specific user from the drop down to send the notification.

      • Slack: When you want to get notification on the Slack tool, you can select Slack → Slack endpoint and Slack Channel.

      • Send Event to Observability Tool: You can also choose to send notifications on the Observability tool by selecting the Send event to Observability tool→ Tool name*.

All the fields marked in Asterisk (*) are mandatory.