How to specify a Git tag to be processed with Jenkins
TweetPosted on Friday Feb 21, 2014 at 08:35PM in Jenkins
Environment
- Jenkins 1.551
- Apache Maven 3.1.1
- git version 1.8.3.4 (Apple Git-47)
- Eclipse Kepler SR1
- Oracle JDK7u51
- OS X 10.9.1
Create a tag
Open context menu of the project - Team - Advanced - Tag
Enter tag name and Tag message, then click OK
To check created tag, Open context menu of the project - Team - Show in Repositories View
Confirm it appeared.
Modify a resource of HEAD
- In order to check that build will processed with the tag specified, so just do some modify a resource of HEAD.
- Make sure that you are in the master branch.
- Procedure to switch: Team - Switch To - master
- I have modified a resource that returns a message to Servlet. now it shows like that:
- After modify, we have to commit it.
Install Git Parameter Plugin
I got trouble that the plugin not showing any tags, so I have stopped using this plugin. there are some people who reporting same problem[6]. If skipped this, we can't see the list of tags in the repository, but we can specify a tag manually.
This plugin makes easy that specify a tag to be processed.
Make a Jenkins job
- Copy a job that created in previous post
- Check “This build is parameterized”
- Click “Add Parameter”
- Click “Git Parameter”
- Enter “tag” to “Name”
- Enter “*/master” to “Branch”
- Find the section named “Source Code Management”
- Enter “${tag}” to “Branch Specifier”
- Click “Save”
Try Parameterized build
- Click this:
- Select a tag that created above
- Click “ビルド”
Check console output of Jenkins
ユーザーanonymousが実行 ビルドします。 ワークスペース: /Users/Shared/Jenkins/Home/jobs/DeploySpecifiedTag/workspace Fetching changes from the remote Git repository Fetching upstream changes from file:///Users/kyle/gits1/hellojenkins Checking out Revision 9d88b2abe381c6e2c915bbbf0ddeec09119b6f04 (v1.0) Parsing POMs ...
- We can see that build was processed with tag named “v1.0”
References
- Can I get Jenkins to build a git tag from a passed in parameter? - Stack Overflow
- Jenkins and the Git Branch Selection - Sourceprojects.org
- Git Parameter Plugin - Jenkins - Jenkins Wiki
- Jenkinsで外部パラメータで与えたブランチを対象にビルドできるようにしておくと凄惨性あがって墓ドル - ( ꒪⌓꒪) ゆるよろ日記
- Hudson Growl Pluginでビルド結果をGrowlへ通知 | skmks
- Doesn't show any tags or revisions · Issue #2 · lukanus/git-parameter
Tags: jenkins