Reads Jenkins version from the manifest and checks if an update center
for this version is available. If this is the case, latest plugin
versions are resolved from this update center. This ensures that
latest plugin versions are always compatible to the LTS version if
an LTS version is used.
Fixes#494
The new install-plugins.sh script removed the possibility to pass a file
containing a list of plugins that was given with the 'old' plugins.sh
script, although this functionality can be provided with only a few
lines more.
Now, when the install-plugins.sh script is called with only a single
argument that matches an existing file on the file system, it is assumed
that this file contains the list of plugins that should be installed,
newlines are replaced by spaces and this manipulated content is used as
the plugins list for further processing.
- Use modern `$()` syntax vs backticks [see [SC2006](https://github.com/koalaman/shellcheck/wiki/SC2006)]
- Always check for, and bail on, failures of `cd`. [see [SC2164](https://github.com/koalaman/shellcheck/wiki/SC2164)]
- Avoid `for foo in $(...)`, per [DontReadLinesWithFor](http://mywiki.wooledge.org/DontReadLinesWithFor)
- Avoid parsing `ls` to find subdirectories when `for d in "$dir"/*/` does the job; see also [ParsingLs](http://mywiki.wooledge.org/ParsingLs)
- `\s` is not specified in POSIX ERE (thus, not guaranteed to be available in bash-native regexes unless local platform's C library's regex implementation extends standard); use `[[:space:]]` instead.
- Avoid unnecessary deviations from POSIX sh specification:
- `echo -e` violates (not just extends) POSIX, doesn't work as expected in bash compiled with `--enable-xpg-echo-default`; [POSIX specification](http://pubs.opengroup.org/onlinepubs/009604599/utilities/echo.html) suggests `printf` as replacement (see APPLICATION USAGE section).
- `function` keyword not specified in POSIX, provides no benefit over standard-compliant syntax
Plugins with no dependencies (like the `ansicolor` plugin) will not have created a `resolved` flag.
`rm` will throw an error if the file does not exist. Set a `-f` flag to stop this.