Resource Definition
2022世界杯阿根廷预选赛赛程are defined in a pipeline config under the2022世界杯阿根廷预选赛赛程tag, as shown below. Not all sections are required by all resources.
resources: - name:type: configuration:
| Tag | Description of usage | Required/Optional |
|---|---|---|
name |
Analphanumeric string (underscores are permitted) that makes it easy to infer what the resource represents, e.g., |
Required |
type |
Name of the resource type that this resource is an instance of.Alist of all types is below. |
Required |
configuration |
Specifies configuration settings, which vary for each Commonly included in this block is a setting that assigns by its name anintegrationthrough which the resource will be accessed. The integration must be compatible with the |
Required |
Using Resources
Resources can be inputs and outputs of steps in a pipeline.
- Resources may be from the same pipeline source as the pipeline or another pipeline source in the same Project and environment.
- If the resource is from a multi-branch pipeline source, either the same as the pipeline or a different source, and a different branch than the pipeline,
branchmust be included in the resource ininputResourcesor outputResources. - To use a resource from a single-branch pipeline,
branchshould not be specified.
Resources can be used by steps in these ways:
Inputs
When specified in a step in theinputResourcessection, theresource is an input for a step. The resourcecan also be referred to by its name as an argument in shell commands that the step executes.
A resource version will automatically initiate the execution of that step that has that resource as input resource.
For example, when a Step specifies aGitReporesource, any new code commit to that Git repository will automatically cause that step to execute.
If a step that specifies animageresource andtriggeris set asfalse执行步骤,它将使用最新的version of the resource during the execution.
Steps that have input resources from other pipelines trigger a run of the pipeline when the resource is updated. By default, input resources that were an output resource of another step in the same run will run whether or not the resource is updated.
To skip steps in the same run when input resources are not updated,newVersionOnlymay be added to the input resource.
Outputs
When specified as the output of a step in anoutputResourcestag, the resource receives the output of the step.The resourcecan also be referred to by its name as an argument in shell commands that the step executes.
Environment Variables
A step that specifies a resource ininputresourcescan access the resource and its attributes through environment variables.
The form of the environment variable is:
res_
You can also access an integration that is specified in the resource through an environment variable, whose form is:
res_
Example
If the definition of aGitReporesource namedapp_gitrepois as follows:
resources: - name: app_gitRepo type: GitRepo configuration: path: user1/repo1 gitProvider: myGitProvider
Then the following environment variables will be available to a step that uses theapp_gitRepoas an input:
| Environment Variable | Result | Description |
|---|---|---|
res_app_gitRepo_path |
user1/repo1 | Returns thepathattribute of theapp_gitReporesource |
res_app_gitRepo_gitProvider_url |
Returnsurlof the Git Provider of theapp_gitReporesource |
Example
This example step shows how these environment variables might be used to send notifications:
steps: - name: build_app type: MvnBuild configuration: sourceLocation: . mvnCommand: clean install configFileLocation: . inputResources: - name: app_gitRepo # Use the app_gitRepo resource execution: onSuccess: - send_notification notifySlack --text "Maven build completed for $res_app_gitRepo_path at $res_app_gitRepo_gitProvider_url" onFailure: - send_notification notifySlack --text "Maven build FAILED for $res_app_gitRepo_path at $res_app_gitRepo_gitProvider_url"
Arrays
For arrays within resources (e.g.VmCluster):
res_res_res_res_
For object arrays within resources (e.g. DistributionRule):
res_res_res_
State Information
Steps can store any key-value pair data in a resource using thewrite_outpututility function. Those values held by the resource can then be referencedas environment variables by any subsequently executing step that uses that resource as an input. In this way, a step can pass information to another step in the run of the pipeline.
The environment variable for the stored value is of the formres_.
For example, the followingwrite_outputcommandwill store the string value ofdescriptionin the resource. Any step can then access that value stored inmyResourcethrough the environment variable$res_myResource_description:
write_output myResource"description=\"hello world\""
For more information, seeCreating Stateful Pipelines.
Resource types
这些类型的资源JFrog Pipeli2022世界杯阿根廷预选赛赛程nes supports:
