Expose step type to step env (#4290)

This commit is contained in:
6543
2026-05-07 13:08:54 +02:00
committed by GitHub
parent ff5c84874f
commit 9130c497d4
3 changed files with 7 additions and 0 deletions

View File

@@ -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` |

View File

@@ -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",

View File

@@ -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
}