public void validateTask(ValidationContext ctx) { validateCommand(); if (!usingBothArgsAndArgList()) { errors.add(ARGS, EXEC_CONFIG_ERROR); errors.add(ARG_LIST_STRING, EXEC_CONFIG_ERROR); } if (workingDirectory != null && !FilenameUtil.isNormalizedPathOutsideWorkingDir(workingDirectory)) { if (ctx.isWithinPipelines()) { errors.add(WORKING_DIR, String.format("The path of the working directory for the custom command in job '%s' in stage '%s' of pipeline '%s' is outside the agent sandbox.", ctx.getJob().name(), ctx.getStage().name(), ctx.getPipeline().name())); } else { errors.add(WORKING_DIR, String.format("The path of the working directory for the custom command in job '%s' in stage '%s' of template '%s' is outside the agent sandbox.", ctx.getJob().name(), ctx.getStage().name(), ctx.getTemplate().name())); } } for (Argument argument : getArgList()) { if (!argument.errors().isEmpty()) { errors.add(ARG_LIST_STRING, argument.errors().asString()); } } }