blob: 2cb58293e1cf980117f387a7a56ed762cfd5111b [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')) {
49 sh "BASH_ENV=$NVM_DIR/nvm.sh bash -c 'nvm install'"
50 }
51 }
52
Chris Kaye23eab92021-04-19 15:04:15 +010053 sh "BASH_ENV=$NVM_DIR/nvm.sh bash -c 'npm install --no-save commitlint'"
54 sh "BASH_ENV=$NVM_DIR/nvm.sh bash -c 'npx commitlint --from=${mergeBase}'"
55 }
56 }
57 }
58}