ci: pin native and runtime Lesavka jobs to requested source
This commit is contained in:
parent
7e8139965c
commit
32274747f5
@ -268,9 +268,11 @@ data:
|
||||
url('https://scm.bstein.dev/bstein/lesavka.git')
|
||||
credentials('gitea-pat')
|
||||
}
|
||||
branches('*/dev-phone-companion-updates')
|
||||
// Pin both the pipeline definition and worker checkout to the request.
|
||||
branches('$EXPECTED_SOURCE_REVISION')
|
||||
}
|
||||
}
|
||||
lightweight(false)
|
||||
scriptPath('docker/Jenkinsfile.compile')
|
||||
}
|
||||
}
|
||||
@ -493,9 +495,11 @@ data:
|
||||
url('https://scm.bstein.dev/bstein/lesavka.git')
|
||||
credentials('gitea-pat')
|
||||
}
|
||||
branches('*/dev-phone-companion-updates')
|
||||
// Pin both the pipeline definition and worker checkout to the request.
|
||||
branches('$EXPECTED_SOURCE_REVISION')
|
||||
}
|
||||
}
|
||||
lightweight(false)
|
||||
scriptPath('docker/Jenkinsfile.runtime')
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
// Controller-side, read-only acceptance probe. Supply only the software job's
|
||||
// reviewed Job DSL as candidateSeed in the binding. No jobs are saved or queued.
|
||||
// Controller-side acceptance probe with a private Git fixture. Supply one reviewed
|
||||
// job's DSL as candidateSeed and its allowlisted name as candidateJob. Installed
|
||||
// jobs are never saved, queued or changed.
|
||||
import groovy.json.JsonOutput
|
||||
import groovy.xml.XmlUtil
|
||||
import hudson.EnvVars
|
||||
@ -20,11 +21,15 @@ import java.nio.file.attribute.PosixFilePermissions
|
||||
|
||||
class ReviewOnly extends JenkinsJobManagement {
|
||||
Map<String, String> rendered = [:]
|
||||
final String expectedJob
|
||||
|
||||
ReviewOnly() { super(TaskListener.NULL.logger, [:], new File('/tmp')) }
|
||||
ReviewOnly(String expectedJob) {
|
||||
super(TaskListener.NULL.logger, [:], new File('/tmp'))
|
||||
this.expectedJob = expectedJob
|
||||
}
|
||||
|
||||
@Override boolean createOrUpdateConfig(Item item, boolean ignoreExisting) {
|
||||
assert item.name == 'lesavka-software-tests'
|
||||
assert item.name == expectedJob
|
||||
rendered[item.name] = item.xml
|
||||
return true
|
||||
}
|
||||
@ -34,25 +39,32 @@ class ReviewOnly extends JenkinsJobManagement {
|
||||
}
|
||||
}
|
||||
|
||||
def review = new ReviewOnly()
|
||||
def selectedJob = binding.getVariable('candidateJob')
|
||||
def expected = [
|
||||
'lesavka-software-tests': [path: 'docker/Jenkinsfile.software-tests', builds: '8'],
|
||||
'lesavka-compile': [path: 'docker/Jenkinsfile.compile', builds: '12'],
|
||||
'lesavka-runtime-tests': [path: 'docker/Jenkinsfile.runtime', builds: '8'],
|
||||
]
|
||||
assert expected.containsKey(selectedJob)
|
||||
def review = new ReviewOnly(selectedJob)
|
||||
def installedState = {
|
||||
def current = Jenkins.get().getItemByFullName('lesavka-software-tests').definition
|
||||
def current = Jenkins.get().getItemByFullName(selectedJob).definition
|
||||
[path: current.scriptPath, lightweight: current.lightweight, branches: current.scm.branches*.name]
|
||||
}
|
||||
def before = installedState()
|
||||
new DslScriptLoader(review).runScript(binding.getVariable('candidateSeed'))
|
||||
assert review.rendered.keySet() == ['lesavka-software-tests'] as Set
|
||||
def xml = new XmlParser().parseText(review.rendered['lesavka-software-tests'])
|
||||
assert review.rendered.keySet() == [selectedJob] as Set
|
||||
def xml = new XmlParser().parseText(review.rendered[selectedJob])
|
||||
def definition = Jenkins.XSTREAM2.fromXML(XmlUtil.serialize(xml.definition[0]))
|
||||
assert !definition.lightweight
|
||||
assert definition.scriptPath == 'docker/Jenkinsfile.software-tests'
|
||||
assert definition.scriptPath == expected[selectedJob].path
|
||||
def scm = definition.scm
|
||||
assert scm.branches*.name == ['$EXPECTED_SOURCE_REVISION']
|
||||
assert scm.userRemoteConfigs.size() == 1
|
||||
assert scm.userRemoteConfigs[0].url == 'https://scm.bstein.dev/bstein/lesavka.git'
|
||||
assert scm.userRemoteConfigs[0].credentialsId == 'gitea-pat'
|
||||
assert xml.properties.'org.jenkinsci.plugins.workflow.job.properties.DisableConcurrentBuildsJobProperty'.size() == 1
|
||||
assert xml.properties.'jenkins.model.BuildDiscarderProperty'.strategy.numToKeep.text() == '8'
|
||||
assert xml.properties.'jenkins.model.BuildDiscarderProperty'.strategy.numToKeep.text() == expected[selectedJob].builds
|
||||
assert xml.properties.'jenkins.model.BuildDiscarderProperty'.strategy.artifactNumToKeep.text() == '4'
|
||||
|
||||
def resolver = GitSCM.getDeclaredMethod('getSingleBranch', EnvVars)
|
||||
@ -124,7 +136,7 @@ try {
|
||||
}
|
||||
assert !directory.exists()
|
||||
checks << 'private_fixture_removed'
|
||||
println(JsonOutput.toJson([status: 'passed', checks: checks,
|
||||
println(JsonOutput.toJson([status: 'passed', job: selectedJob, checks: checks,
|
||||
plugins: ['git', 'git-client', 'workflow-cps', 'job-dsl'].collectEntries {
|
||||
[(it): Jenkins.get().pluginManager.getPlugin(it).version]
|
||||
}]))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user