-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
50 lines (47 loc) · 1.46 KB
/
Jenkinsfile
File metadata and controls
50 lines (47 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
pipeline {
agent {
label 'local'
}
stages {
stage("Checkout") {
steps {
checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://git.sapphiccode.net/SapphicCode/universe.git']])
script {
def rev = sh(script: "git rev-parse HEAD", returnStdout: true).trim()
def remoteUrl = sh(script: "git config --get remote.origin.url", returnStdout: true).trim()
env.FLAKE_REF = "git+${remoteUrl}?rev=${rev}"
}
}
}
stage("Deploy NixOS") {
matrix {
axes {
axis {
name 'HOST'
values "blahaj", "hyperhaj"
}
}
stages {
stage("Deploy") {
steps {
script {
def host = env.HOST
def args = ""
if (host == "hyperhaj") {
args = "-o Port=2222 "
}
def address = "${args}${host}.sapphicco.de"
withCredentials([sshUserPrivateKey(credentialsId: 'db1b8ea2-5664-4eed-93e6-eff75d958125', keyFileVariable: 'SSH_ID', usernameVariable: 'USER')]) {
sh """#!/usr/bin/env bash
set -euxo pipefail
ssh -i \$SSH_ID -o StrictHostKeyChecking=no -o User=\$USER ${address} -- sudo nixos-rebuild boot --flake "\${FLAKE_REF}"
"""
}
}
}
}
}
}
}
}
}