Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 40 additions & 9 deletions docs/content/docs/concepts/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,46 @@ echo $CDS_PARENT_APPLICATION

Here is the list of git variables:

- `{{.git.hash}}`
- `{{.git.hash.short}}`
- `{{.git.url}}`
- `{{.git.http_url}}`
- `{{.git.branch}}`
- `{{.git.tag}}`
- `{{.git.author}}`
- `{{.git.message}}`
- `{{.git.server}}`
- `{{.git.hash.before}}`: SHA of the most recent commit before the push
- `{{.git.hash}}`: SHA of the most recent commit after the push
- `{{.git.hash.short}}`: Short version of git.hash
- `{{.git.hook}}`: Name of the event that trigger the run
- `{{.git.url}}`: Git ssh URL used to clone
- `{{.git.http_url}}`: Git http url used to clone
- `{{.git.branch}}`:
- Push event: Name of the branch where the push occured
- PullRequest event: Name of the source branch
- `{{.git.tag}}`: Name of the tag that triggered the run
- `{{.git.author}}`: Name of the most recent commit author
- `{{.git.author.email}}`: Email of the most recent commit author
- `{{.git.message}}`: Git message of the most recent commit
- `{{.git.server}}`: Name of the repository manager
- `{{.git.repository}}`:
- Push event: Name of the repository
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a variable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a list :)

- PullRequest event: Name of the source repository

Here is the list of git variables available only for Bitbucket server

- `{{.git.hash.dest}}`: SHA of the most rcent commit on destination branch ( PullRequest event )
- `{{.git.branch.dest}}`: Name of the destination branch on a pull request event
- `{{.git.repository.dest}}`: Name of the target repository on a pull request event
- `{{.git.pr.id}}`: Identifier of the pullrequest
- `{{.git.pr.title}}`: Title of the pullrequest
- `{{.git.pr.state}}`: Status of the pullrequest
- `{{.git.pr.previous.title}}`: Previous title of the pullrequest
- `{{.git.pr.previous.branch}}`: Previous target branch of the pullrequest
- `{{.git.pr.previous.hash}}`: Previous target hash of the pullrequest
- `{{.git.pr.previous.state}}`: Previous status of the pullrequest
- `{{.git.pr.reviewer}}`: Name of the reviewer
- `{{.git.pr.reviewer.email}}`: Email of the reviewer
- `{{.git.pr.reviewer.status}}`: Status of the review
- `{{.git.pr.reviewer.role}}`: Role of the reviewer
- `{{.git.pr.comment}}`: Comment written by the reviewer
- `{{.git.pr.comment.before}}`: Previous comment
- `{{.git.pr.comment.author}}`: Author name of the comment
- `{{.git.pr.comment.author.email}}` Author email of the comment



## Pipeline parameters

Expand Down
14 changes: 7 additions & 7 deletions engine/hooks/bitbucket_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ func getVariableFromBitbucketServerRepository(payload map[string]interface{}, re
if repo == nil {
return
}
payload[GIT_REPOSITORY] = fmt.Sprintf("%s/%s", repo.Project.Key, repo.Slug)
payload[GIT_REPOSITORY_DEST] = fmt.Sprintf("%s/%s", repo.Project.Key, repo.Slug)
}

func getVariableFromBitbucketServerSrcRepository(payload map[string]interface{}, repo *sdk.BitbucketServerRepository) {
if repo == nil {
return
}
payload[GIT_REPOSITORY_BEFORE] = fmt.Sprintf("%s/%s", repo.Project.Key, repo.Slug)
payload[GIT_REPOSITORY] = fmt.Sprintf("%s/%s", repo.Project.Key, repo.Slug)
}

func getVariableFromBitbucketServerAuthor(payload map[string]interface{}, actor *sdk.BitbucketServerActor) {
Expand All @@ -119,11 +119,11 @@ func getVariableFromBitbucketServerPullRequest(payload map[string]interface{}, p
payload[PR_ID] = pr.ID
payload[PR_STATE] = pr.State
payload[PR_TITLE] = pr.Title
payload[GIT_BRANCH_BEFORE] = pr.FromRef.DisplayID
payload[GIT_HASH_BEFORE] = pr.FromRef.LatestCommit
payload[GIT_BRANCH] = pr.ToRef.DisplayID
payload[GIT_HASH] = pr.ToRef.LatestCommit
hashShort := pr.ToRef.LatestCommit
payload[GIT_BRANCH] = pr.FromRef.DisplayID
payload[GIT_HASH] = pr.FromRef.LatestCommit
payload[GIT_BRANCH_DEST] = pr.ToRef.DisplayID
payload[GIT_HASH_DEST] = pr.ToRef.LatestCommit
hashShort := pr.FromRef.LatestCommit
if len(hashShort) >= 7 {
hashShort = hashShort[:7]
}
Expand Down
Loading