Note: This plugin is available for Go servers running on Linux nodes having repoquery installed (part of the yum-utils package. Ubuntu, CentOS)
The Yum respository poller is a bundled package material plugin capable of polling yum repositories for rpm packages. Go server interacts with this plugin via package material plugin interfaces. The plugin makes use of a command similar to the following to poll the server. So it does not depend on the files that yum depends on e.g. files under /etc/yum.repos.d
repoquery --repofrompath=uuid,$REPO_URL --repoid=uuid -q $PACKAGE_SPEC -qf "%{LOCATION}..."
A given instance of polling is considered successful if repoquery returns a single package as output.
Using the Yum plugin for Nexus, it is possible to automatically create and publish Java artifacts as rpms using the rpm-maven-plugin and consume them on the deployment side using rpm or yum. There is a Go webinar that describes this set up.
Repo URL must be a valid http, https or file URL. This plugin looks for the presence of $REPO_URL/repodata/repomd.xml to ascertain validity. Basic authentication (user:password@domain/path) is supported for http and https repositories.
In case of this plugin, the package definition is completely determined by the package spec. The package spec may be in any of the following formats. Please refer the repoquery man page for details.
name
name.arch
name-ver
name-ver-rel
name-ver-rel.arch
name-epoch:ver-rel.arch
epoch:name-ver-rel.arch
Shell glob patterns may also be used. For example, say we have a component under development getting ready for release of version 1.2.0. We cut a branch for the release and bump up the version on trunk/master to 1.3.0. Thus, a package generated by trunk/master may look like mycomp-1.3.0-b72349-noarch.rpm while that generated by branch may look like mycomp-1.2.0-b72344-noarch.rpm. Now if we have a deployment pipeline that is only interested in 1.2 series packages, the package spec needs to be mycomp-1.2.* rather than just mycomp
The following rpm metadata is accessed by the plugin
The following information is made available as environment variables for tasks:
Individual plugins may provide additional info via additional environment variables.
Let's say we set up a repository named ORA pointing to http://public-yum.oracle.com/repo/OracleLinux/OL6/latest/x86\_64 and define a package gcc with a spec of gcc-4.* and set it up as material for a pipeline. To download the package locally on the agent, we could write a task like this:
[go] Start to execute task: <exec command="/bin/bash" >
<arg>-c</arg>
<arg>curl -o /tmp/gcc.rpm $GO_PACKAGE_ORA_GCC_LOCATION</arg>
</exec>
When the task executes on the agent, the environment variables get subsituted as below:
[go] Start to execute task: <exec command="/bin/bash" >
<arg>-c</arg>
<arg>curl -o /tmp/$GO_PACKAGE_ORA_GCC_LABEL.rpm $GO_PACKAGE_ORA_GCC_LOCATION</arg>
</exec>.
...
[go] setting environment variable 'GO_PACKAGE_ORA_GCC_LABEL' to value 'gcc-4.4.7-3.el6.x86_64'
[go] setting environment variable 'GO_REPO_ORA_GCC_REPO_URL' to value 'http://public-yum.oracle.com/repo/OracleLinux/OL6/latest/x86_64'
[go] setting environment variable 'GO_PACKAGE_ORA_GCC_PACKAGE_SPEC' to value 'gcc-4.*'
[go] setting environment variable 'GO_PACKAGE_ORA_GCC_LOCATION' to value 'http://public-yum.oracle.com/repo/OracleLinux/OL6/latest/x86_64/getPackage/gcc-4.4.7-3.el6.x86_64.rpm'
...
Or, to simply pass it as an argument to a deploy script on a remote server
<exec command="/bin/bash">
<arg>-c</arg>
<arg>ssh server "cd /to/dest/dir;deploy.sh $GO_PACKAGE_ORA_GCC_LOCATION"</arg>
</exec>
For self contained packages (no external dependencies other than what is already installed on the target node), it is just enough to do:
rpm -U /path/to/downloaded/pkg.rpm
On the other hand, if the package isn't self-contained, we'd run:
yum install $GO_PACKAGE_ORA_GCC_LABEL
This would require that /etc/yum.repos.d contain the repository definitions.
Although the support for package as material in Go isn't concerned with how the packages are created and published, here is a short set of pointers to information on the web.