This seems to have been some sort of quoting issue.

After much troubleshooting, I found the working solution:

  changed_when:
    - ((jjb_update.stderr_lines | regex_replace('.*jobs
updated.\\s+(\\d+).*', '\\1')) != '0' )

--
Shaun


On Sat, Nov 30, 2019 at 1:30 AM Kai Stian Olstad <
[email protected]> wrote:

> On 30.11.2019 00:16, senorsmile wrote:
> > - hosts: localhost
> >    gather_facts: False
> >    tasks:
> >
> >    - name: Update Jenkins-Jobs on Jenkins Master - docker container
> >      command: |
> >        echo "INFO:jenkins_jobs.cli.subcommand.update:Updating jobs in
> > ['./jobs/'] ([])
> >              INFO:root:Caching type parameters of parameters =
> > jenkins_jobs.modules.parameters:Parameters
> >              INFO:root:Caching type builders of builders =
> > jenkins_jobs.modules.builders:Builders
> >              INFO:jenkins_jobs.builder:Number of jobs generated:  1
> >              INFO:jenkins_jobs.cli.subcommand.update:Number of jobs
> updated:
> > 0
> >              INFO:jenkins_jobs.builder:Number of views generated:  0
> >              INFO:jenkins_jobs.cli.subcommand.update:Number of views
> > updated: 0
> >        "
> >      register: jjb_update
> >      changed_when:
> >        - ( jjb_update.stdout_lines | regex_replace('.*jobs
> updated.\s+(\d+).*', '\1') != '0' )
>
> jjb_update.stdout_lines is a list and the regex_replace filter work on
> strings, so it probably should have failed.
>
> You can use the search test instead on stdout
>
>    changed_when: jjb_update.stdout is not search('jobs updated:.0')
>
> --
> Kai Stian Olstad
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/RXmtqMg_pl4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/92a3f484-9739-ae82-37eb-237e306277f5%40olstad.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAMQv9hDagUf6F4rNi%3D2PH%2B%2BaByDsFe-mtKVz%2BgACHNKY9V9OpQ%40mail.gmail.com.

Reply via email to