gaukhar
gaukhar

Reputation: 182

When triggering jenkins pipeline from Spinnaker is it possible to pass pipelineParams?

When triggering jobs from Spinnaker is there a way to pass pipelineParams. For example I see

{
  "continuePipeline": false,
  "failPipeline": true,
  "isNew": true,
  "job": "job123",
  "master": "master123",
  "name": "Jenkins",
  "parameters": {
    "mavenProfile": "FooBar"  <-- ???
  },
  "type": "jenkins"
}

What purpose do parameters field serve? Can we use it to pass parameters to the Jenkins pipelines? Has anyone successfully accomplished passing parameters to Jenkins pipelines?

When above stage gets triggered, it immediately fails with a message:

job/master, passing params to a job which doesn't need them

Upvotes: 0

Views: 1907

Answers (2)

gaukhar
gaukhar

Reputation: 182

As the answer from Thomas Lin states, the problem was I as trying to pass in parameters to a non-parameterized pipeline.

I went ahead and made my jenkins pipeline paramterized:

https://github.com/jenkinsci/pipeline-model-definition-plugin/wiki/Parametrized-pipelines

parameters {
    string(defaultValue: "", description: 'What profile?', name: 'mavenProfile')
}

And as soon as I did that my Jenkins pipeline started receiving parameters from my Spinnaker pipeline.

Upvotes: 0

Tomas Lin
Tomas Lin

Reputation: 3532

The Jenkins integration in Spinnaker launches individual jobs.

The parameters that you have highlighted points to job parameters defined if you select This project is parameterized in the Jenkins Job config. The reason you're getting that error is because Jenkins hits 2 different endpoints for launching jobs, one with parameters and one without.

As far as I know, there is not a way to launch jenkins pipelines from Spinnaker, but I imagine it would look different than the Jenkins launch job stage since it would have to hit a different API endpoint.

Upvotes: 1

Related Questions