More Lessons from the Pipeline
Never stop learning. That’s an order! Or not. Do whatever you want–you’re not my kid. But the pipeline is always teaching. The pipeline is always showing us something if we are receptive to learning it. Not really. It can teach us and it can show us if we go seeking it.
Table Of Contents
Badges? We don’t need no stinkin badges!
That right there is a build badge. It’s the build for this very website. The one you’re seeing now. Yeah, that’s pretty. I know. I’m kind of a big deal. /s But I love gadgets like this. They can be very helpful. I already get email alerts when builds succeed or fail but there are other ways to check on the status. The build badge is a very fun one because you can have it in your README. Looks pro. I, truly neutral, have decided to just throw it here on this page. It’s very easy to generate, as well.
That’s all there is to it. You’ll have a URL there for an image but they’ll also prepare some Markdown for you. I’ve taken advantage of the latter and you can see its result here. If it’s showing as failing then I’m working on something (hopefully that’s the reason).
Timing is everything
By default this pipeline pops off manually or when we push to the repo. That’s fine except that Hugo doesn’t show articles in the future unless you build your site with hugo -F
. But then those future posts are just always there. That’s not particularly useful. What is being accomplished here is the ability to work on posts to be released at a later date and then have them show up close to the day they should. The pipeline can be scheduled more aggressively but that seems silly. Nothing here is going to be time-sensitive, anyway.
One arrives at the above screen by clicking the three-dot menu (and that, I just remembered, is called a kebab menu. I didn’t eat dinner–I’m hungry and this isn’t helping. The three line menu that, iirc, was popularized by Apple was, or is, called a burger menu) on the screen where you are able to edit the YAML of the pipeline directly. When you click “Add” next to “Scheduled” you’ll be presented with the below.
I decided this schedule would work because it’s a steady stream. I would very much like to still build when a push happens however the future post issue arises and I do quite wish for future posts to work. At the time that this post is up I would probably have not been near a computer to do a push. That info block down there at the bottom is particularly elucidating as it has now informed us that we can schedule through YAML. If this doesn’t seem interesting to you, well, you musn’t be afraid to dream a little bigger. It now becomes simple to programmatically adjust the scheduling on this pipeline. I’m not completely certain why I, personally, would want to do that but I’m sure there are reasons that someone would. I’ll get around to trying it out eventually.
Fill my builds with that Double Vision 🎸
If you recall from Branches? We Don’t Need No Stinking Branches, there is another feature branch. I don’t know that it’s fully worthwhile to get the build status of the feature branch as it will change. Right now it’s vale-info
as I’m working on adding some information from the vale linter. Full post on that later.
Either way, I’ve been manually running that pipeline while I’ve been ironing out issues with the build system (and I assure you that most of my issues are self-inflicted and could have been ameliorated by running the build agent in a docker container or just using the one free worker that I get through Azure DevOps–both will eventually happen so be on the lookout for those) but those are mostly ironed out and I would like for that build to trigger on push.
State of the pipeline
Right now the pipeline is this:
trigger:
- main
stages:
- stage: 'GenerateHugo'
displayName: 'Generate hugo website'
jobs:
- job:
pool:
name: Default
#vmImage: ubuntu-latest
workspace:
clean: all
steps:
- checkout: self
displayName: 'Checkout repository including submodules'
submodules: true # true so Hugo theme submodule is checked out
- task: Bash@3
inputs:
filePath: 'utilities/process-vale.sh'
- task: CmdLine@2
displayName: "Hugo build"
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
#command line runs with --noprofile --norc and that's annoying
inputs:
script: '/home/vstsagent/.linuxbrew/bin/hugo --cleanDestinationDir --minify'
- task: CmdLine@2
displayName: "Hugo Staging Build"
condition: ne(variables['Build.SourceBranch'], 'refs/heads/main')
#command line runs with --noprofile --norc and that's annoying
inputs:
script: '/home/vstsagent/.linuxbrew/bin/hugo -D -F --cleanDestinationDir --minify --baseURL=https://STAGINGURL.azurestaticapps.net'
- task: AzureStaticWebApp@0
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
inputs:
skip_app_build: true
app_location: '/public'
app_build_command: ''
output_location: ''
azure_static_web_apps_api_token: '$(TOKEN)'
- task: AzureStaticWebApp@0
condition: ne(variables['Build.SourceBranch'], 'refs/heads/main')
inputs:
skip_app_build: true
app_location: '/public'
app_build_command: ''
output_location: ''
azure_static_web_apps_api_token: '$(STAGING_TOKEN)'
The condition
statements are what makes this work. The pipeline will undertake different action based on what branch it is running on which is very cool and useful. You’ll note that I build the website with hugo -D -F --baseURL=https://stagingurl
to ensure that the links on the site direct to the appropriate address. It also builds draft posts and future posts (all about that scheduling).
Gotta build ’em all
Well, not all of them. But to build the branch vale-info
your trigger section should have - vale-info
. This is good for a specific branch however it doesn’t scale very well. There is a convention for feature branches that has them be named as feature/thefeaturename
so that we can then add a trigger - feature/*
to just cover those cases forever. It will look like this:
trigger:
- main
- vale-info
- feature/*
Happy building! 👷
./content/posts/more-lessons-from-the-pipeline.md 10:80 warning Use first person (such as Microsoft.FirstPerson 'my') sparingly. 10:156 warning Try to avoid using Microsoft.We first-person plural like 'us'. 10:172 warning Try to avoid using Microsoft.We first-person plural like 'we'. 10:172 error Use 'we're' instead of 'we Microsoft.Contractions are'. 10:209 warning Consider removing 'really'. Microsoft.Adverbs 10:232 warning Try to avoid using Microsoft.We first-person plural like 'us'. 10:253 warning Try to avoid using Microsoft.We first-person plural like 'us'. 10:259 warning Try to avoid using Microsoft.We first-person plural like 'we'. 13:9 warning Don't use end punctuation in Microsoft.HeadingPunctuation headings. 13:12 warning Try to avoid using Microsoft.We first-person plural like 'We'. 13:42 warning Don't use end punctuation in Microsoft.HeadingPunctuation headings. 16:64 warning Consider removing 'very'. Microsoft.Adverbs 16:134 warning Use first person (such as Microsoft.FirstPerson 'I'm') sparingly. 16:164 warning Use first person (such as ' I Microsoft.FirstPerson ') sparingly. 16:203 warning Consider removing 'very'. Microsoft.Adverbs 16:216 warning Use first person (such as ' I Microsoft.FirstPerson ') sparingly. 16:342 warning Consider removing 'very'. Microsoft.Adverbs 16:405 warning Use first person (such as ' I, Microsoft.FirstPerson ') sparingly. 16:478 warning Consider removing 'very'. Microsoft.Adverbs 20:42 warning For a general audience, use Microsoft.GeneralURL 'address' rather than 'URL'. 20:213 warning Use first person (such as Microsoft.FirstPerson 'I'm') sparingly. 23:52 warning Try to avoid using Microsoft.We first-person plural like 'we'. 23:266 error Use 'what's' instead of 'What Microsoft.Contractions is'. 23:345 warning Consider using 'later' instead Microsoft.Wordiness of 'at a later date'. 27:74 warning Use first person (such as ' I Microsoft.FirstPerson ') sparingly. 27:117 warning Use first person (such as ' I Microsoft.FirstPerson ') sparingly. 27:139 warning Use first person (such as Microsoft.FirstPerson 'I'm') sparingly. 27:198 error More than 3 commas! marktoso.TresComas 29:46 error Use 'it's' instead of 'It is'. Microsoft.Contractions 31:1 warning Use first person (such as 'I Microsoft.FirstPerson ') sparingly. 31:74 warning Consider removing 'very'. Microsoft.Adverbs 31:164 warning Use first person (such as ' I Microsoft.FirstPerson ') sparingly. 31:239 warning Use first person (such as ' I Microsoft.FirstPerson ') sparingly. 31:257 error Use 'haven't' instead of 'have Microsoft.Contractions not'. 31:393 warning Try to avoid using Microsoft.We first-person plural like 'us'. 31:401 warning Try to avoid using Microsoft.We first-person plural like 'we'. 31:607 warning Use first person (such as Microsoft.FirstPerson 'I'm') sparingly. 31:681 warning Use first person (such as Microsoft.FirstPerson 'I'm') sparingly. 33:9 warning Use first person (such as Microsoft.FirstPerson 'my') sparingly. 34:31 warning Try to avoid using Microsoft.We first-person plural like 'We'. 34:91 warning Try to avoid using Microsoft.We first-person plural like 'we'. 34:166 warning Use first person (such as ' I Microsoft.FirstPerson ') sparingly. 34:302 warning Use first person (such as Microsoft.FirstPerson 'I'm') sparingly. 36:115 warning Use first person (such as ' I Microsoft.FirstPerson ') sparingly. 36:142 warning Use first person (such as Microsoft.FirstPerson 'my') sparingly. 36:224 warning Prefer 'personal digital Microsoft.Terms assistant' over 'agent'. 36:290 warning Use first person (such as ' I Microsoft.FirstPerson ') sparingly. 36:414 warning Use first person (such as ' I Microsoft.FirstPerson ') sparingly. 95:120 error Use 'it's' instead of 'it is'. Microsoft.Contractions 95:146 warning Consider removing 'very'. Microsoft.Adverbs 95:184 warning Use first person (such as ' I Microsoft.FirstPerson ') sparingly. 98:11 warning Consider using 'all' instead Microsoft.Wordiness of 'all of'. 98:171 warning Consider removing 'very'. Microsoft.Adverbs 98:284 warning Try to avoid using Microsoft.We first-person plural like 'we'. 110:210 warning Use first person (such as ' I Microsoft.FirstPerson ') sparingly.✖ 6 errors, 49 warnings and 0 suggestions in 1 file.