mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-08-05 08:58:29 +00:00
Feature: Add HEAD_COMMIT env var (#1392)
This commit is contained in:
@@ -349,6 +349,7 @@ Or a custom command
|
||||
* `HEAD_REPO_NAME` - Name of the repository that is getting merged into the base repository, ex. `atlantis`.
|
||||
* `HEAD_REPO_OWNER` - Owner of the repository that is getting merged into the base repository, ex. `acme-corp`.
|
||||
* `HEAD_BRANCH_NAME` - Name of the head branch of the pull request (the branch that is getting merged into the base)
|
||||
* `HEAD_COMMIT` - The sha256 that points to the head of the branch that is being pull requested into the base. If the pull request is from Bitbucket Cloud the string will only be 12 characters long because Bitbucket Cloud truncates its commit IDs.
|
||||
* `BASE_BRANCH_NAME` - Name of the base branch of the pull request (the branch that the pull request is getting merged into)
|
||||
* `PROJECT_NAME` - Name of the project configured in `atlantis.yaml`. If no project name is configured this will be an empty string.
|
||||
* `PULL_NUM` - Pull request number or ID, ex. `2`.
|
||||
|
||||
@@ -50,6 +50,7 @@ command](custom-workflows.html#custom-run-command).
|
||||
* `HEAD_REPO_NAME` - Name of the repository that is getting merged into the base repository, ex. `atlantis`.
|
||||
* `HEAD_REPO_OWNER` - Owner of the repository that is getting merged into the base repository, ex. `acme-corp`.
|
||||
* `HEAD_BRANCH_NAME` - Name of the head branch of the pull request (the branch that is getting merged into the base)
|
||||
* `HEAD_COMMIT` - The sha256 that points to the head of the branch that is being pull requested into the base. If the pull request is from Bitbucket Cloud the string will only be 12 characters long because Bitbucket Cloud truncates its commit IDs.
|
||||
* `BASE_BRANCH_NAME` - Name of the base branch of the pull request (the branch that the pull request is getting merged into)
|
||||
* `PULL_NUM` - Pull request number or ID, ex. `2`.
|
||||
* `PULL_AUTHOR` - Username of the pull request author, ex. `acme-user`.
|
||||
|
||||
@@ -26,6 +26,7 @@ func (wh DefaultPreWorkflowHookRunner) Run(ctx models.PreWorkflowHookCommandCont
|
||||
"BASE_REPO_OWNER": ctx.BaseRepo.Owner,
|
||||
"DIR": path,
|
||||
"HEAD_BRANCH_NAME": ctx.Pull.HeadBranch,
|
||||
"HEAD_COMMIT": ctx.Pull.HeadCommit,
|
||||
"HEAD_REPO_NAME": ctx.HeadRepo.Name,
|
||||
"HEAD_REPO_OWNER": ctx.HeadRepo.Owner,
|
||||
"PULL_AUTHOR": ctx.Pull.Author,
|
||||
|
||||
@@ -49,8 +49,8 @@ func TestPreWorkflowHookRunner_Run(t *testing.T) {
|
||||
ExpErr: "exit status 127: running \"lkjlkj\" in",
|
||||
},
|
||||
{
|
||||
Command: "echo base_repo_name=$BASE_REPO_NAME base_repo_owner=$BASE_REPO_OWNER head_repo_name=$HEAD_REPO_NAME head_repo_owner=$HEAD_REPO_OWNER head_branch_name=$HEAD_BRANCH_NAME base_branch_name=$BASE_BRANCH_NAME pull_num=$PULL_NUM pull_author=$PULL_AUTHOR",
|
||||
ExpOut: "base_repo_name=basename base_repo_owner=baseowner head_repo_name=headname head_repo_owner=headowner head_branch_name=add-feat base_branch_name=master pull_num=2 pull_author=acme\n",
|
||||
Command: "echo base_repo_name=$BASE_REPO_NAME base_repo_owner=$BASE_REPO_OWNER head_repo_name=$HEAD_REPO_NAME head_repo_owner=$HEAD_REPO_OWNER head_branch_name=$HEAD_BRANCH_NAME head_commit=$HEAD_COMMIT base_branch_name=$BASE_BRANCH_NAME pull_num=$PULL_NUM pull_author=$PULL_AUTHOR",
|
||||
ExpOut: "base_repo_name=basename base_repo_owner=baseowner head_repo_name=headname head_repo_owner=headowner head_branch_name=add-feat head_commit=12345abcdef base_branch_name=master pull_num=2 pull_author=acme\n",
|
||||
},
|
||||
{
|
||||
Command: "echo user_name=$USER_NAME",
|
||||
@@ -86,6 +86,7 @@ func TestPreWorkflowHookRunner_Run(t *testing.T) {
|
||||
Pull: models.PullRequest{
|
||||
Num: 2,
|
||||
HeadBranch: "add-feat",
|
||||
HeadCommit: "12345abcdef",
|
||||
BaseBranch: "master",
|
||||
Author: "acme",
|
||||
},
|
||||
|
||||
@@ -44,6 +44,7 @@ func (r *RunStepRunner) Run(ctx models.ProjectCommandContext, command string, pa
|
||||
"COMMENT_ARGS": strings.Join(ctx.EscapedCommentArgs, ","),
|
||||
"DIR": path,
|
||||
"HEAD_BRANCH_NAME": ctx.Pull.HeadBranch,
|
||||
"HEAD_COMMIT": ctx.Pull.HeadCommit,
|
||||
"HEAD_REPO_NAME": ctx.HeadRepo.Name,
|
||||
"HEAD_REPO_OWNER": ctx.HeadRepo.Owner,
|
||||
"PATH": fmt.Sprintf("%s:%s", os.Getenv("PATH"), r.TerraformBinDir),
|
||||
|
||||
@@ -65,8 +65,8 @@ func TestRunStepRunner_Run(t *testing.T) {
|
||||
ExpOut: "workspace=myworkspace version=0.11.0 dir=$DIR planfile=$DIR/my::project::name-myworkspace.tfplan project=my/project/name\n",
|
||||
},
|
||||
{
|
||||
Command: "echo base_repo_name=$BASE_REPO_NAME base_repo_owner=$BASE_REPO_OWNER head_repo_name=$HEAD_REPO_NAME head_repo_owner=$HEAD_REPO_OWNER head_branch_name=$HEAD_BRANCH_NAME base_branch_name=$BASE_BRANCH_NAME pull_num=$PULL_NUM pull_author=$PULL_AUTHOR repo_rel_dir=$REPO_REL_DIR",
|
||||
ExpOut: "base_repo_name=basename base_repo_owner=baseowner head_repo_name=headname head_repo_owner=headowner head_branch_name=add-feat base_branch_name=master pull_num=2 pull_author=acme repo_rel_dir=mydir\n",
|
||||
Command: "echo base_repo_name=$BASE_REPO_NAME base_repo_owner=$BASE_REPO_OWNER head_repo_name=$HEAD_REPO_NAME head_repo_owner=$HEAD_REPO_OWNER head_branch_name=$HEAD_BRANCH_NAME head_commit=$HEAD_COMMIT base_branch_name=$BASE_BRANCH_NAME pull_num=$PULL_NUM pull_author=$PULL_AUTHOR repo_rel_dir=$REPO_REL_DIR",
|
||||
ExpOut: "base_repo_name=basename base_repo_owner=baseowner head_repo_name=headname head_repo_owner=headowner head_branch_name=add-feat head_commit=12345abcdef base_branch_name=master pull_num=2 pull_author=acme repo_rel_dir=mydir\n",
|
||||
},
|
||||
{
|
||||
Command: "echo user_name=$USER_NAME",
|
||||
@@ -124,6 +124,7 @@ func TestRunStepRunner_Run(t *testing.T) {
|
||||
Pull: models.PullRequest{
|
||||
Num: 2,
|
||||
HeadBranch: "add-feat",
|
||||
HeadCommit: "12345abcdef",
|
||||
BaseBranch: "master",
|
||||
Author: "acme",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user