mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-05-15 14:05:58 +00:00
Expose step type to step env (#4290)
This commit is contained in:
@@ -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` |
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user