本文整理汇总了Java中hudson.util.ArgumentListBuilder类的典型用法代码示例。如果您正苦于以下问题:Java ArgumentListBuilder类的具体用法?Java ArgumentListBuilder怎么用?Java ArgumentListBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArgumentListBuilder类属于hudson.util包,在下文中一共展示了ArgumentListBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getArgs
import hudson.util.ArgumentListBuilder; //导入依赖的package包/类
private ArgumentListBuilder getArgs() {
ArgumentListBuilder args = new ArgumentListBuilder();
String command, options;
args.clear();
options = getOptions(this.oFile, this.target, this.dump,
this.symbol, this.enAll, this.enWarn, this.enStyle,
this.enPerformance, this.enPortability, this.enInfo,
this.enUnusedFunc, this.enMissingInc,
this.force, this.includeDir, this.inconclusive, this.quiet,
this.posix, this.c89, this.c99, this.c11, this.cpp03, this.cpp11,
this.unmatchSuppress, this.unusedFunc, this.varScope,
this.verbose, this.xml, this.xmlVer);
if (!getDescriptor().getUseDefault() && (getDescriptor().getExePath() == null)) {
command = getDescriptor().getExePath();
} else {
command = "cppcheck";
}
args.addTokenized(command + options);
return args;
}
示例2: perform
import hudson.util.ArgumentListBuilder; //导入依赖的package包/类
@Override
public void perform(Run<?, ?> build, FilePath workspace, Launcher launcher, TaskListener listener) {
/*
// This also shows how you can consult the global configuration of the builder
if (getDescriptor().getUseFrench()) {
listener.getLogger().println("Bonjour, " + oFile + "!");
} else {
listener.getLogger().println("Hello, " + oFile + "!");
}
*/
listener.getLogger().println("[Cppchecker] " + "Starting the cppcheck.");
try {
ArgumentListBuilder args = getArgs();
OutputStream out = listener.getLogger();
FilePath of = new hudson.FilePath(workspace.getChannel(), workspace + "/" + this.oFile.trim());
launcher.launch().cmds(args).stderr(of.write()).stdout(out).pwd(workspace).join();
} catch (IOException | InterruptedException ex) {
Logger.getLogger(Cppchecker.class.getName()).log(Level.SEVERE, null, ex);
}
listener.getLogger().println("[Cppchecker] " + "Ending the cppcheck.");
}
示例3: hasContainer
import hudson.util.ArgumentListBuilder; //导入依赖的package包/类
@Override
public boolean hasContainer(Launcher launcher, String id) throws IOException, InterruptedException {
if (StringUtils.isEmpty(id)) {
return false;
}
ArgumentListBuilder args = new ArgumentListBuilder()
.add("inspect", "-f", "'{{.Id}}'", id);
ByteArrayOutputStream out = new ByteArrayOutputStream();
int status = launchHyperCLI(launcher, args)
.stdout(out).stderr(launcher.getListener().getLogger()).join();
if (status != 0) {
return false;
} else {
return true;
}
}
示例4: execInSlaveContainer
import hudson.util.ArgumentListBuilder; //导入依赖的package包/类
@Override
public Proc execInSlaveContainer(Launcher launcher, String containerId, Launcher.ProcStarter starter) throws IOException, InterruptedException {
ArgumentListBuilder args = new ArgumentListBuilder()
.add("exec", containerId);
args.add("env").add(starter.envs());
List<String> originalCmds = starter.cmds();
boolean[] originalMask = starter.masks();
for (int i = 0; i < originalCmds.size(); i++) {
boolean masked = originalMask == null ? false : i < originalMask.length ? originalMask[i] : false;
args.add(originalCmds.get(i), masked);
}
Launcher.ProcStarter procStarter = launchHyperCLI(launcher, args);
if (starter.stdout() != null) {
procStarter.stdout(starter.stdout());
}
return procStarter.start();
}
示例5: launch
import hudson.util.ArgumentListBuilder; //导入依赖的package包/类
private LaunchResult launch(@CheckForNull @Nonnull EnvVars launchEnv, boolean quiet, FilePath pwd, @Nonnull ArgumentListBuilder args) throws IOException, InterruptedException {
// Prepend the docker command
args.prepend(DockerTool.getExecutable(toolName, node, launcher.getListener(), launchEnv));
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Executing docker command {0}", args.toString());
}
Launcher.ProcStarter procStarter = launcher.launch();
if (pwd != null) {
procStarter.pwd(pwd);
}
LaunchResult result = new LaunchResult();
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayOutputStream err = new ByteArrayOutputStream();
result.setStatus(procStarter.quiet(quiet).cmds(args).envs(launchEnv).stdout(out).stderr(err).start().joinWithTimeout(CLIENT_TIMEOUT, TimeUnit.SECONDS, launcher.getListener()));
final String charsetName = Charset.defaultCharset().name();
result.setOut(out.toString(charsetName));
result.setErr(err.toString(charsetName));
return result;
}
示例6: executeGet
import hudson.util.ArgumentListBuilder; //导入依赖的package包/类
public void executeGet(AbstractBuild build, final Launcher launcher, final BuildListener listener) throws Exception {
ArgumentListBuilder args = new ArgumentListBuilder();
EnvVars env = build.getEnvironment(listener);
setupWorkspace(build, env);
String executable = getExecutable(env, listener, launcher);
args.add(executable);
args.add("get");
if (doGetUpdate) {
args.add("-update");
}
LOGGER.info("Launching Terraform Get: "+args.toString());
int result = launcher.launch().pwd(workspacePath.getRemote()).cmds(args).stdout(listener).join();
if (result != 0) {
throw new Exception("Terraform Get failed: "+ result);
}
}
示例7: executeApply
import hudson.util.ArgumentListBuilder; //导入依赖的package包/类
public void executeApply(AbstractBuild build, final Launcher launcher, final BuildListener listener) throws Exception {
ArgumentListBuilder args = new ArgumentListBuilder();
EnvVars env = build.getEnvironment(listener);
String executable = getExecutable(env, listener, launcher);
args.add(executable);
args.add("apply");
args.add("-input=false");
args.add("-state="+stateFile.getRemote());
if (!isNullOrEmpty(getVariables())) {
variablesFile = workingDirectory.createTextTempFile("variables", ".tfvars", evalEnvVars(getVariables(), env));
args.add("-var-file="+variablesFile.getRemote());
}
LOGGER.info("Launching Terraform Apply: "+args.toString());
int result = launcher.launch().pwd(workspacePath.getRemote()).cmds(args).stdout(listener).join();
if (result != 0) {
throw new Exception("Terraform Apply failed: "+ result);
}
}
示例8: appendCredentials
import hudson.util.ArgumentListBuilder; //导入依赖的package包/类
protected ArgumentListBuilder appendCredentials(ArgumentListBuilder args)
throws IOException, InterruptedException
{
if (credentials instanceof SSHUserPrivateKey) {
SSHUserPrivateKey privateKeyCredentials = (SSHUserPrivateKey)credentials;
key = Utils.createSshKeyFile(key, ws, privateKeyCredentials, copyCredentialsInWorkspace);
args.add("--private-key").add(key);
args.add("-u").add(privateKeyCredentials.getUsername());
if (privateKeyCredentials.getPassphrase() != null) {
script = Utils.createSshAskPassFile(script, ws, privateKeyCredentials, copyCredentialsInWorkspace);
environment.put("SSH_ASKPASS", script.getRemote());
// inspired from https://github.com/jenkinsci/git-client-plugin/pull/168
// but does not work with MacOSX
if (! environment.containsKey("DISPLAY")) {
environment.put("DISPLAY", ":123.456");
}
}
} else if (credentials instanceof UsernamePasswordCredentials) {
args.add("-u").add(credentials.getUsername());
args.add("-k");
}
return args;
}
示例9: buildCommandLine
import hudson.util.ArgumentListBuilder; //导入依赖的package包/类
@Override
protected ArgumentListBuilder buildCommandLine()
throws InterruptedException, AnsibleInvocationException, IOException
{
ArgumentListBuilder args = new ArgumentListBuilder();
prependPasswordCredentials(args);
appendExecutable(args);
appendHostPattern(args);
appendInventory(args);
appendHModule(args);
appendModuleCommand(args);
appendSudo(args);
appendForks(args);
appendCredentials(args);
appendAdditionalParameters(args);
return args;
}
示例10: buildCommandLine
import hudson.util.ArgumentListBuilder; //导入依赖的package包/类
@Override
protected ArgumentListBuilder buildCommandLine() throws InterruptedException, AnsibleInvocationException, IOException {
ArgumentListBuilder args = new ArgumentListBuilder();
prependPasswordCredentials(args);
appendExecutable(args);
appendPlaybook(args);
appendInventory(args);
appendLimit(args);
appendTags(args);
appendSkippedTags(args);
appendStartTask(args);
appendSudo(args);
appendForks(args);
appendCredentials(args);
appendAdditionalParameters(args);
return args;
}
示例11: should_generate_simple_invocation
import hudson.util.ArgumentListBuilder; //导入依赖的package包/类
@Test
public void should_generate_simple_invocation() throws Exception {
// Given
Inventory inventory = new InventoryPath("/tmp/hosts");
BuildListener listener = mock(BuildListener.class);
CLIRunner runner = mock(CLIRunner.class);
AbstractBuild<?,?> build = mock(AbstractBuild.class);
when(build.getEnvironment(any(TaskListener.class))).thenReturn(new EnvVars());
AnsibleAdHocCommandInvocation invocation = new AnsibleAdHocCommandInvocation("/usr/local/bin/ansible", build, listener);
invocation.setHostPattern("localhost");
invocation.setInventory(inventory);
invocation.setModule("ping");
invocation.setForks(5);
// When
invocation.execute(runner);
// Then
ArgumentCaptor<ArgumentListBuilder> argument = ArgumentCaptor.forClass(ArgumentListBuilder.class);
verify(runner).execute(argument.capture(), anyMap());
assertThat(argument.getValue().toString())
.isEqualTo("/usr/local/bin/ansible localhost -i /tmp/hosts -m ping -f 5");
}
示例12: should_generate_simple_invocation_with_env
import hudson.util.ArgumentListBuilder; //导入依赖的package包/类
@Test
public void should_generate_simple_invocation_with_env() throws Exception {
// Given
Inventory inventory = new InventoryPath("/tmp/hosts");
BuildListener listener = mock(BuildListener.class);
CLIRunner runner = mock(CLIRunner.class);
AbstractBuild<?,?> build = mock(AbstractBuild.class);
when(build.getEnvironment(any(TaskListener.class))).thenReturn(new EnvVars());
AnsibleAdHocCommandInvocation invocation = new AnsibleAdHocCommandInvocation("/usr/local/bin/ansible", build, listener);
invocation.setHostPattern("localhost");
invocation.setInventory(inventory);
invocation.setModule("ping");
invocation.setForks(5);
invocation.setColorizedOutput(true);
invocation.setHostKeyCheck(false);
invocation.setUnbufferedOutput(true);
// When
invocation.execute(runner);
// Then
ArgumentCaptor<Map> argument = ArgumentCaptor.forClass(Map.class);
verify(runner).execute(any(ArgumentListBuilder.class), argument.capture());
assertThat((Map<String, String>)argument.getValue())
.containsEntry("PYTHONUNBUFFERED", "1")
.containsEntry("ANSIBLE_FORCE_COLOR", "true")
.containsEntry("ANSIBLE_HOST_KEY_CHECKING", "False");
}
示例13: should_handle_private_key_credentials
import hudson.util.ArgumentListBuilder; //导入依赖的package包/类
@Test
@Ignore("build.getWorkspace() cannot be mocked")
public void should_handle_private_key_credentials() throws Exception {
// Given
Inventory inventory = new InventoryPath("/tmp/hosts");
SSHUserPrivateKey pkey = mock(SSHUserPrivateKey.class);
when(pkey.getUsername()).thenReturn("mylogin");
BuildListener listener = mock(BuildListener.class);
CLIRunner runner = mock(CLIRunner.class);
AbstractBuild<?,?> build = mock(AbstractBuild.class);
when(build.getEnvironment(any(TaskListener.class))).thenReturn(new EnvVars());
AnsibleAdHocCommandInvocation invocation = new AnsibleAdHocCommandInvocation("/usr/local/bin/ansible", build, listener);
invocation.setHostPattern("localhost");
invocation.setInventory(inventory);
invocation.setModule("ping");
invocation.setCredentials(pkey);
invocation.setForks(5);
// When
invocation.execute(runner);
// Then
ArgumentCaptor<ArgumentListBuilder> argument = ArgumentCaptor.forClass(ArgumentListBuilder.class);
verify(runner).execute(argument.capture(), anyMap());
assertThat(argument.getValue().toString())
.matches("/usr/local/bin/ansible localhost -i /tmp/hosts -m ping -f 5 --private-key .+ -u mylogin");
}
示例14: should_handle_variables
import hudson.util.ArgumentListBuilder; //导入依赖的package包/类
@Test
public void should_handle_variables() throws Exception {
// Given
Inventory inventory = new InventoryPath("/tmp/hosts");
BuildListener listener = mock(BuildListener.class);
CLIRunner runner = mock(CLIRunner.class);
AbstractBuild<?,?> build = mock(AbstractBuild.class);
EnvVars vars = new EnvVars();
vars.put("MODULE", "ping");
when(build.getEnvironment(any(TaskListener.class))).thenReturn(vars);
AnsibleAdHocCommandInvocation invocation = new AnsibleAdHocCommandInvocation("/usr/local/bin/ansible", build, listener);
invocation.setHostPattern("localhost");
invocation.setInventory(inventory);
invocation.setModule("${MODULE}");
invocation.setForks(5);
// When
invocation.execute(runner);
// Then
ArgumentCaptor<ArgumentListBuilder> argument = ArgumentCaptor.forClass(ArgumentListBuilder.class);
verify(runner).execute(argument.capture(), anyMap());
assertThat(argument.getValue().toString())
.isEqualTo("/usr/local/bin/ansible localhost -i /tmp/hosts -m ping -f 5");
}
示例15: execute
import hudson.util.ArgumentListBuilder; //导入依赖的package包/类
/**
* Execute a Drush command.
*/
protected boolean execute(ArgumentListBuilder args, TaskListener out) throws IOException, InterruptedException {
ProcStarter starter = launcher.launch().pwd(workspace).cmds(args);
if (out == null) {
// Output stdout/stderr into listener.
starter.stdout(listener);
} else {
// Output stdout into out.
// Do not output stderr since this breaks the XML formatting on stdout.
starter.stdout(out).stderr(NullOutputStream.NULL_OUTPUT_STREAM);
}
starter.join();
return true;
}