From 9130c497d418b1c56fb8414ff25406cb720e7edd Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 7 May 2026 13:08:54 +0200 Subject: [PATCH] Expose step type to step env (#4290) --- docs/docs/20-usage/50-environment.md | 1 + pipeline/runtime/runtime_test.go | 4 ++++ pipeline/runtime/step.go | 2 ++ 3 files changed, 7 insertions(+) diff --git a/docs/docs/20-usage/50-environment.md b/docs/docs/20-usage/50-environment.md index 78cb4bbe75..d1b925b8b0 100644 --- a/docs/docs/20-usage/50-environment.md +++ b/docs/docs/20-usage/50-environment.md @@ -98,6 +98,7 @@ This is the reference list of all environment variables available to your pipeli | `CI_WORKFLOW_NAME` | workflow name | `release` | | | **Current step** | | | `CI_STEP_NAME` | step name | `build package` | +| `CI_STEP_TYPE` | step type (`commands`, `plugin`, `service`, `clone` or `cache`) | `commands` | | `CI_STEP_NUMBER` | step number | `0` | | `CI_STEP_STARTED` | step started UNIX timestamp | `1722617519` | | `CI_STEP_URL` | URL to step in UI | `https://ci.example.com/repos/7/pipeline/8` | diff --git a/pipeline/runtime/runtime_test.go b/pipeline/runtime/runtime_test.go index d327b6adfe..c11084d562 100644 --- a/pipeline/runtime/runtime_test.go +++ b/pipeline/runtime/runtime_test.go @@ -283,6 +283,8 @@ func TestWorkflowWithServiceStep(t *testing.T) { Environment: map[string]string{ "CI_PIPELINE_STARTED": fmt.Sprintf("%d", r.started), "CI_PIPELINE_STATUS": "success", + "CI_STEP_NAME": "test", + "CI_STEP_TYPE": "commands", }, Commands: []string{"echo test"}, }, @@ -481,6 +483,8 @@ func TestWorkflowPluginStep(t *testing.T) { assert.EqualValues(t, map[string]string{ "CI_PIPELINE_STATUS": "success", + "CI_STEP_NAME": "publish", + "CI_STEP_TYPE": "plugin", "DRONE_BUILD_STATUS": "success", "DRONE_REPO_SCM": "git", "EXPECT_TYPE": "plugin", diff --git a/pipeline/runtime/step.go b/pipeline/runtime/step.go index efae86c656..69215eb243 100644 --- a/pipeline/runtime/step.go +++ b/pipeline/runtime/step.go @@ -103,6 +103,8 @@ func (r *Runtime) setStepEnv(step *backend_types.Step) error { } step.Environment["CI_PIPELINE_STARTED"] = strconv.FormatInt(r.started, 10) step.Environment["CI_STEP_STARTED"] = strconv.FormatInt(time.Now().Unix(), 10) + step.Environment["CI_STEP_TYPE"] = string(step.Type) + step.Environment["CI_STEP_NAME"] = step.Name return nil }