One of the most basic aspects of building a great website and keeping your customers happy is ensuring that your links work. I know this seems obviously, but you would be surprised at how many products and documentation sites don’t bother with this leaving their content littered with links to 404s.
The first thing you will need to do is setup linkchecker on your Jenkins machine. The easiest way to do this is to just install it globally as shown below. You will need SSH access to Jenkins for this step and you will need to install the python-dev package if it isn’t already installed. (Note, this step assumes Jenkins is running on Linux - this will also work on Windows, but with slightly different installation).
sudo apt-get install python-dev sudo pip install LinkChecker
To setup your build in Jenkins simply create a “New Item” and select “Freestyle Project”. Name the project whatever you like.
Configure the project with a few basic settings. Under build triggers, check “Build Periodically” and set a cron schedule like
H 0 * * *.
Next, set add a build step for “Execute Shell” and add the command to run linkchecker.
See the documentation on link checker for additional configuration on the CLI.
Set your desired notification preferences such as email or Slack when the build fails.
Save your configuration and run your project. The console output will show you if you have a broken link on your site like this.
Now you are set to provide a more usable site for your readers or customers.