In a plugin I start a job on a slave and at some point I need to create a 
file in a folder in the jenkins home folder on the slave 
(/var/jenkins/sampleFolder). Its a hack but necessary for now.

    File outputDir = new File("/var/jenkins/sampleFolder/");
    if (!outputDir.exists()) {
      outputDir.mkdirs();
      listener.getLogger().println("Created directory: " + 
outputDir.getAbsolutePath());
    }
    File file = new File(outputDir, "config.properties");
    if (!outputDir.exists()) {
      listener.getLogger().println("Not found: " + 
outputDir.getAbsolutePath());
    }

    boolean createNewFile = file.createNewFile();
    if (createNewFile) {
      PrintWriter printWriter = new PrintWriter(new FileWriter(file));
      printWriter.println("a : v" );
      printWriter.close();
    } else {
      listener.getLogger().println("Error! could not create file " + 
file.getAbsolutePath());
    }

But I get an error that the file cannot be created or more specifically:

ERROR: No such file or directory

If I run the job on the master it works.

Is it not allowed to create files/folders on a slave in the Jenkins home 
folder?



-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to