DEV Community

Rob Montague
Rob Montague

Posted on

CICD working!

I've done it! I was able to get it done earlier this week, but I wasn't able to write about it until now. I ended up using some information from this post ( and I mixed in the angular cli deploy gh-pages addin (

Now when I push to master in my devops git repo, a pipeline will kick off, run the build, lint it, test it, publish the tests and if everything succeeds, push up to my github pages.

Here's how I got to where I'm at:
1) Upload newly created angular app to devops git repo.
2) Create a branch for the pipeline work
3) In that branch in devops, go to pipelines and add the following YAML file:

# Node.js with Angular
# Build a Node.js project that uses Angular.
# Add steps that analyze code, save build artifacts, deploy, and more:
  buildConfiguration: 'Release'

- master

  vmImage: 'ubuntu-latest'

- task: NodeTool@0
    versionSpec: '10.x'
  displayName: 'Setup Environment'

- script: |
    npm install -g @angular/cli
    npm install
  displayName: 'npm install'

- script: ng lint
  displayName: 'Code Analysis'

- script: ng test --watch=false --codeCoverage=true
  displayName: 'Tests'

- task: PublishTestResults@2
  condition: succeededOrFailed()
    testResultsFormat: 'JUnit'
    testResultsFiles: '**/TESTS-*.xml'
  displayName: "Publish Test Results"

- task: PublishCodeCoverageResults@1
  condition: succeededOrFailed()
    codeCoverageTool: 'Cobertura'
    summaryFileLocation: '$(Build.SourceDirectory)/coverage/$(Angular_Project_Name)/cobertura-coverage.xml'
  displayName: 'Publish Code Coverage Results'

- script: ng deploy --repo=https://$(Github_Username):$(GITHUB_TOKEN)$(Github_Username)/$(Github_Repo_Location)
  condition: succeeded()
  displayName: 'Build Production and Deploy to'

- task: PublishBuildArtifacts@1
    PathtoPublish: 'dist/$(Angular_Project_Name)'
    ArtifactName: 'web-app'
    publishLocation: 'Container'
  displayName: 'Publish Artifacts'

I really like that devops allows me to store secure variables!

I really didn't need that publish artifacts at the end, but I figured I'd try it out. I do have one bug currently, the linting results publish can't find the output file to publish at the moment, so there is probably something wrong with my pathing.

Once I am able to finish the linting issue, it's on to the fun: Making the website work!

Top comments (0)