| 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 { |
| author = sh( |
| returnStdout: true, |
| script: 'git log --format="%ae" -1').trim() |
| |
| mergeBase = sh( |
| returnStdout: true, |
| script: "git merge-base ${params.REFNAME_BASE} HEAD").trim() |
| } |
| } |
| } |
| |
| stage('Lint') { |
| when { |
| expression { |
| author.endsWith('@arm.com') |
| } |
| } |
| |
| steps { |
| sh "BASH_ENV=$NVM_DIR/nvm.sh bash -c 'npm install --no-save commitlint'" |
| sh "BASH_ENV=$NVM_DIR/nvm.sh bash -c 'npx commitlint --from=${mergeBase}'" |
| } |
| } |
| } |
| } |