forked from MarkEWaite/jenkins-bugs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
82 lines (73 loc) · 3.03 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<project name="jenkins-bugs-master-branch" default="sync" basedir=".">
<property environment="env"/>
<target name="is-first-build">
<condition property="first.build">
<equals arg1="${env.BUILD_NUMBER}" arg2="1"/>
</condition>
</target>
<!-- Check environment variables only in builds 2+ -->
<target name="check-non-initial-build" description="Check git env vars at build 2+" depends="is-first-build" if="env.JENKINS_URL" unless="first.build">
<fail message="GIT_PREVIOUS_COMMIT not set" unless="env.GIT_PREVIOUS_COMMIT"/>
<fail message="GIT_PREVIOUS_SUCCESSFUL_COMMIT not set" unless="env.GIT_PREVIOUS_SUCCESSFUL_COMMIT"/>
</target>
<!-- Check environment variables in all builds -->
<target name="check-git-env-vars" description="Check all git env vars" depends="check-non-initial-build" if="env.JENKINS_URL">
<fail message="GIT_AUTHOR_EMAIL not set" unless="env.GIT_AUTHOR_EMAIL"/>
<fail message="GIT_AUTHOR_NAME not set" unless="env.GIT_AUTHOR_NAME"/>
<fail message="GIT_BRANCH not set" unless="env.GIT_BRANCH"/>
<fail message="GIT_COMMIT not set" unless="env.GIT_COMMIT"/>
<fail message="GIT_COMMITTER_EMAIL not set" unless="env.GIT_COMMITTER_EMAIL"/>
<fail message="GIT_COMMITTER_NAME not set" unless="env.GIT_COMMITTER_NAME"/>
<fail message="GIT_LOCAL_BRANCH not set" unless="env.GIT_LOCAL_BRANCH"/>
<fail message="GIT_URL not set" unless="env.GIT_URL"/>
<echo>GIT_ env var checks all passed</echo>
</target>
<!-- Synchronize repositories -->
<target name="sync" description="Synchronize git repositories">
<git command="pull">
<args>
<arg value="--all"/>
<arg value="--prune"/>
</args>
</git>
</target>
<target name="increment" description="Increment build number">
<buildnumber/>
<git command="commit">
<args>
<arg value="-m"/>
<arg value="[${ant.project.name}] ${user.name} build++, was ${build.number}"/>
<arg value="build.number"/>
</args>
</git>
</target>
<!-- Info about this repository -->
<target name="info" description="Report info about this repo">
<echo>java is ${java.version}</echo>
<echo>user dir is ${user.dir}</echo>
<git command="branch" />
<!-- JENKINS-41906 reports that master branch built without
any commits. This reports commits on this branch in the last 15
minutes -->
<echo>Displaying git log messages on this branch from last 15 minutes</echo>
<git command="log">
<args>
<arg value="--since='15 minutes ago'"/>
</args>
</git>
<echo>End of git log messages on this branch from last 15 minutes</echo>
</target>
<!-- From https://gist.github.com/davejlong/874521 -->
<macrodef name="git">
<attribute name="command" />
<attribute name="dir" default="" />
<element name="args" optional="true" />
<sequential>
<echo message="git @{command}" />
<exec executable="git" dir="@{dir}">
<arg value="@{command}" />
<args/>
</exec>
</sequential>
</macrodef>
</project>