Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins: How to use jenkins pipeline Multiple parameters

I have a Jenkinsfile instance using ansible-playbook to deploy webmachine.

I need to specified ansible-playbook parameters more than one at once.

I got

WorkflowScript: 25: Multiple occurrences of the parameters section

my jenkinsfile like this,

pipeline {
agent none
stages {
    stage('docker-compose up') {
        input {
            message "Should we continue?"
            ok "Yes, do it!"
            parameters {
                string(name: 'KIBANA_TAG', defaultValue: '', description: 'input tag for ansible command.')
            }
            parameters {
                string(name: 'FLUENT_TAG', defaultValue: '', description: 'input tag for ansible command.')
            }
            parameters {
                string(name: 'ES_TAG', defaultValue: '', description: 'input tag for ansible command.')
            }
            parameters {
                string(name: 'HOST', defaultValue: '', description: 'input tag for ansible command.')
            }
        }
        steps {
            sh "rd6-admin@qa ansible-playbook /tmp/qa/docker-compose-up.yml -e fluent_tag=${params.FLUENT_TAG} -e kibana_tag=${params.KIBANA_TAG} -e es_tag=${params.ES_TAG} -e host=${params.HOST}"
        }
    }
}
}

what part should i fix?

like image 844
hanase Avatar asked Mar 14 '18 08:03

hanase


2 Answers

The comma separator is not working in version 2.222.1. I removed the comma and it is now working.

parameters {
    string(name: 'KIBANA_TAG', defaultValue: 'default', description: 'input tag for ansible command.')
    string(name: 'FLUENT_TAG', defaultValue: 'default', description: 'input tag for ansible command.')
    string(name: 'ES_TAG', defaultValue: 'default', description: 'input tag for ansible command.')
    string(name: 'HOST', defaultValue: 'default', description: 'input tag for ansible command.')
}
like image 137
Rajasekaran Avatar answered Oct 13 '22 17:10

Rajasekaran


parameters {
    string(name: 'KIBANA_TAG', defaultValue: 'default', description: 'input tag for ansible command.')
    string(name: 'FLUENT_TAG', defaultValue: 'default', description: 'input tag for ansible command.')
    string(name: 'ES_TAG', defaultValue: 'default', description: 'input tag for ansible command.')
    string(name: 'HOST', defaultValue: 'default', description: 'input tag for ansible command.')
}

Try this. Multiple occurrences of the parameters section means that there is only one parameters{} allowed and you have to place your parameters inside there.

like image 4
ErikWe Avatar answered Oct 13 '22 17:10

ErikWe