diff --git a/cmf/all/.cikit/ci/post-deploy.yml b/cmf/all/.cikit/ci/post-deploy.yml index f3bc663e..1536e5e0 100644 --- a/cmf/all/.cikit/ci/post-deploy.yml +++ b/cmf/all/.cikit/ci/post-deploy.yml @@ -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; diff --git a/scripts/roles/cikit-gitlab-ci/templates/.gitlab-ci.yml.j2 b/scripts/roles/cikit-gitlab-ci/templates/.gitlab-ci.yml.j2 index 63041481..45bff27a 100644 --- a/scripts/roles/cikit-gitlab-ci/templates/.gitlab-ci.yml.j2 +++ b/scripts/roles/cikit-gitlab-ci/templates/.gitlab-ci.yml.j2 @@ -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. diff --git a/scripts/roles/cikit-jenkins/templates/jobs/builder.xml.j2 b/scripts/roles/cikit-jenkins/templates/jobs/builder.xml.j2 index d081cad0..eb532b9e 100644 --- a/scripts/roles/cikit-jenkins/templates/jobs/builder.xml.j2 +++ b/scripts/roles/cikit-jenkins/templates/jobs/builder.xml.j2 @@ -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" @@ -122,9 +128,6 @@ fi if ${RUN_TESTS}; then cikit tests "${ARGS[@]}" --run --headless fi - -deploy_hook post-deploy -sudo chown -R jenkins:jenkins ./ diff --git a/scripts/roles/cikit-jenkins/templates/jobs/pr_builder.xml.j2 b/scripts/roles/cikit-jenkins/templates/jobs/pr_builder.xml.j2 index a854f6e2..8a318c56 100644 --- a/scripts/roles/cikit-jenkins/templates/jobs/pr_builder.xml.j2 +++ b/scripts/roles/cikit-jenkins/templates/jobs/pr_builder.xml.j2 @@ -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" @@ -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 ./ diff --git a/scripts/roles/cikit-sniffers/defaults/main.yml b/scripts/roles/cikit-sniffers/defaults/main.yml index 2571dfb6..43e6f5c7 100644 --- a/scripts/roles/cikit-sniffers/defaults/main.yml +++ b/scripts/roles/cikit-sniffers/defaults/main.yml @@ -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 @@ -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 diff --git a/scripts/roles/cikit-sniffers/tasks/main.yml b/scripts/roles/cikit-sniffers/tasks/main.yml index 40dfe590..fe62d411 100644 --- a/scripts/roles/cikit-sniffers/tasks/main.yml +++ b/scripts/roles/cikit-sniffers/tasks/main.yml @@ -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