YAML Schema
resources: - name:type: GitRepo configuration: gitProvider: path: files: include: exclude: branches: include: exclude: pullRequestSourceBranches: include: exclude: pullRequestTargetBranches: include: exclude: tags: include: exclude: buildOn: commit: pullRequestCreate: pullRequestClose: releaseCreate: tagCreate: cancelPendingRunsOn: newCommit: pullRequestUpdate: shallowDepth: # used to set the depth at which the repo is (shallow)cloned/fetched cloneProtocol: # Optional. Defaults to ssh pin: versionId: sha:
Tags
name
Analphanumericstring (underscores are permitted) that identifies the resource.
type
必须GitRepo
for this resource type.
configuration
Specifies all configuration selections for the resource.
Tag |
Description |
Required/Optional |
---|---|---|
|
The name of the source control integration.Currently supported integration types are: | Required |
path |
The path of the repository from the integration root |
Required |
files |
|
Optional |
|
Supported regex The
Examples:
If the tag is not specified, the default branch will be triggered. |
Optional |
pullRequestSourceBranches |
If this tag is not specified, all branches are matched by default. |
Optional |
pullRequestTargetBranches |
If this tag is not specified, the |
Optional |
tags |
Used to specify a collection of tags and releases upon which a new version is created
If this tag is not specified, all tags are matched by default. |
Optional |
buildOn |
Used to control whether the resource will be updated on specified events
If this tag is not specified, For more information about using this tag, seeTriggering On a Git Repository Change. |
Optional |
cancelPendingRunsOn |
Used to control whether previously triggered runs are canceled for new webhooks
All values for this tag are false by default. For more information about using this tag, seeCancelling Previous Runs On a Git Repository Change. |
Optional |
shallowDepth |
Uses a positive integer to set the depth at which the repo is (shallow) cloned/fetched If |
Optional |
cloneProtocol |
Used to select the protocol to be used when cloning the repo. Supported values aressh orhttps . Defaults tossh . |
Optional |
pin |
This configuration can be used to pin the resource to a specific version. The pinned resource version will be used by the steps that reference this resource as an input and newer versions will be ignored. Users have two configuration options when selecting the GitRepo resource version to be pinned:
或
Steps that use the resource as an output can still produce new versions. New versions will be visible for steps using the resource as an input as long as they are part of the same run of the step that created the version. When creating a new run,manual custom triggercan still be used to override the pinned version to a different one. |
Optional |
Environment Variables
WheneverGitRepo
is used in a step, a set of environment variables is automatically made available that you can use in your step.
Environment Variable | Description |
---|---|
res_ |
Relative path of the resource |
res_ |
Name of branch on which the commit occurred. If it was created for a pull request, this is the base branch |
res_ |
Commit message of the version being used |
res_ |
SHA of the commit of the version being used |
res_ |
URL to the commit |
res_ |
Name of the committer for the SHA being used |
res_ |
Git integration name |
res_ |
URL of the Git Provider integration |
res_ |
Name of the Git repo |
res_ |
HTTPS URL for the Git repository |
res_ |
SSH URL for the Git repository. |
res_ |
URL for the Git repository |
res_ |
Default branch of the Git repository |
res_ |
If a tag name was present in the current version, this will be the tag name |
res_ |
Thename string of the integration used by the GitRepo |
res_ |
True if the version is a git tag based build |
res_ |
Trueif the version is a git release based build. Supported only if the integration is GitHub |
res_ |
True if the version is a git open pull request based build |
res_ |
True ,if the version is a git closed pull request based step. Supported only if the integration is GitHub or Bitbucket or Gitlab. |
res_ |
True if the version is a git release based build. Supported only if the integration is GitHub |
res_ |
The ID number of the pull request |
res_ |
Name of the base branch into which the pull request changes will be merged |
res_ |
Source URL of the pull request |
res_ |
Source HTTPS URL of the pull request |
res_ |
Source SSH URL of the pull request |
res_ |
Full path of the resource folder on the node |
res_ |
Input or output resource |
res_ |
JSON对象包含沙的细节 |
res_ |
沙性能试验ore the commit was made |
res_ |
The commit SHA of base branch in a PR |
res_ |
Compare URL for the commit |
res_ |
If a git tag is created, this holds the message if it is present |
res_ |
If a release is created, this holds the name of the release |
res_ |
If a release is created, this holds the description of the release |
res_ |
If a release is created, this holds the date of the release |
res_ |
Details of when the last author logged in |
res_ |
Email of the author |
res_ |
True if a branch was created |
res_ |
True if a branch was deleted |
Examples
Example 1
resources: - name: my_app_repo type: GitRepo configuration: gitProvider: my_github path: myuser/repo-name branches: include: master
Example 2
resources: - name: my_app_repo type: GitRepo configuration: gitProvider: my_github path: myuser/repo-name branches: exclude: ^(master|release)$
Example 3
The following example may be useful to reference a single directory in a source repository that contains source code for a single microservice within a larger project.
resources: - name: my_app_repo type: GitRepo configuration: gitProvider: my_github path: myuser/repo-name branches: include: master files: include: ^folder1\/package\/docker\/micro1\/.+
Example 4
By default, a GitRepo triggers on a commit, but this can be changed in thebuildOn
attributes. For more information about triggering, seeTriggering Pipelines and Steps.
resources: - name: my_app_repo type: GitRepo configuration: gitProvider: my_github path: myuser/repo-name branches: include: master buildOn: commit: false pullRequestCreate: true
Example 5
The following example pipeline triggers the first step on the GitRepo resource. The step uses the environment variables exposed by the GitRepo resource to navigate to the path where the git repository is cloned on the build node, and to execute a script in that directory.
pipelines: - name: java_pipeline steps: - name: step_1 type: Bash configuration: inputResources: - name: my_app_repo execution: onExecute: - pushd $res_my_app_repo_resourcePath - ./execute.sh - popd
Example 6
resources: - name: my_app_repo type: GitRepo configuration: gitProvider: my_github path: myuser/repo-name branches: include: master cloneProtocol: https
Example 7
在这个例子中,GitRepo辊筒y updated for pull requests to master.
resources: - name: my_app_repo type: GitRepo configuration: gitProvider: my_github path: myuser/repo-name pullRequestTargetBranches: include: ^master$ buildOn: commit: false pullRequestCreate: true