我是 Jenkins 新手,我想使用节点执行命令,但出现以下错误: java.io.IOException:批处理脚本只能在 Windows 节点上运行。
我的节点是:
node ('master') {
git 'https://github.com/bryaneibon/SeleniumWithCucucumber.git'
bat label: '', script: 'mvn verify'
}
Run Code Online (Sandbox Code Playgroud)
当我删除 bash 命令时,一切正常。
通过尝试使用命令:
node ('master') {
git 'https://github.com/bryaneibon/SeleniumWithCucucumber.git'
bat 'mvn verify'
}
Run Code Online (Sandbox Code Playgroud)
我有完全相同的错误。
精简日志如下:
No credentials specified
> /usr/local/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> /usr/local/bin/git config remote.origin.url https://github.com/bryaneibon/SeleniumWithCucucumber.git
# timeout=10
Fetching upstream changes from https://github.com/bryaneibon/SeleniumWithCucucumber.git
> /usr/local/bin/git --version # timeout=10
> /usr/local/bin/git fetch --tags --force --progress --
.
.
.
[Pipeline] bat
[Pipeline] …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的项目中实现 Jetpack Datastore。我正在使用该apha-01版本并且代码运行良好。然后我在Gradle文件中看到有新版本,所以我将其更新为alpha-03.
启动我的应用程序后,我遇到了另一个问题。我发现版本中没有找到 Proto 库,alpha-03所以我回滚到版本alpha-01。另外,我尝试过alpha-02。从那时起我遇到了以下错误:
Process: com.montymobile.sands, PID: 19928
java.io.IOException: /data/user/0/com.montymobile.sands/files/datastore/sns_preferences.preferences_pb.tmp could not be renamed to /data/user/0/com.montymobile.sands/files/datastore/sns_preferences.preferences_pb
at androidx.datastore.SingleProcessDataStore.writeData$datastore_core_release(SingleProcessDataStore.kt:304)
at androidx.datastore.SingleProcessDataStore.transformAndWrite(SingleProcessDataStore.kt:282)
at androidx.datastore.SingleProcessDataStore$actor$1.invokeSuspend(SingleProcessDataStore.kt:165)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Run Code Online (Sandbox Code Playgroud)
我注意到发生这种情况是因为我依次保存了两个不同的密钥,每个密钥都在一个协程中。当我评论第二个操作时,它起作用了。谁能解释为什么会发生这种情况?以及如何保存我想要的尽可能多的值?
任何帮助,将不胜感激。
我在C#(.NET Web服务)中创建一个文件,并且不想覆盖现有文件.
方法似乎是构建一个FileMode.CreateNew设置的FileStream.事实上,如果文件存在,它会抛出异常.
但是,如何识别此异常,而不是文件创建引发的其他可能异常?http://msdn.microsoft.com/en-us/library/47ek66wy.aspx上的文档将此案例列为"IOException",这显然是模糊的,因为其他事情可能会导致这种情况.
这里的答案是我捕获IOException然后只是做一个File.Exists?
我们来看看这个代码示例:
using System;
using System.IO;
namespace ConsoleApplication25
{
class Program
{
static void Main()
{
var bytes = new byte[] { 1, 2, 3 };
var trimChars = new[] { '"' };
var path = Environment.CommandLine.Trim().Trim(trimChars);
File.WriteAllBytes(path, bytes);
}
}
}
Run Code Online (Sandbox Code Playgroud)
运行此程序(程序试图覆盖自身)会导致抛出异常:
System.IO.IOException was unhandled
Message=The process cannot access the file 'F:\TEMP\ConsoleApplication25\ConsoleApplication25\bin\Debug\ConsoleApplication25.vshost.exe' because it is being used by another process.
Source=mscorlib
StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, …Run Code Online (Sandbox Code Playgroud) 在下面的代码中,我得到了Unreachable catch block for IOException.此异常不会从try语句体错误(下划线)与扔IOException在} catch (IOException e){我究竟做错了什么?
class driver {
public static void main(String[] args) {
// TODO Auto-generated method stub
Customer forrest = new Customer("Forrest Gump", 1,
"42 New Street, New York, New York");
Customer random = new Customer("Random Name", 2,
"44 New Street, New York, New York");
Customer customer[] = { null, forrest, random };
int whichOption = 1;
int id = 0;
char action = ' ';
char accSrc = …Run Code Online (Sandbox Code Playgroud) 我只是在滚动浏览带有分页的GridView/ListView加载图像时,由于Aquery库在Android 4.4 Kitkat上延迟加载图像而出现问题.
以下是日志:
12-03 10:39:43.678: W/AQuery(6261): reporting:java.io.IOException: open failed: EMFILE (Too many open files)
12-03 10:39:43.678: W/AQuery(6261): at java.io.File.createNewFile(File.java:946)
12-03 10:39:43.678: W/AQuery(6261): at com.androidquery.callback.AbstractAjaxCallback.getPreFile(AbstractAjaxCallback.java:1150)
12-03 10:39:43.678: W/AQuery(6261): at com.androidquery.callback.AbstractAjaxCallback.httpDo(AbstractAjaxCallback.java:1609)
12-03 10:39:43.678: W/AQuery(6261): at com.androidquery.callback.AbstractAjaxCallback.httpGet(AbstractAjaxCallback.java:1344)
12-03 10:39:43.678: W/AQuery(6261): at com.androidquery.callback.AbstractAjaxCallback.network(AbstractAjaxCallback.java:1243)
12-03 10:39:43.678: W/AQuery(6261): at com.androidquery.callback.AbstractAjaxCallback.networkWork(AbstractAjaxCallback.java:1082)
12-03 10:39:43.678: W/AQuery(6261): at com.androidquery.callback.AbstractAjaxCallback.backgroundWork(AbstractAjaxCallback.java:1014)
12-03 10:39:43.678: W/AQuery(6261): at com.androidquery.callback.AbstractAjaxCallback.run(AbstractAjaxCallback.java:977)
12-03 10:39:43.678: W/AQuery(6261): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
12-03 10:39:43.678: W/AQuery(6261): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
12-03 10:39:43.678: W/AQuery(6261): at java.lang.Thread.run(Thread.java:841)
12-03 10:39:43.678: W/AQuery(6261): Caused by: libcore.io.ErrnoException: open failed: EMFILE (Too …Run Code Online (Sandbox Code Playgroud) 这是我在这里发布的问题的扩展,虽然这似乎解决了我的问题的一部分,现在我明白了IO-Exception read end dead exception.我正在使用一个multithreaded应用程序,其中 thread-1 produces随机数和其他thread-2 consumes它来计算平均值.一旦平均值达到阈值,我发出信号thread-1停止产生数字.这是代码的基本设计.
我到了IO-Exception read end dead exception.我想知道为什么会这样,以及如何解决它.谢谢.
代码如下:
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;
//
class NumGen extends Thread {
PipedOutputStream pos;
DataOutputStream dos;
AtomicBoolean isDone;
public NumGen(PipedOutputStream pos,AtomicBoolean isDone){
this.pos=pos;
dos=new DataOutputStream(pos);
this.isDone=isDone;
}
public void run(){
while (!isDone.get()){
Random rand = new Random();
try {
dos.writeDouble(rand.nextDouble()+100.0);
} catch (IOException e) { …Run Code Online (Sandbox Code Playgroud) 调用Runtime.getRuntime().EXEC()
当我传递命令"cd filename"
完整代码时,前者不起作用;
package com.piomnicron.riles;
import java.io.File;
import javax.swing.JOptionPane;
public class A {
protected static Runtime B = Runtime.getRuntime();
public static void main(String[] args) {
File E = new File("");
System.err.println(E.getAbsolutePath());
try{
B.exec("cd "+E.getAbsolutePath()+"\\");
}catch(Throwable e)
{
JOptionPane.showMessageDialog(null, "had an oopsie!");
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
}
我的问题恰好是,为什么它抛出以下IOException:
cannot run program "cd": CreateProcess error = 2, The system could not find the file specified
Run Code Online (Sandbox Code Playgroud)
我先尝试没有+"\",以防有人认为这可能是答案,
我已经做了一些谷歌搜索,并没有一个答案,我发现回答我的问题以任何方式,他们都专注于打开一个罐子,或文件,但我只是想知道为什么cd命令不起作用.我不能使用CD的绝对路径,因为这意味着如果有人移动它所包含的文件夹,它将会中断.
错误是B.exec(); 如果你想知道的话
请原谅任何语法错误,太阳在我眼中,我几乎看不到屏幕.
我正在尝试从我的java应用程序运行命令.我从用户那里得到输入并运行这行代码:Runtime.getRuntime().exec($userInput);.我尝试过很多简单的命令,包括"echo","start chrome"和"rem".似乎唯一有效的命令是"cmd.exe",我甚至不知道它是什么.
诸如"echo"之类的命令会生成此错误:
java.io.IOException: Cannot run program "echo": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at me.Draconwolver.Main.runCmd(Main.java:119)
at me.Draconwolver.Main.main(Main.java:34)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 6 more
Run Code Online (Sandbox Code Playgroud)
请随时向我询问更多详情.
在Apache的HttpClient的文档的execute(HttpHost target, HttpRequest request)方法,说:
IOException - 如果出现问题或连接中止
如果我捕获IOException,这会捕获所有 服务器5xx错误吗?
try {
response = client.execute(httpHost, request);
} catch (IOException e) {
// throw custom Exception
} finally {
// close response and client
}
Run Code Online (Sandbox Code Playgroud)
我问的原因是,在这个逻辑之后的其他地方,我们正在做类似以下的事情:
if (response.getStatusLine().getStatusCode() >= 500) {
// Could we ever reach this point after the code above?
}
Run Code Online (Sandbox Code Playgroud) ioexception ×10
java ×5
android ×2
batch-file ×2
c# ×2
.net ×1
aquery ×1
datastore ×1
exception ×1
file-exists ×1
io ×1
jenkins ×1
process ×1
try-catch ×1