blob: 96d7a02535fe0b976b08112c9e9e88ef926ae472 [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 {
38 author = sh(
39 returnStdout: true,
40 script: 'git log --format="%ae" -1').trim()
41
42 mergeBase = sh(
43 returnStdout: true,
44 script: "git merge-base ${params.REFNAME_BASE} HEAD").trim()
45 }
46 }
47 }
48
49 stage('Lint') {
50 when {
51 expression {
52 author.endsWith('@arm.com')
53 }
54 }
55
56 steps {
57 sh "BASH_ENV=$NVM_DIR/nvm.sh bash -c 'npm install --no-save commitlint'"
58 sh "BASH_ENV=$NVM_DIR/nvm.sh bash -c 'npx commitlint --from=${mergeBase}'"
59 }
60 }
61 }
62}