Nerd For Tech
Published in

Nerd For Tech

Build Promotion with OneDev

In OneDev, you can request good/verified builds to be further processed down the pipeline. This is build promotion, which can be done from build detail page like below:

The promotion menu above lists all downstream jobs depending on current build. Job dependency can be defined in dependencies & services section of a job. For above example, the deploy job depends on build job to retrieve its published artifacts for further processing. An overly simplified build spec is as below (requires OneDev 6.2.3 or higher):

version: 15
jobs:
- name: Build
steps:
- !CommandStep
name: build
runInContainer: true
image: alpine
interpreter: !DefaultInterpreter
commands:
- '# build our awesome app'
- echo @build_number@ > app.txt
useTTY: false
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !PublishArtifactStep
name: publish
artifacts: app.txt
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
triggers:
- !BranchUpdateTrigger {}
retryCondition: never
maxRetries: 3
retryDelay: 30
cpuRequirement: 500
memoryRequirement: 256
timeout: 3600
- name: Deploy
steps:
- !CommandStep
name: deploy
runInContainer: true
image: alpine
interpreter: !DefaultInterpreter
commands:
- '# let''s verify the app content'
- cat app.txt
- '# continue to deploy the app'
useTTY: false
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
jobDependencies:
- jobName: Build
requireSuccessful: true
artifacts: '**'
retryCondition: never
maxRetries: 3
retryDelay: 30
cpuRequirement: 500
memoryRequirement: 256
timeout: 3600

You may wonder why not running the deploy job from commit directly like below:

The reason is that running deploy job here triggers a new pipeline. Build job will re-run in this pipeline, and deploy job will retrieve artifacts from this newly generated build, which is still not verified. OTOH, promoting a build continues pipeline of that build. The example build spec above will demonstrate the difference:

  1. If promoting from an existing build, the deploy job prints build number of promoted build via retrieved app.txt
  2. If running deploy job directly from commit, it will print build number of newly generated build job

That’s all. Thanks for reading!

--

--

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store