Example 1
GitRepo resource listening to the master branch
resources:
- name: my_app_repo
type: GitRepo
configuration:
gitProvider: my_github
path: myuser/repo-name
branches:
include: masterGitRepo resource listening to all branches except master and release
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.
GitRepo resource listening only to certain files in a directory
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 the buildOn attributes. For more information about triggering, see Triggering Pipelines and Steps.
GitRepo triggers only for a pull request and not for commit
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.
Usage in a Pipeline
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
- popdExample 6
GitRepo resource using HTTPS protocol during repo clone
resources:
- name: my_app_repo
type: GitRepo
configuration:
gitProvider: my_github
path: myuser/repo-name
branches:
include: master
cloneProtocol: httpsExample 7
In this example, the GitRepo is only updated for pull requests to master.
GitRepo triggers only for a 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