Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a build task only when changes have been pulled from a git repository

Tags:

I have a C++ program hosted in Bitbucket git repository that I'm compiling with CMake. The current play can be seen below. It works fine except build-task is run every time the play is run. Instead I'd like build-task to run only when new software version is pulled by git-module. How I can tell in build-task if clone-task found new version ?

--- # tasks of role: foo  - name: clone repository   git: [email protected]:foo/foo.git        dest={{ foo.dir }}        accept_hostkey=yes  - name: create build dir   file: state=directory path={{ foo.build_dir }}  - name: build   command: "{{ item }} chdir={{ foo.build_dir }}"   with_items:     - cmake ..     - make 
like image 531
user272735 Avatar asked Apr 11 '14 13:04

user272735


1 Answers

You can register variable with output of clone task and invoke build task when state of clone task is changed

For example:

--- # tasks of role: foo  - name: clone repository   git: [email protected]:foo/foo.git        dest={{ foo.dir }}        accept_hostkey=yes   register: gitclone  - name: create build dir   file: state=directory path={{ foo.build_dir }}  - name: build   command: "{{ item }} chdir={{ foo.build_dir }}"   with_items:     - cmake ..     - make   when: gitclone.changed 
like image 173
ghloogh Avatar answered Oct 26 '22 09:10

ghloogh