blob: 9d1d44f11bb987ca3be86356cffad2fb1fd4e04d [file] [log] [blame]
Chris Kaye23eab92021-04-19 15:04:15 +01001pipeline {
2 agent {
3 label 'docker-amd64-tf-a-bionic'
4 }
5
6 parameters {
7 string(
8 name: 'URL',
9 defaultValue: 'https://review.trustedfirmware.org/TF-A/trusted-firmware-a',
10 description: 'Repository URL.')
11
12 string(
13 name: 'REFSPEC',
14 defaultValue: '+refs/heads/*:refs/remotes/origin/*',
15 description: 'Git refspec used when fetching.')
16
17 string(
18 name: 'REFNAME',
19 defaultValue: 'origin/master',
20 description: 'Git refname of the last commit to lint.')
21
22 string(
23 name: 'REFNAME_BASE',
24 defaultValue: 'origin/master',
25 description: 'Git refname of the parent of the first commit to lint.')
26 }
27
28 stages {
29 stage('Checkout') {
30 steps {
31 checkout([$class: 'GitSCM',
32 branches: [[name: params.REFNAME]],
33 userRemoteConfigs: [[
34 url: params.URL,
35 refspec: params.REFSPEC]]])
36
37 script {
Chris Kaye23eab92021-04-19 15:04:15 +010038 mergeBase = sh(
39 returnStdout: true,
40 script: "git merge-base ${params.REFNAME_BASE} HEAD").trim()
41 }
42 }
43 }
44
45 stage('Lint') {
Chris Kaye23eab92021-04-19 15:04:15 +010046 steps {
Chris Kay73f55322022-10-10 13:35:36 +010047 script {
48 if (fileExists('.nvmrc')) {
Chris Kay2d582b42022-10-12 14:04:08 +010049 sh "nvm install"
Chris Kay73f55322022-10-10 13:35:36 +010050 }
51 }
52
Chris Kay2d582b42022-10-12 14:04:08 +010053 sh "npm install --no-save commitlint"
54 sh "npx commitlint --from=${mergeBase}"
Chris Kaye23eab92021-04-19 15:04:15 +010055 }
56 }
57 }
58}