sudo /usr/bin/salt-call state.highstate --retcode-passthrough mocked=True
Hi,
Please excuse the noobiness of the following as I am no dev, and not yet aware of code review and so on....
I found that many times after I commit and push to our company gitlab the following provisioning / setup of a test server finds syntax error and so on.
I am sure you guys already check this basics (correct syntax / basic code review) and am wondering how you handle these.
...
import groovy.json.JsonSlurper
node("cs-prod-saltstack"){
stage("Checkout"){
sh "mkdir -p /srv/salt"
dir('/srv/salt'){
checkout scm
}
}
stage("Lint"){
sh "salt-run fileserver.update && salt-run git_pillar.update && salt '*' saltutil.sync_all"
sh "salt '*' state.show_lowstate" // execution exits if command failure
sh "salt '*' state.highstate mock=True" // execution exits if command failure
}
stage("Execute highstate"){
// Executing Highstate apply
try {
sh "docker exec -t test-salt_minion salt-call state.highstate -l debug --retcode-passthrough --no-color"
} catch (Exception err) {
currentBuild.result = "FAILURE"
}
}
stage ("Testing") {
def jsonResp = sh(script: 'docker exec -t test-salt_minion salt-call saltcheck.run_highstate_tests --output=json -l quiet --no-color', returnStdout: true).trim()
echo jsonResp
def jsonout = new groovy.json.JsonSlurper().parseText(jsonResp)
try {
assert jsonout.local[13]."TEST RESULTS".Failed == 0
currentBuild.result = 'SUCCESS'
} catch (AssertionError e) {
currentBuild.result = 'FAILURE'
office365ConnectorSend(message: "${JOB_NAME} - Salt State validation Problem!\n", status: "${currentBuild.result}, took ${currentBuild.durationString}.", webhookUrl: <someurl>)
}
}
}
{% from "openssh/map.jinja" import openssh with context %}
openssh-server-latest:
module_and_function: pkg.latest_version
args:
- {{ openssh.server }}
assertion: assertEmpty