I am having hard time getting the when condition work
I have couple of application names have 2 separate jenkins urls. My playbook has to check if the job exists on both the urls and then create the new job. I am successful until checking and getting the data if the job exists or not. NOw when trying to write the when condition I am failing.
scenario 1 : I have 2 repos, and 2 urls . in this case the job exists on one of the jenkins and then it has to skip the next step creating the new jenkins job , I need to get when condition working.
“msg”: “Job URLs: [‘https://test.com/job/repo1.teamCI/’]” “msg”: “Job URLs: ”
scenario 2: in this case the job doesn’t exist on any of the url, then it should go and create the job on specific jenkins which I mentioned in next play
“msg”: “Job URLs: ”
“msg”: “Job URLs: ”
TASK [Display Jobs] ************************************************************
ok: [localhost] => (item={‘changed’: False, ‘jobs’: , ‘invocation’: {‘module_args’: {‘glob’: 'repo1.', ‘url’: ‘https://url1.com’, ‘user’: ‘account’, ‘token’: ‘tokenvalue’, ‘validate_certs’: False, ‘name’: None, ‘color’: None, ‘password’: None}}, ‘failed’: False, ‘item’: [{‘url’: ‘https://url1.com’, ‘username’: ‘account’, ‘password_file’: ‘group_vars/password1.yml’}, ‘repo1’], ‘ansible_loop_var’: ‘item’}) => {
“ansible_loop_var”: “item”,
“item”: {
“ansible_loop_var”: “item”,
“changed”: false,
“failed”: false,
“invocation”: {
“module_args”: {
“color”: null,
“glob”: "repo1.",
“name”: null,
“password”: null,
“token”: “VALUE_SPECIFIED_IN_NO_LOG_PARAMETER”,
“url”: “url”,
“user”: “acount”,
“validate_certs”: false
}
},
“item”: [
{
“password_file”: “group_vars/password1.yml”,
“url”: “https://url1.com”,
“username”: “account”
},
“release.sqls”
],
“jobs”:
},
“item.jobs”:
}
I am checking item.jobs attribute