Cloud customer?
Start for Free>
Upgrade in MyJFrog >
What's New in Cloud >





Overview

Pipelines Extensions enable users to extend the capabilities of Pipelines by adding their own custom steps and resources to the Pipelines DSL.

The example in this tutorial can be found in theJFrog GitHub repository. You can fork thisjfrog-pipelines-extensions-samplerepo to your own GitHub account to try on your own installation of Pipelines.



Example Extensions

存储库提供了以下简单的服务les, both in the namespacetutorials:

Page Contents

tutorials/HealthCheck- A step that performs a health check action to a website, with optional notification to a Slack instance on success and failure.

stepModel.yml
configuration: healthCheckUrl: type: Url notifyOnSuccess: type: Boolean notifyOnFailure: type: Boolean stuff: type: String[]
onExecute.sh
checkHealth() { local success=true local url=$(find_step_configuration_value "healthCheckUrl") { local statusCode=$(curl --silent --output /dev/stderr --write-out "%{http_code}" "$url") } || exitCode=$? if test $statusCode -ne 200; then export success=false echo "Health check failed with statusCode: $statusCode & exitCode: $exitCode for url: $url" else echo "Health check succeeded" fi $success } execute_command checkHealth

tutorials/test- A resource type that holds some example data types

resourceModel.yml
configuration: alpha: type: String validate: isRegex: "^[a-zA-Z_][a-zA-Z0-9_]*$" number: type: Int flag: type: Boolean

Add and Sync Extensions

To add your Pipelines DSL extension definitions so they can be used in your pipelines, you must作为exten分叉的存储库添加到管道sion source.

Add an Administration Integration

In theAdministrationmodule,add an administration integrationfor the version control system account (e.g.,GitHub,Bitbucket Server, or other) that holds the source repository for your extensions.

This procedure can only be performed by anadministrator useror resource manager user.

To add an administrator integration for Pipelines DSL extensions:

  1. From theAdministrationmodule go toPipelines | Integrations.
  2. From the Integrationsview, clickAdd an Integration.
  3. In the resultingAdd New Integrationdisplay, click theAdminradio button and then complete the entries for your VCS account and clickCreate.

  4. After entering all the relevant details for the integration, clickTest Connectionto validate all the details you have entered, including the URL, user credentials, and the token for sufficient permissions on the repository.

Add an Extension Source

Once the VCS account has been added to the administration integrations, you can add your source code repository as an extension source.

Your source code repository for your extensions must be structured according to the requirements for thestep modelandresource model.

For example, our sample repository folder structure is:

jfrog-pipelines-extensions-sample -- steps ------ tutorials –- HealthCheck
|
– resources -- tutorials -- test

wheretutorialsidentifies the namespace for each set ofstepsand2022世界杯阿根廷预选赛赛程.

To add an Extension Source:

  1. From theApplicationmodule go toPipelines | Extensions & Templates.
  2. Select theSourcestab, thenclickAdd Source,and then clickExtensions.
  3. In the resultingAdd Extension Sourcedisplay, select the VCS account integration added above, enter the repository path and branch, then clickCreate Source.

Pipelines syncs the extension source to load the extensions.

Click theLogscolumn to view the results of the sync.


Confirm Extensions

View theExtensionstab to see the list of successfully loaded Pipelines DSL extensions.



Example Pipeline

The example pipelineMyHealthCheckis in thepipelinebranch of the repository. TheMyHealthCheckpipeline will test the newly added step and resource extensions.

pipeline.yml
resources: - name: MyGitHub type: GitRepo configuration: path: jfrogtw/jfrog-pipelines-extensions-sample # <-- Change to your repository path gitProvider: tw_github # <-- Change to your GitHub integration - name: MyTest type: tutorials/test configuration: alpha: "JFrog" number: 42 flag: true pipelines: - name: MyHealthCheck configuration: environmentVariables: readOnly: my_env_var: "hello" steps: - name: Health_Check_Step type: tutorials/HealthCheck configuration: healthCheckUrl: "//www.si-fil.com" notifyOnSuccess: false notifyOnFailure: false stuff: - "This is a string" - "This is another string" inputResources: - name: MyTest - name: MyGitHub


Add the Pipeline Source

To load the example pipeline in your Pipelines deployment, add thepipelinebranch of the repository as a Single Branch Pipeline Source.

If you have not already, you will need to add an integration for your GitHub account. Note that this is in addition to the administration integration added above (even though it is for the same account).


When you clickCreate Source, the Pipelines DSL file will be synced from the newly added pipeline source. When completed, you can view theLogsfor the sync.

Run the Example Pipeline

The newly loaded pipelineMyHealthCheckcan be seen in theMy Pipelinesview.

Click onMyHealthCheckto view itsPipeline History. You can click on the pipeline's singleHealth_Check_Stepto trigger a run of the pipeline.

  • No labels
Copyright © 2022 JFrog Ltd.