| pipeline { |
| agent { |
| label 'docker-amd64-tf-a-bionic' |
| } |
| |
| parameters { |
| string( |
| name: 'URL', |
| defaultValue: 'https://review.trustedfirmware.org/TF-A/trusted-firmware-a', |
| description: 'Repository URL.') |
| |
| string( |
| name: 'REFSPEC', |
| defaultValue: '+refs/heads/*:refs/remotes/origin/*', |
| description: 'Git refspec used when fetching.') |
| |
| string( |
| name: 'REFNAME', |
| defaultValue: 'origin/master', |
| description: 'Git refname of the last commit to lint.') |
| |
| string( |
| name: 'REFNAME_BASE', |
| defaultValue: 'origin/master', |
| description: 'Git refname of the parent of the first commit to lint.') |
| } |
| |
| stages { |
| stage('Checkout') { |
| steps { |
| checkout([$class: 'GitSCM', |
| branches: [[name: params.REFNAME]], |
| userRemoteConfigs: [[ |
| url: params.URL, |
| refspec: params.REFSPEC]]]) |
| |
| script { |
| mergeBase = sh( |
| returnStdout: true, |
| script: "git merge-base ${params.REFNAME_BASE} HEAD").trim() |
| } |
| } |
| } |
| |
| stage('Lint') { |
| steps { |
| script { |
| if (fileExists('.nvmrc')) { |
| sh "bash -c 'nvm install'" |
| } |
| } |
| |
| sh "bash -c 'npm install --no-save commitlint'" |
| sh "bash -c 'npx commitlint --from=${mergeBase}'" |
| } |
| } |
| } |
| } |