UNPKG

2.14 kBMarkdownView Raw
1# Using semantic-release with [Jenkins CI](https://www.jenkins.io/doc/book/pipeline/)
2
3## Environment variables
4
5The [Authentication](../usage/ci-configuration.md#authentication) environment variables can be configured in [Jenkins Project Settings](https://www.jenkins.io/doc/pipeline/tour/environment/)..
6
7Alternatively, the default `NPM_TOKEN` and `GH_TOKEN` can be easily [setup with semantic-release-cli](../usage/getting-started.md#getting-started).
8
9## Node.js project configuration
10
11### `Jenkinsfile (Declarative Pipeline)` configuration for a Node.js job
12
13**Note**: The publish pipeline must run a [Node >= 10.18 version](../support/FAQ.md#why-does-semantic-release-require-node-version--1018).
14
15This example is a minimal configuration for **semantic-release** with a build running Node 10.18. See [Jenkins documentation](https://www.jenkins.io/doc/) for additional configuration options.
16
17The`semantic-release` execution command varies depending if you are using a [local](../usage/installation.md#local-installation) or [global](../usage/installation.md#global-installation) **semantic-release** installation.
18
19```yaml
20// The release stage in the pipeline will run only if the test stage in the pipeline is successful
21pipeline {
22 agent any
23 environment {
24 GH_TOKEN = credentials('some-id')
25 }
26 stages {
27 stage('Test') {
28 steps {
29 sh '''
30 # Configure your test steps here (checkout, npm install, tests etc)
31 npm install
32 npm test
33 '''
34 }
35 }
36 stage('Release') {
37 tools {
38 nodejs "node 10.18"
39 }
40 steps {
41 sh '''
42 # Run optional required steps before releasing
43 npx semantic-release
44 '''
45 }
46 }
47 }
48}
49```
50
51### `package.json` configuration for a Node job
52
53A `package.json` is required only for [local](../usage/installation.md#local-installation) **semantic-release** installation.
54
55```json
56{
57 "devDependencies": {
58 "semantic-release": "^15.0.0"
59 }
60}
61```
\No newline at end of file