Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DRONE_STEP_NUMBER to environment variables #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions engine/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,13 @@ func (c *Compiler) Compile(ctx context.Context, args runtime.CompilerArgs) runti
Branch: args.Build.Target,
}

var stepNumber int64 = 0
// create the clone step
if pipeline.Clone.Disable == false {
if !pipeline.Clone.Disable {
stepNumber++
step := createClone(pipeline)
step.ID = random()
step.Envs = environ.Combine(envs, step.Envs)
step.Envs = environ.Combine(envs, step.Envs, environ.StepArgs(step.Name, stepNumber))
step.WorkingDir = workspace
step.Volumes = append(step.Volumes, workMount, statusMount)
spec.Steps = append(spec.Steps, step)
Expand All @@ -376,7 +378,8 @@ func (c *Compiler) Compile(ctx context.Context, args runtime.CompilerArgs) runti

// create steps
for _, src := range pipeline.Services {
dst := createStep(pipeline, src)
stepNumber++
dst := createStep(src, stepNumber)
dst.Detach = true
dst.Envs = environ.Combine(envs, dst.Envs)
dst.Volumes = append(dst.Volumes, workMount, statusMount)
Expand Down Expand Up @@ -406,7 +409,8 @@ func (c *Compiler) Compile(ctx context.Context, args runtime.CompilerArgs) runti

// create steps
for _, src := range pipeline.Steps {
dst := createStep(pipeline, src)
stepNumber++
dst := createStep(src, stepNumber)
dst.Envs = environ.Combine(envs, dst.Envs)
dst.Volumes = append(dst.Volumes, workMount, statusMount)
setupScript(src, dst, os)
Expand Down
4 changes: 2 additions & 2 deletions engine/compiler/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

const placeholderImage = "drone/placeholder:1"

func createStep(spec *resource.Pipeline, src *resource.Step) *engine.Step {
func createStep(src *resource.Step, num int64) *engine.Step {
dst := &engine.Step{
ID: random(),
Name: src.Name,
Expand All @@ -28,7 +28,7 @@ func createStep(spec *resource.Pipeline, src *resource.Step) *engine.Step {
Entrypoint: src.Entrypoint,
Detach: src.Detach,
DependsOn: src.DependsOn,
Envs: environ.Combine(convertStaticEnv(src.Environment), environ.StepName(src.Name)),
Envs: environ.Combine(convertStaticEnv(src.Environment), environ.StepArgs(src.Name, num)),
IgnoreStderr: false,
IgnoreStdout: false,
Privileged: src.Privileged,
Expand Down