From e1ad97a224678be99de32ae83d7dd41f478fa006 Mon Sep 17 00:00:00 2001 From: zc Date: Sun, 7 Feb 2021 11:07:20 +0800 Subject: [PATCH 1/2] add trigger environment variable --- environ/environ.go | 1 + 1 file changed, 1 insertion(+) diff --git a/environ/environ.go b/environ/environ.go index ab6147f..ed1cc97 100644 --- a/environ/environ.go +++ b/environ/environ.go @@ -141,6 +141,7 @@ func Build(build *drone.Build) map[string]string { "DRONE_BUILD_FINISHED": fmt.Sprint(build.Finished), "DRONE_DEPLOY_TO": build.Deploy, "DRONE_DEPLOY_ID": fmt.Sprint(build.DeployID), + "DRONE_BUILD_TRIGGER": build.Trigger, // these are legacy configuration parameters for backward // compatibility with drone 0.8. These are deprecated and From 67b61b6458e494adcbc4a51b3f529f23a07aa0ef Mon Sep 17 00:00:00 2001 From: zc Date: Sun, 7 Feb 2021 11:11:12 +0800 Subject: [PATCH 2/2] fix unit --- environ/environ_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/environ/environ_test.go b/environ/environ_test.go index 9effacb..47429bf 100644 --- a/environ/environ_test.go +++ b/environ/environ_test.go @@ -58,6 +58,7 @@ func TestRepo(t *testing.T) { func TestBuild(t *testing.T) { v := &drone.Build{ + Trigger: "root", Source: "develop", Target: "master", After: "762941318ee16e59dabbacb1b4049eec22f0d303", @@ -124,6 +125,7 @@ func TestBuild(t *testing.T) { "DRONE_PULL_REQUEST": "32", "DRONE_SOURCE_BRANCH": "develop", "DRONE_TARGET_BRANCH": "master", + "DRONE_BUILD_TRIGGER": "root", "CI_BUILD_CREATED": "1561421740", "CI_BUILD_EVENT": "pull_request",