diff options
author | Paul Bonaud <paul.bonaud@fretlink.com> | 2019-01-16 08:58:43 +0100 |
---|---|---|
committer | Paul Bonaud <paul.bonaud@fretlink.com> | 2019-01-16 14:41:44 +0100 |
commit | e9b912b42c831d3ca17ed6f0e718f0189ecabfb2 (patch) | |
tree | 3cf4a1e0e0b53f659e4b38defe037fac6f6ec69a /tasks/deploy.yml | |
parent | f23c13859727da0010fb668a9bb9d41ad56203e6 (diff) | |
download | ansible-clever-e9b912b42c831d3ca17ed6f0e718f0189ecabfb2.tar.gz ansible-clever-e9b912b42c831d3ca17ed6f0e718f0189ecabfb2.tar.zst ansible-clever-e9b912b42c831d3ca17ed6f0e718f0189ecabfb2.zip |
deploy: check "up-to-date" error to succeeded if last commit is OK
Diffstat (limited to 'tasks/deploy.yml')
-rw-r--r-- | tasks/deploy.yml | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/tasks/deploy.yml b/tasks/deploy.yml index 0ed97f8..b394e55 100644 --- a/tasks/deploy.yml +++ b/tasks/deploy.yml | |||
@@ -80,7 +80,41 @@ | |||
80 | - clever_deploy is failed | 80 | - clever_deploy is failed |
81 | - clever_deploy.stderr is defined | 81 | - clever_deploy.stderr is defined |
82 | 82 | ||
83 | - shell: clever activity | ||
84 | args: | ||
85 | chdir: "{{ clever_app_root }}" | ||
86 | environment: | ||
87 | CONFIGURATION_FILE: "{{ clever_login_file }}" | ||
88 | changed_when: false | ||
89 | register: clever_activity_result | ||
90 | |||
91 | - debug: | ||
92 | var: clever_activity_result.stdout_lines | ||
93 | |||
94 | - shell: git show -q --format=format:%H HEAD | ||
95 | args: | ||
96 | chdir: "{{ clever_app_root }}" | ||
97 | changed_when: false | ||
98 | register: current_commit_sha | ||
99 | |||
100 | # #### | ||
101 | # Expects all configuration to be located in the project's repository. | ||
102 | # Making a git commit bound to the same *configuration* and *executable* version. | ||
103 | # ## | ||
104 | - name: Fail if current commit is not the last deployed one | ||
105 | fail: | ||
106 | msg: "The clever deployment failed! Please check latest deploy activity logs above." | ||
107 | when: | ||
108 | - clever_deploy is failed | ||
109 | - clever_deploy.stderr is defined | ||
110 | - clever_deploy.stderr is search("application is up-to-date") | ||
111 | - clever_activity_valid_deploy_keyword in clever_activity_result.stdout_lines[-1] | ||
112 | - current_commit_sha.stdout_lines[-1] in clever_activity_result.stdout_lines[-1] | ||
113 | |||
83 | - name: Fail on deployment errors | 114 | - name: Fail on deployment errors |
84 | fail: | 115 | fail: |
85 | msg: "The clever deployment failed! Please check logs above." | 116 | msg: "The clever deployment failed! Please check logs above." |
86 | when: clever_deploy is failed | 117 | when: |
118 | - clever_deploy is failed | ||
119 | - clever_deploy.stderr is defined | ||
120 | - clever_deploy.stderr is not search("application is up-to-date") | ||