Skip to content

Commit

Permalink
#147: Run "post-deploy.yml" even if a build failed
Browse files Browse the repository at this point in the history
  • Loading branch information
BR0kEN- committed Jul 5, 2018
1 parent d10d2ce commit 6932a97
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
1 change: 1 addition & 0 deletions cmf/all/.cikit/ci/post-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# the same set of input variables but will run early, before any other tasks.
#
# Available variables:
# - rc: an exit code of the build process. If it's not "0" then a build failed;
# - dist: an absolute path to the project's destination;
# - env: a name of the environment being built;
# - site-url: a URL of a website being built;
Expand Down
1 change: 1 addition & 0 deletions scripts/roles/cikit-gitlab-ci/templates/.gitlab-ci.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ build/run:
- export BUILD_ACTIONS="$(php -r "echo json_encode(array_map('trim', array_filter(explode(PHP_EOL, '$(git log -n1 --pretty=%B | awk -vRS="]" -vFS="[" '{print $2}')'))));")"
# Dump all available variables for debugging purposes.
- env
# @todo Add "trap" to run "post-deploy" anyway.
# @todo Unify hooks triggers as it's done for Jenkins.
- [ -f "${CI_PROJECT_DIR}/.cikit/ci/pre-deploy.yml" ] && cikit "${CI_PROJECT_DIR}/.cikit/ci/pre-deploy.yml" --site-url="${CI_ENVIRONMENT_URL}" --build-id="${CI_ENVIRONMENT_NAME}" --workspace="${CI_PROJECT_DIR}" --dist="${DESTINATION}"
# Reinstall a project.
Expand Down
11 changes: 7 additions & 4 deletions scripts/roles/cikit-jenkins/templates/jobs/builder.xml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,16 @@ deploy_hook() {
local HOOK_PLAYBOOK="$WORKSPACE/.cikit/ci/$1.yml"

if [ -f "$HOOK_PLAYBOOK" ]; then
cikit "$HOOK_PLAYBOOK" "${ARGS[@]}" --dist="$DESTINATION"
cikit "$HOOK_PLAYBOOK" "${ARGS[@]}" --dist="$DESTINATION" --rc="$2"
fi
}

handle_shutdown() {
deploy_hook post-deploy $?
sudo chown -R jenkins:jenkins "$WORKSPACE"
}

trap handle_shutdown EXIT
deploy_hook pre-deploy
cikit reinstall "${ARGS[@]}" --reinstall-mode="$BUILD_MODE"

Expand All @@ -122,9 +128,6 @@ fi
if ${RUN_TESTS}; then
cikit tests "${ARGS[@]}" --run --headless
fi

deploy_hook post-deploy
sudo chown -R jenkins:jenkins ./
</command>
</hudson.tasks.Shell>
</builders>
Expand Down
12 changes: 7 additions & 5 deletions scripts/roles/cikit-jenkins/templates/jobs/pr_builder.xml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,16 @@ deploy_hook() {
local HOOK_PLAYBOOK="$WORKSPACE/.cikit/ci/$1.yml"

if [ -f "$HOOK_PLAYBOOK" ]; then
cikit "$HOOK_PLAYBOOK" "${ARGS[@]}" --dist="$DESTINATION"
cikit "$HOOK_PLAYBOOK" "${ARGS[@]}" --dist="$DESTINATION" --rc="$2"
fi
}

handle_shutdown() {
deploy_hook post-deploy $?
sudo chown -R jenkins:jenkins "$WORKSPACE"
}

trap handle_shutdown EXIT
deploy_hook pre-deploy
cikit reinstall "${ARGS[@]}" --actions="$BUILD_ACTIONS"

Expand All @@ -130,10 +136,6 @@ sudo rsync --delete -ra ./ "$DESTINATION/"
sudo chown -R www-data:jenkins $_

cikit sniffers "${ARGS[@]}"

# Move reports to the website directory.
deploy_hook post-deploy
sudo chown -R jenkins:jenkins ./
</command>
</hudson.tasks.Shell>
</builders>
Expand Down
4 changes: 3 additions & 1 deletion scripts/roles/cikit-sniffers/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cikit_sniffers:
Drupal:
version: 8.x-2.x
repo: git://git.drupal.org/project/coder.git
build: composer install
DrupalSecure:
version: master
repo: http://git.drupal.org/sandbox/coltrane/1921926.git
Expand All @@ -25,5 +26,6 @@ cikit_sniffers:
version: master
repo: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git
HTML:
version: 2.1.1
version: 2.2.0
repo: https://github.com/squizlabs/HTML_CodeSniffer.git
build: npm install && ./node_modules/.bin/grunt build
7 changes: 7 additions & 0 deletions scripts/roles/cikit-sniffers/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
version: "{{ item.value.version }}"
with_dict: "{{ cikit_sniffers.coding_standards.list }}"

- name: "Build '{{ item.key }}'"
shell: "{{ item.value.build }}"
args:
chdir: "{{ cikit_sniffers.coding_standards.dest }}/{{ item.key }}"
when: item.value.build is defined
with_dict: "{{ cikit_sniffers.coding_standards.list }}"

- name: Create HTMLCS binary
template:
src: htmlcs.j2
Expand Down

0 comments on commit 6932a97

Please sign in to comment.