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

Unable to call a step - that takes an application_environment object as a param - from stage block #72

Closed
Vince-Cercury opened this issue Apr 28, 2020 · 1 comment

Comments

@Vince-Cercury
Copy link

Vince-Cercury commented Apr 28, 2020

In my pipeline_config:

application_environments{
    dev{
        long_name = "Development"
    }
    prod{
        long_name = "Production"
    }
}

I've got a step called project_specific_step.groovy:

void call(environment) {
   echo "environment.short_name: ${environment.short_name}"
}

Calling it from Jenkinsfile:

project_specific_step dev

OUTPUT:

environment.short_name: dev

As expected

Calling it from a stage block defined in pipeline_config.groovy:

stages{
  stage_do_things{
    project_specific_step dev
    common_step_a
    common_step_b
  }
}

OUTPUT:

hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: org.boozallen.plugins.jte.binding.injectors.ApplicationEnvironment.call() is applicable for argument types: () values: []
Possible solutions: wait(), any(), wait(long), any(groovy.lang.Closure), each(groovy.lang.Closure), wait(long, int)

Error.

Is passing an application_environment object to a step supported from a stage block?

Use case: Only one of my project need to call project_specific_step step. The others don't. I want to reuse the same Jenkinsfile though. I don't want to have to create another Jenkinsfile just for that one project that is different. So overriding a stage block primitive in pipeline_config of this specific project is ideal.
However my step needs an input, as it is being called a few times, in different stages. Behaviour will change depending on the environment we pass

Suggestions please?

@Vince-Cercury Vince-Cercury changed the title Unable to call a step - that takes an application_environment object from stage block Unable to call a step - that takes an application_environment object as a param - from stage block Apr 28, 2020
@steven-terrana
Copy link

Recapping the conversation from the JTE Gitter Channel:

Stage parameters should be passed from the pipeline template and accessed in steps via the stageContext variable.

This stageContext functionality has been documented as part of the 2.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants