diff --git a/lib/api/gitlab.js b/lib/api/gitlab.js
index 635af849a660ffd94c06d5b0d41e85f15a923d7e..21727b4cbc7dd45a7d53376ac1feba2e5e8083bb 100644
--- a/lib/api/gitlab.js
+++ b/lib/api/gitlab.js
@@ -498,7 +498,10 @@ async function createFile(branchName, filePath, fileContents, message) {
       content: Buffer.from(fileContents).toString('base64'),
     };
   } else {
-    url = `projects/${config.repoName}/repository/files/${filePath}`;
+    url = `projects/${config.repoName}/repository/files/${filePath.replace(
+      /\//g,
+      '%2F'
+    )}`;
     opts.body = {
       branch: branchName,
       commit_message: message,
@@ -523,7 +526,10 @@ async function updateFile(branchName, filePath, fileContents, message) {
       content: Buffer.from(fileContents).toString('base64'),
     };
   } else {
-    url = `projects/${config.repoName}/repository/files/${filePath}`;
+    url = `projects/${config.repoName}/repository/files/${filePath.replace(
+      /\//g,
+      '%2F'
+    )}`;
     opts.body = {
       branch: branchName,
       commit_message: message,