{"record":{"id":"437d47fc8a9408fb","repo":"jenkinsci/jenkins","slug":"failed-to-set-the-timestamp-of-f-to-timestamp","errorCode":null,"errorMessage":"Failed to set the timestamp of ${f} to ${timestamp}","messagePattern":"Failed to set the timestamp of (.+?) to (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/hudson/FilePath.java","lineNumber":1830,"sourceCode":"        act(new Touch(timestamp));\n    }\n\n    private static class Touch extends MasterToSlaveFileCallable<Void> {\n        private final long timestamp;\n\n        Touch(long timestamp) {\n            this.timestamp = timestamp;\n        }\n\n            private static final long serialVersionUID = -5094638816500738429L;\n\n            @Override\n            public Void invoke(File f, VirtualChannel channel) throws IOException {\n                if (!f.exists()) {\n                    Files.newOutputStream(fileToPath(f)).close();\n                }\n                if (!f.setLastModified(timestamp))\n                    throw new IOException(\"Failed to set the timestamp of \" + f + \" to \" + timestamp);\n                return null;\n            }\n    }\n\n    private void setLastModifiedIfPossible(final long timestamp) throws IOException, InterruptedException {\n        String message = act(new SetLastModified(timestamp));\n\n        if (message != null) {\n            LOGGER.warning(message);\n        }\n    }\n\n    private static class SetLastModified extends MasterToSlaveFileCallable<String> {\n        private final long timestamp;\n\n        SetLastModified(long timestamp) {\n            this.timestamp = timestamp;\n        }","sourceCodeStart":1812,"sourceCodeEnd":1848,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/FilePath.java#L1812-L1848","documentation":"Thrown by the Touch.invoke act when File.setLastModified(long) returns false, meaning the OS refused to update the file's last-modified timestamp. This wraps the raw boolean failure into an IOException propagated through FilePath.act(). Common causes: the file is read-only, on a filesystem that doesn't support mtime (e.g., some FAT variants, or the file is held open exclusively on Windows), or the timestamp value is out of the OS's supported range.","triggerScenarios":"Calling FilePath.touch(long timestamp) on a path whose target file has a last-modified time that cannot be changed — file is locked, read-only, or the timestamp is negative/out of epoch range for the filesystem.","commonSituations":"Windows with a file open in another process (exclusive lock), files on network-mounted shares (SMB/NFS) with restricted permissions, FAT/exFAT volumes that reject pre-1980 or far-future timestamps, or containerized builds where the file owner differs from the Jenkins process UID.","solutions":["Ensure the Jenkins process has write permission on the file and its parent directory.","On Windows, close any process holding the file open before calling touch().","Validate the timestamp is within the filesystem's supported range (FAT: 1980-01-01 to 2107-12-31).","If mtime is not needed, catch IOException and log a warning instead of failing the build."],"exampleFix":"// before\nfilePath.touch(timestamp);\n\n// after — guard against unsupported mtime\ntry {\n    filePath.touch(timestamp);\n} catch (IOException e) {\n    listener.getLogger().println(\"Warning: could not set timestamp: \" + e.getMessage());\n}","handlingStrategy":"try-catch","validationCode":"long ts = timestamp;\n// FAT supports 1980-01-01 to 2107-12-31\nif (ts < 315532800000L || ts > 4133980799000L) {\n    LOGGER.warning(\"Timestamp out of filesystem-supported range; touch may fail.\");\n}\nif (!f.canWrite()) {\n    LOGGER.warning(\"File is not writable; setLastModified will likely fail: \" + f);\n}","typeGuard":null,"tryCatchPattern":"try {\n    filePath.setLastModifiedIfPossible(timestamp);\n} catch (IOException e) {\n    // Non-fatal: timestamp is cosmetic in most build contexts\n    LOGGER.log(Level.WARNING, \"Could not set timestamp on {0}\", filePath);\n}","preventionTips":["Ensure Jenkins process owns or has write access to workspace files.","On Windows, avoid touching files held open by other processes.","Validate timestamp range for the target filesystem before calling touch()."],"tags":["filesystem","file-metadata","windows","permissions"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}