詹金斯的提示 [英] Prompts in Jenkins
问题描述
我正在尝试通过jenkins使用ansible剧本在centos 7上安装软件.
I am trying to install software on centos 7 using ansible playbook through jenkins.
我正在尝试从jenkins调用ansible剧本来安装该软件.
I am trying to call ansible playbook from jenkins for installing the software.
我在ansible剧本中使用vars_prompt传递一些用户定义的参数,当我手动运行ansible剧本时,它会提示并成功运行,但是当我使用jenkins进行构建时,它不会提示任何输入.
I am using vars_prompt in ansible playbook to pass some user-defined parameters, when i run the ansible playbook manually, it asks for prompts and runs successfully but when i build using jenkins it doesn't prompt for any inputs.
管道:
node {
ansiblePlaybook(
installation: 'FirstAnsibleTest',
inventory: '/etc/ansible/hosts',
playbook: '/etc/ansible/install.yml',
become: true,
colorized: true,
)
}
install.yml:
install.yml:
- hosts: all
vars_prompt:
- name: "webusername"
prompt: "Enter webusername"
- name: "webpassword"
prompt: "Enter webpassword"
private: yes
tasks:
- import_tasks: /etc/ansible/roles/installe/tasks/main.yml
我如何让詹金斯询问可以传递给ansible剧本的提示?
How can I make jenkins to ask for prompts that can be passed to the ansible playbook?
推荐答案
当詹金斯(Jenkins)以非交互方式启动工作时,您需要在调用剧本时将变量及其值传递给--extra-vars
(例如:
as Jenkins launches the job as non-interactive manner, you need to pass --extra-vars
with the variables and their value when calling the playbook (ex: --extra-vars 'webusername=foo webpassword=bar'
).
文档中对此进行了解释.
对于任何
vars_prompt
变量的提示将被跳过 已通过命令行--extra-vars
定义的变量 选项,或从非交互式会话(例如cron)运行时 或Ansible塔).请参见 /Variables/章节.
Prompts for individual
vars_prompt
variables will be skipped for any variable that is already defined through the command line--extra-vars
option, or when running from a non-interactive session (such as cron or Ansible Tower). See Passing Variables On The Command Line in the /Variables/ chapter.
对于密码,我知道无法直接传递密码,但是例如可以使用环境变量.
For the password I understand that is not possible to pass it directly but you can for instance use an environment variable.
这篇关于詹金斯的提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!