Skip to content
Permalink
Browse files

JENKINS-11813 : New option to allow to configure SYMROOT (With token …

…macro plugin support)
  • Loading branch information
aheritier committed Nov 28, 2011
1 parent dfd0a84 commit 3817940a3c020cc420ed2f3b55617d6d6509119e
@@ -45,6 +45,7 @@

import javax.servlet.ServletException;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -57,6 +58,7 @@
public final String configuration;
public final String target;
public final String sdk;
public final String symRoot;
public final String xcodeProjectPath;
public final String xcodeProjectFile;
public final String embeddedProfileFile;
@@ -68,8 +70,11 @@
public final String keychainPwd;

// Fields in config.jelly must match the parameter names in the "DataBoundConstructor"
/**
* @since 1.1
*/
@DataBoundConstructor
public XCodeBuilder(Boolean buildIpa, Boolean cleanBeforeBuild, String configuration, String target, String sdk, String xcodeProjectPath, String xcodeProjectFile, String embeddedProfileFile, String cfBundleVersionValue, String cfBundleShortVersionStringValue, Boolean unlockKeychain, String keychainPath, String keychainPwd) {
public XCodeBuilder(Boolean buildIpa, Boolean cleanBeforeBuild, String configuration, String target, String sdk, String xcodeProjectPath, String xcodeProjectFile, String embeddedProfileFile, String cfBundleVersionValue, String cfBundleShortVersionStringValue, Boolean unlockKeychain, String keychainPath, String keychainPwd, String symRoot) {
this.buildIpa = buildIpa;
this.sdk = sdk;
this.target = target;
@@ -83,6 +88,12 @@ public XCodeBuilder(Boolean buildIpa, Boolean cleanBeforeBuild, String configura
this.unlockKeychain = unlockKeychain;
this.keychainPath = keychainPath;
this.keychainPwd = keychainPwd;
this.symRoot = symRoot;
}

@Deprecated
public XCodeBuilder(Boolean buildIpa, Boolean cleanBeforeBuild, String configuration, String target, String sdk, String xcodeProjectPath, String xcodeProjectFile, String embeddedProfileFile, String cfBundleVersionValue, String cfBundleShortVersionStringValue, Boolean unlockKeychain, String keychainPath, String keychainPwd) {
this(buildIpa,cleanBeforeBuild,configuration,target,sdk,xcodeProjectPath,xcodeProjectFile,embeddedProfileFile,cfBundleVersionValue,cfBundleShortVersionStringValue,unlockKeychain,keychainPath,keychainPwd,null);
}

@Override
@@ -105,7 +116,23 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener lis
projectRoot = projectRoot.child(xcodeProjectPath);
}
listener.getLogger().println(Messages.XCodeBuilder_workingDir(projectRoot));
FilePath buildDirectory = projectRoot.child("build").child(configuration + "-iphoneos");

// Set the build directory and the symRoot
String symRootValue = null;
FilePath buildDirectory;
if (!StringUtils.isEmpty(symRoot)) {
// If not empty we use the Token Expansion to replace it
// https://wiki.jenkins-ci.org/display/JENKINS/Token+Macro+Plugin
try {
symRootValue = TokenMacro.expand(build, listener, symRoot).trim();
buildDirectory = new FilePath(new File(symRootValue)).child(configuration + "-iphoneos");
} catch (MacroEvaluationException e) {
listener.error(Messages.XCodeBuilder_symRootMacroError(e.getMessage()));
return false;
}
} else {
buildDirectory = projectRoot.child("build").child(configuration + "-iphoneos");
}

// XCode Version
int returnCode = launcher.launch().envs(envs).cmds(getDescriptor().getXcodebuildPath(), "-version").stdout(listener).pwd(projectRoot).join();
@@ -248,6 +275,13 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener lis
}
commandLine.add("build");

if (!StringUtils.isEmpty(symRootValue)) {
commandLine.add("SYMROOT="+symRootValue);
xcodeReport.append(", symRoot: ").append(symRootValue);
} else {
xcodeReport.append(", symRoot: DEFAULT");
}

listener.getLogger().println(xcodeReport.toString());
returnCode = launcher.launch().envs(envs).cmds(commandLine).stdout(reportGenerator.getOutputStream()).pwd(projectRoot).join();
if (reportGenerator.getExitCode() != 0) return false;
@@ -23,6 +23,7 @@
#
XCodeBuilder.xcodebuildNotFound=Cannot find xcodebuild with the configured path {0}.
XCodeBuilder.avgtoolNotFound=Cannot find agvtool with the configured path {0}.
XCodeBuilder.symRootMacroError=Failure while expanding macros for symRoot. Error: {0}
XCodeBuilder.unlockKeychainFailed=Unable to unlock the keychain.
XCodeBuilder.xcrunNotFound=Cannot find xcrun with the configured path {0}.
XCodeBuilder.cleaningBuildDir=Cleaning build directory: {0}
@@ -43,6 +43,11 @@
<f:textbox/>
</f:entry>

<f:entry title="${%SYMROOT}" field="symRoot"
description="Leave empty for default SYMROOT">
<f:textbox/>
</f:entry>

<f:entry title="${%Configuration}" field="configuration">
<f:textbox default="Release"/>
</f:entry>
@@ -0,0 +1,32 @@
<!--
~ The MIT License
~
~ Copyright (c) 2011 Ray Yamamoto Hilton
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in
~ all copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
~ THE SOFTWARE.
-->

<div>
<p>
You only need to supply this value if you want to specify the SYMROOT path to use.<br/>
If empty, the default SYMROOT path will be used (it could be different depending of your Xcode version).<br/>
Supports all macros from the <a href="https://wiki.jenkins-ci.org/display/JENKINS/Token+Macro+Plugin" target="_blank">Token Macro Plugin</a>.<br/>
For example you can use the value : ${ENV,var="WORKSPACE"}/build<br/>
</p>
</div>

0 comments on commit 3817940

Please sign in to comment.