Commit c74f2ec8 authored by Alexandre Burgoni's avatar Alexandre Burgoni
Browse files

Update LinkChecker docs & vars

parent f1a662bf
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -2,10 +2,13 @@

## Description

Using this job you will be able to detect most (see [here](#types-of-link-verified)) broken links in your **Markdown** or **HTML** files.

It uses the tool [`Liche`](https://github.com/raviqqe/liche){:target="_blank"} in [Go](https://golang.org/){:target="_blank"} to test and find the links in your documents. In its default state, this job will analyze your whole project for eligible files to verify.

## How to use it

1. My first step into the job
1. Have `.md` or `.html` files in your project
2. Add the corresponding URL to your `.gitlab-ci.yml` file (see [Getting
   started](/getting-started)). Example:

@@ -30,7 +33,16 @@

| Name | Description | Default |
| ---- | ----------- | ------- |
| ` ` <img width=450/> |  | ` ` |
| `LICHE_DIRECTORY` <img width=450/> | Path to the directory to be scanned | ` ` |
| `LICHE_FILES` | A list of files (separated with spaces) to scan. It can be used with `LICHE_DIRECTORY` | ` ` |
| `LICHE_EXCLUDE` | A [regular expression](https://en.wikipedia.org/wiki/Regular_expression){:target="_blank"} | ` ` |
| `LICHE_PRINT_OK` | In addition to broken links, it will add not-broken links in the report (see [artifacts](#artifacts)) | `true` |
| `LICHE_RECURSIVE` | When `LICHE_DIRECTORY` is filled it will search for files recursively  | `true` |
| `FAIL_ON_BROKEN` | Make your pipeline fails when a broken link is found | `false` |
| `LICHE_OPTIONS` | Additional options (see [options](https://github.com/raviqqe/liche){:target="_blank"}) | ` ` |
| `REPORT_OUTPUT` | Report file's name | `junit-report.xml` |

### Types of link verified

### Artifacts

+7 −5
Original line number Diff line number Diff line
@@ -12,9 +12,10 @@ links_checker:
      LICHE_DIRECTORY: ""
      LICHE_FILES: ""
      LICHE_EXCLUDE: ""
      LICHE_WRITE_OK: "true"
      LICHE_PRINT_OK: "true"
      LICHE_OPTIONS: ""
      FAIL_ON_ERROR: "false"
      LICHE_RECURSIVE: "true"
      FAIL_ON_BROKEN: "false"
      REPORT_OUTPUT: "junit-report.xml"
  script:
      - apk add --update nodejs npm curl && npm install junit-report-builder
@@ -33,7 +34,7 @@ links_checker:
                  echo "Directory specified ${LICHE_DIRECTORY} does not exist, exit"
                  exit 1
              fi
              add_option "-r ${CI_PROJECT_DIR}/${LICHE_DIRECTORY}"; 
              add_option "${CI_PROJECT_DIR}/${LICHE_DIRECTORY}"; 
          fi
      - |
          if [ ! -z "${LICHE_FILES}" ]; then
@@ -47,7 +48,8 @@ links_checker:
              done
          fi
      - if [ ! -z ${LICHE_EXCLUDE} ]; then add_option "-x \"${LICHE_EXCLUDE}\""; fi
      - if [ ${LICHE_WRITE_OK} = "true" ]; then add_option "-v"; fi
      - if [ ${LICHE_PRINT_OK} = "true" ]; then add_option "-v"; fi
      - if [ ${LICHE_RECURSIVE} = "true" ]; then add_option "-r"; fi

      - |
          if liche ${LICHE_OPTIONS} > linkchecker_logs 2>&1; then
@@ -56,7 +58,7 @@ links_checker:
          else
              generate_report;
              echo "Errors found in checked files";
              if [ ${FAIL_ON_ERROR} = "true" ]; then exit 1; fi
              if [ ${FAIL_ON_BROKEN} = "true" ]; then exit 1; fi
          fi
  artifacts:
      when: always