# Test case ** Create project on Jenkins 1. New item -> Select "Pipeline", Name: "PipelineProject" 2. Check "Do not allow concurrent builds" 3. Build Triggers: - Poll SCM: - Schedule: "H/5 * * * *" 4. Modify pipeline.groovy to change values as needed and save the file. 5. Pipeline script /** * Configurable elements: * - container image * - Local registry example `image: registry.local:9001/ganeshwalkoli/build-image:0.3` * - Angular: 15.2.0 * - Git repo URL: https://github.com/chiraganand/test-repo.git * - branch: main * - sonar.projectKey: test-repo (should match with SonarQube project id) * * NOTE: Testing is not currently done because of issue with ChromeHeadless not * running without --no-sandbox in root even though this parameter is provided inside * karma.conf.js. Better to download a Chrome container image and run the tests in there. */ podTemplate(yaml: ''' apiVersion: v1 kind: Pod spec: containers: - name: build image: ganeshwalkoli/build-image:0.3 command: - sleep args: - 99d ''' ) { node(POD_LABEL) { stage('Build') { git url: 'https://github.com/chiraganand/test-repo.git', branch: 'main' container('build') { sh ''' npm install -g @angular/cli@15.2.0 npm ci ng version ng build ''' } } stage('Test') { container('build') { sh ''' #curl -fSsL https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor | tee /etc/apt/trusted.gpg.d/google-chrome.gpg >> /dev/null #echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' > /etc/apt/sources.list.d/google-chrome.list #apt-get update && apt-get install -y google-chrome-stable ng test --karma-config karma.conf.js --no-progress --no-watch --browsers=ChromeNoSandbox ''' } } stage('QA') { container('build') { sh ''' echo TODO: QA ''' withSonarQubeEnv() { sh """ /usr/local/bin/sonar-scanner \ -Dsonar.projectKey=test-repo \ -Dsonar.sources=. """ } } } stage('Deploy') { container('build') { sh ''' echo TODO: Deploy ''' } } } } 6. Now copy-paste pipeline.groovy in "Pipeline Definition" section.