Merge lp:~thomas-voss/jenkins.pbuilder.plugin/fix-973101 into lp:~thomas-voss/jenkins.pbuilder.plugin/trunk

Proposed by Thomas Voß
Status: Merged
Merge reported by: Thomas Voß
Merged at revision: not available
Proposed branch: lp:~thomas-voss/jenkins.pbuilder.plugin/fix-973101
Merge into: lp:~thomas-voss/jenkins.pbuilder.plugin/trunk
Diff against target: 196 lines (+40/-53)
2 files modified
src/main/java/com/ubuntu/builder/HelloWorldBuilder.java (+37/-53)
src/main/resources/com/ubuntu/builder/HelloWorldBuilder/config.jelly (+3/-0)
To merge this branch: bzr merge lp:~thomas-voss/jenkins.pbuilder.plugin/fix-973101
Reviewer Review Type Date Requested Status
Martin Mrazik (community) Approve
Review via email: mp+100749@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Martin Mrazik (mrazik) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/main/java/com/ubuntu/builder/HelloWorldBuilder.java'
2--- src/main/java/com/ubuntu/builder/HelloWorldBuilder.java 2012-03-22 11:09:35 +0000
3+++ src/main/java/com/ubuntu/builder/HelloWorldBuilder.java 2012-04-04 08:47:19 +0000
4@@ -64,6 +64,7 @@
5 private final String pbuilderSetupBranch;
6 private final String mainBranch;
7 private final String packagingBranch;
8+ private final boolean chrootedBuild;
9 private final String workDirectory;
10 private final String resultsDirectory;
11 // Fields in config.jelly must match the parameter names in the "DataBoundConstructor"
12@@ -71,6 +72,7 @@
13 public HelloWorldBuilder(String pbuilderSetupBranch,
14 String mainBranch,
15 String packagingBranch,
16+ boolean chrootedBuild,
17 String workDirectory,
18 String resultsDirectory) {
19
20@@ -80,6 +82,7 @@
21
22 this.workDirectory = workDirectory;
23 this.resultsDirectory = resultsDirectory;
24+ this.chrootedBuild = chrootedBuild;
25 this.name = null;
26 }
27
28@@ -102,6 +105,14 @@
29 return packagingBranch;
30 }
31
32+ public boolean IsChrootedBuild() {
33+ return chrootedBuild;
34+ }
35+
36+ public boolean GetChrootedBuild() {
37+ return chrootedBuild;
38+ }
39+
40 public String getWorkDirectory() {
41 return workDirectory;
42 }
43@@ -120,8 +131,9 @@
44 try {
45 envVars = build.getEnvironment(listener);
46 } catch(Exception e) {
47- listener.getLogger().println("Problem getting build env: " + envVars);
48+ listener.getLogger().println("Problem getting build env: " + e);
49 }
50+
51 String psb = pbuilderSetupBranch;
52 String mb = mainBranch;
53 String pb = packagingBranch;
54@@ -158,21 +170,6 @@
55 listener.getLogger().println("Problem branching or updating pbuilder setup.");
56 return false;
57 }
58- // Get the pbuilder setup
59- /*if(launcher.launch().
60- cmds("bzr",
61- "checkout",
62- pbuilderSetupBranch,
63- build.getWorkspace().child(this.CHECKOUT_DIRECTORY).toString()).
64- stdout(listener.getLogger()).
65- stderr(listener.getLogger()).
66- pwd(build.getWorkspace()).
67- join() != this.EXIT_SUCCESS) {
68-
69- listener.getLogger().println("Problem branching pbuilder setup ... aborting.");
70- return false;
71- }*/
72-
73 if(launcher.launch().
74 cmds("sudo",
75 "./Builder.sh",
76@@ -181,17 +178,18 @@
77 "-h",
78 "./hooks",
79 "-r",
80- resultDir.toString(),//"../results",
81+ resultDir.toString(),
82 "-m",
83 mb,
84 "-p",
85- pb).
86+ pb,
87+ chrootedBuild ? "-c" : "").
88 pwd(build.getWorkspace() + "/pbuilder_setup").
89 stdout(listener.getLogger()).
90 stderr(listener.getLogger()).
91 join() != this.EXIT_SUCCESS) {
92
93- listener.getLogger().println("Problem invoking pbuilder ... aborting.");
94+ listener.getLogger().println("pbuilder returned ERROR.");
95 return false;
96 }
97
98@@ -213,26 +211,33 @@
99 int exitCode = -1;
100
101 if(pbuilderSetupDir.exists()) {
102- exitCode = launcher.launch().
103+ /*exitCode = launcher.launch().
104 cmds("bzr",
105 "pull",
106 branch).
107 stdout(listener.getLogger()).
108 stderr(listener.getLogger()).
109 pwd(pbuilderSetupDir).
110- join();
111- } else {
112- exitCode = launcher.launch().
113- cmds("bzr",
114- "checkout",
115- branch,
116- pbuilderSetupDir.toString()).
117- stdout(listener.getLogger()).
118- stderr(listener.getLogger()).
119- pwd(build.getWorkspace()).
120- join();
121+ join();*/
122+
123+ try {
124+ pbuilderSetupDir.deleteRecursive();
125+ } catch(Exception e) {
126+ listener.getLogger().println("Problem deleting pbuilder setup dir: " + e);
127+ return false;
128+ }
129 }
130-
131+
132+ exitCode = launcher.launch().
133+ cmds("bzr",
134+ "checkout",
135+ branch,
136+ pbuilderSetupDir.toString()).
137+ stdout(listener.getLogger()).
138+ stderr(listener.getLogger()).
139+ pwd(build.getWorkspace()).
140+ join();
141+
142 return exitCode == EXIT_SUCCESS;
143 }
144
145@@ -255,15 +260,6 @@
146 @Extension // This indicates to Jenkins that this is an implementation of an extension point.
147 public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {
148 /**
149- * To persist global configuration information,
150- * simply store it in a field and call save().
151- *
152- * <p>
153- * If you don't want fields to be persisted, use <tt>transient</tt>.
154- */
155- private boolean useFrench;
156-
157- /**
158 * Performs on-the-fly validation of the form field 'name'.
159 *
160 * @param value
161@@ -353,21 +349,9 @@
162
163 @Override
164 public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
165- // To persist global configuration information,
166- // set that to properties and call save().
167- useFrench = formData.getBoolean("useFrench");
168- // ^Can also use req.bindJSON(this, formData);
169- // (easier when there are many fields; need set* methods for this, like setUseFrench)
170- save();
171 return super.configure(req,formData);
172 }
173
174- /**
175- * This method returns true if the global configuration says we should speak French.
176- */
177- public boolean useFrench() {
178- return useFrench;
179- }
180 }
181 }
182
183
184=== modified file 'src/main/resources/com/ubuntu/builder/HelloWorldBuilder/config.jelly'
185--- src/main/resources/com/ubuntu/builder/HelloWorldBuilder/config.jelly 2012-02-14 13:09:11 +0000
186+++ src/main/resources/com/ubuntu/builder/HelloWorldBuilder/config.jelly 2012-04-04 08:47:19 +0000
187@@ -19,6 +19,9 @@
188 <f:textbox />
189 </f:entry>
190 <f:optionalBlock title="Advanced Options" inline="true">
191+ <f:entry title="Build in a chroot'ed environment" field="chrootedBuild">
192+ <f:checkbox value="false"/>
193+ </f:entry>
194 <f:entry title="Work Directory" field="workDirectory">
195 <f:textbox value="work"/>
196 </f:entry>

Subscribers

People subscribed via source and target branches

to all changes: