tutorials/HealthCheck- A step that performs a health check action to a website, with optional notification to a Slack instance on success and failure.
configuration: healthCheckUrl: type: Url notifyOnSuccess: type: Boolean notifyOnFailure: type: Boolean stuff: type: String[]
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
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:
- From theAdministrationmodule go toPipelines | Integrations.
- From the Integrationsview, clickAdd an Integration.
- In the resultingAdd New Integrationdisplay, click theAdminradio button and then complete the entries for your VCS account and clickCreate.
- 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
wheretutorials
identifies the namespace for each set ofsteps
and2022世界杯阿根廷预选赛赛程
.
To add an Extension Source:
- From theApplicationmodule go toPipelines | Extensions & Templates.
- Select theSourcestab, thenclickAdd Source,and then clickExtensions.
- 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 pipelineMyHealthCheck
is in thepipeline
branch of the repository. TheMyHealthCheck
pipeline will test the newly added step and resource extensions.
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 thepipeline
branch 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.