NAME
Git::MoreHooks::TriggerJenkins - Git::Hooks plugin to create and remove jobs from Jenkins
VERSION
version 0.003_001
SYNOPSIS
Use package via Git::Hooks interface (configuration in Git config file).
DESCRIPTION
This Git::Hooks plugin hooks itself to the hooks below to trigger a build in Jenkins for the current branch.
post-receive
This hook is invoked once for every branch in the remote repository after a successful
git push
. It's used to trigger a build or builds in Jenkins.
This plugin will create a Jenkins job with the name of the pushed branch. This job will then be triggered. The job is configured so that an email is sent to the user (the pushing user) at the end of the run. If the job already exists at Jenkins, its parameters are not updated. It is only triggered again.
STATUS
Package Git::MoreHooks is currently being developed so changes in the existing hooks are possible.
USAGE
To enable this hook add it to the githooks.plugin configuration option:
git config --add githooks.plugin Git::MoreHooks::TriggerJenkins
CONFIGURATION
The plugin is configured by the following git options.
githooks.triggerjenkins.ref REFSPEC
By default, all refs (branch names) are triggered. To trigger only some refs (usually some branch under refs/heads/), specify them with one or more instances of this option.
The refs can be specified as a complete ref name (e.g. "refs/heads/master") or by a regular expression starting with a caret (^
), which is kept as part of the regexp (e.g. "^refs/heads/(master|common\/TICKET-[0-9]+)").
TODO: Apply environment var USER to refs regular expression.
githooks.triggerjenkins.base-url URL
Specifies the Jenkins server HTTP URL. Only the base, e.g. http://jenkins.company. Required.
githooks.triggerjenkins.api-key USERNAME
Specifies the Jenkins server username. Required.
githooks.triggerjenkins.api-token TOKEN
Specifies the Jenkins server access token. Required.
githooks.triggerjenkins.project KEY
If set use this Jenkins project instead of extracting the name from ref name.
githooks.triggerjenkins.create-job [01]
If set to 0, only trigger build if the job already exists. If set to 1, create a new Jenkins job (project), unless it already exists). Default 1.
githooks.triggerjenkins.create-job-template FILENAME
If set, read the file as a Template Toolkit template file, and use it to create a new Jenkins job. The template needs to create a job config XML.
githooks.triggerjenkins.quiet [01]
If set to 1, do not print out anything to explain to user what was done. If set to 0, explain to user what was done and print out the link to the Jenkins job. Default 0.
githooks.triggerjenkins.force [01]
If set to 1, force a new build by cancelling the running build and scheduling a new. Default 0.
githooks.triggerjenkins.email-domain STRING
The domain name part of email address, i.e. "domain.com" in <user.name@domain.com>. If not present, notification email will not be configured into Jenkins job.
EXPORTS
This module exports routines that can be used directly without using all of Git::Hooks infrastructure.
handle_affected_refs GIT
This is the routine used to implement the post-receive
hook. It needs a Git::More
object for parameter.
SEE ALSO
REFERENCES
- This script is heavily inspired (and sometimes derived) from Gustavo Chaves' Git::Hooks::CheckJira.
NOTES
Thanks go to Gustavo Leite de Mendonça Chaves for his Git::Hooks package.
This hook first implemented for Cxense Sweden AB. Published to CPAN with Cxense Sweden AB's permission.
AUTHOR
'Mikko Koivunalho <mikko.koivunalho@iki.fi>'
COPYRIGHT AND LICENSE
This software is copyright (c) 2015 by Mikko Koivunalho.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 398:
L<> starts or ends with whitespace