我需要一个目录中与特定模式匹配的文件,下面的剧本在命令行中工作,但在Jenkins中执行时失败。
有没有一个解决方案可以使用包含通配符值的Ansible剧本在Jenkins中执行shell命令?
Jenkins2.319.2
这是我的战术手册:
- name: A Playbook to build artifacts
hosts: targetservers
vars:
path_to_files: /opt/app/jenkins/sandbox_project_12345
debugger: never
become: yes
become_user: root
gather_facts: no
remote_user: test_user
ignore_errors: no
tasks:
- name: ping all
ping:
- name: List of files to be copied
shell: bash -c 'ls {{ path_to_files + "/*006*" }}'
delegate_to: localhost
register: files_to_be_copied
- name: Loop through files
debug: msg="{{ "Item = " + item }}"
with_items: "{{ files_to_be_copied.stdout_lines }}"
```
TASK [List of files to be copied]**********************************************
fatal: [server.company_name.com -> localhost]: FAILED! => {"changed": true, "cmd": "bash -c 'ls /opt/app/jenkins/sandbox_project_12345/2212.00*006*'", "delta": "0:00:00.010146", "end": "2022-10-25 14:34:54.516178", "msg": "non-zero return code", "rc": 2, "start": "2022-10-25 14:34:54.506032", "stderr": "ls: cannot access /opt/app/jenkins/sandbox_project_12345/2212.00*006*: No such file or directory", "stderr_lines": ["ls: cannot access /opt/app/jenkins/sandbox_project_12345/2212.00*006*: No such file or directory"], "stdout": "", "stdout_lines": []}
1条答案
按热度按时间2w3kk1z51#
获取错误消息:
我将要开始研究假设是: