Unverified Commit d5800827 authored by Kom ॐ's avatar Kom ॐ Committed by GitHub

docs: Add Jenkins build caching information (#58001)

parent c6d30da3
...@@ -126,3 +126,43 @@ Using Azure Pipelines' [Cache task](https://docs.microsoft.com/en-us/azure/devop ...@@ -126,3 +126,43 @@ Using Azure Pipelines' [Cache task](https://docs.microsoft.com/en-us/azure/devop
key: next | $(Agent.OS) | yarn.lock key: next | $(Agent.OS) | yarn.lock
path: '$(System.DefaultWorkingDirectory)/.next/cache' path: '$(System.DefaultWorkingDirectory)/.next/cache'
``` ```
## Jenkins (Pipeline)
Using Jenkins' [Job Cacher](https://www.jenkins.io/doc/pipeline/steps/jobcacher/) plugin, add the following build step to your `Jenkinsfile` where you would normally run `next build` or `npm install`:
```yaml
stage("Restore npm packages") {
steps {
// Writes lock-file to cache based on the GIT_COMMIT hash
writeFile file: "next-lock.cache", text: "$GIT_COMMIT"
cache(caches: [
arbitraryFileCache(
path: "node_modules",
includes: "**/*",
cacheValidityDecidingFile: "package-lock.json"
)
]) {
sh "npm install"
}
}
}
stage("Build") {
steps {
// Writes lock-file to cache based on the GIT_COMMIT hash
writeFile file: "next-lock.cache", text: "$GIT_COMMIT"
cache(caches: [
arbitraryFileCache(
path: ".next/cache",
includes: "**/*",
cacheValidityDecidingFile: "next-lock.cache"
)
]) {
// aka `next build`
sh "npm run build"
}
}
}
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment