Jenkins
services.jenkins activation
Write this into your /etc/nixos/configuration.nix
services.jenkins = { enable = true; };
After a `nixos-rebuild switch`
Then the program is available via webbrowser at:
CI configuration
Using the multibranch pipeline one can use this Jenkinsfile in the repository to build it:
pipeline { agent any environment { PATH="/run/current-system/sw/bin" } stages { stage('Build') { steps { echo 'Building..' sh 'ls' sh 'nix-shell --command "just build"' archiveArtifacts artifacts: 'frontend/dist/*', fingerprint: true } } stage('Test') { steps { echo 'Testing..' sh 'nix-shell --command "just test"' } } stage('Check fmt') { steps { echo 'Checking fmt..' sh 'nix-shell --command "cargo fmt --check"' sh 'nix-shell --command "cd frontend; cargo fmt --check"' } } } post { changed { script { if (currentBuild.currentResult == 'FAILURE') { emailext subject: '$DEFAULT_SUBJECT', body: '$DEFAULT_CONTENT', recipientProviders: [ [$class: 'CulpritsRecipientProvider'], [$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider'] ], replyTo: '$DEFAULT_REPLYTO', to: '$DEFAULT_RECIPIENTS' } } } always { cleanWs(cleanWhenNotBuilt: false, deleteDirs: true, disableDeferredWipeout: true, notFailBuild: true, patterns: [[pattern: '.gitignore', type: 'INCLUDE'], [pattern: '.propsfile', type: 'EXCLUDE']]) } } }
building nix projects
jenkins-nix-ci: A NixOS module for Jenkins, optimized specifically for running projects using Nix.
mrVanDalo has a library to declare jenkins in his repository. It can be used as shown here