Jenkins Plugins Resolver
Jenkins Plugin Resolver is a Go application to manage Jenkins projects.
This application manages your project dependencies, by resolving their transitive dependencies offline (no need to run Jenkins) and downloading the full list of dependencies in the Jenkins plugins folder.
Installation
You can either use the Go binaries, the Docker images or build the binaries yourself.
Binaries
go get github.com/bitnami-labs/jenkins-plugins-resolver/cmd/jpresolver
go get github.com/bitnami-labs/jenkins-plugins-resolver/cmd/jpdownloader
Docker
You need to install docker to use the docker images.
docker pull gcr.io/bitnami-labs/jenkins-plugins-resolver:latest
docker pull gcr.io/bitnami-labs/jenkins-plugins-downloader:latest
Build
You need to install bazel to build the binaries locally.
bazel build //cmd/jpresolver:jpresolver
bazel build //cmd/jpdownloader:jpdownloader
Usage
Write your project file with your project dependencies.
The jpresolver
tool will resolve the transitive dependencies for your project file.
jpresolver -optional
NOTE: The -optional
flag will enable resolving optional dependencies too.
Once it runs, it will generate a lock file describing all the project dependencies (required plugins and transitive dependencies).
The jpdownloader
tool is meant to run in a Jenkins environment. It will download the project dependencies in your Jenkins plugins folder (JENKINS_HOME/plugins
).
jpdownloader
Development
This project uses the standard go mod tool to manage and vendor Go dependencies.
Aditionally, it uses bazel to manage the project build.
Install bazel
Feel free to follow official installation instructions.
Building with bazel
Go code built with bazel requires all the .go
source files and all the imports to be declared in the BUILD.bazel
files that live in each Go package directory (and the same applies to the vendored sources).
Due to the predictability of Go this operation can be fully automated with gazelle
:
bazel run //:gazelle
This will create missing BUILD.bazel
files and patch existing ones (preserving comments and other rules).
NOTE: Remember to run it if you notice your bazel builds fail mentioing that the Go compiler cannot find a given package.
However, go mod
will remove these BUILD.bazel
files in vendored sources. In order to fix these, we have included a small snippet to maintain them easily:
scripts/go-vendor
Finally, you can build the project:
bazel build //cmd/jpresolver:jpresolver
bazel build //cmd/jpdownloader:jpdownloader
Running with bazel
Once you build them with bazel, you can run them from the bazel workspace:
bazel-bin/cmd/jpresolver/...
bazel-bin/cmd/jpdownloader/..
You can also run them with bazel directly:
bazel run //cmd/jpresolver:jpresolver -- -h
bazel run //cmd/jpdownloader:jpdownloader -- -h