You've already forked jenkins-lib
mirror of
https://github.com/firstBitMarksistskaya/jenkins-lib.git
synced 2025-08-25 20:09:25 +02:00
Переезд на градль-рельсы с тестами и объектами
This commit is contained in:
25
test/integration/groovy/RuleBootstrapper.groovy
Normal file
25
test/integration/groovy/RuleBootstrapper.groovy
Normal file
@@ -0,0 +1,25 @@
|
||||
import com.mkobit.jenkins.pipelines.codegen.LocalLibraryRetriever
|
||||
import org.jenkinsci.plugins.workflow.libs.GlobalLibraries
|
||||
import org.jenkinsci.plugins.workflow.libs.LibraryConfiguration
|
||||
import org.jenkinsci.plugins.workflow.libs.LibraryRetriever
|
||||
import org.jvnet.hudson.test.JenkinsRule
|
||||
|
||||
final class RuleBootstrapper {
|
||||
private RuleBootstrapper() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This demonstrates how you can can configure the {@link JenkinsRule} to use the local source code
|
||||
* as a {@link LibraryConfiguration}. In this example we are making it implicitly loaded.
|
||||
*/
|
||||
static void setup(JenkinsRule rule) {
|
||||
rule.timeout = 30
|
||||
final LibraryRetriever retriever = new LocalLibraryRetriever()
|
||||
final LibraryConfiguration localLibrary =
|
||||
new LibraryConfiguration('testLibrary', retriever)
|
||||
localLibrary.implicit = true
|
||||
localLibrary.defaultVersion = 'unused'
|
||||
localLibrary.allowVersionOverride = false
|
||||
GlobalLibraries.get().libraries = [localLibrary]
|
||||
}
|
||||
}
|
39
test/integration/groovy/cmdTest.groovy
Normal file
39
test/integration/groovy/cmdTest.groovy
Normal file
@@ -0,0 +1,39 @@
|
||||
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition
|
||||
import org.jenkinsci.plugins.workflow.job.WorkflowJob
|
||||
import org.jenkinsci.plugins.workflow.job.WorkflowRun
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.jvnet.hudson.test.JenkinsRule
|
||||
|
||||
class cmdTest {
|
||||
|
||||
@Rule
|
||||
public JenkinsRule rule = new JenkinsRule()
|
||||
|
||||
@Before
|
||||
void configureGlobalGitLibraries() {
|
||||
RuleBootstrapper.setup(rule)
|
||||
}
|
||||
|
||||
@Test
|
||||
void "cmd should echo something"() {
|
||||
def pipeline = '''
|
||||
pipeline {
|
||||
agent any
|
||||
stages {
|
||||
stage('test') {
|
||||
steps {
|
||||
cmd("echo helloWorld")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
'''.stripIndent()
|
||||
final CpsFlowDefinition flow = new CpsFlowDefinition(pipeline, true)
|
||||
final WorkflowJob workflowJob = rule.createProject(WorkflowJob, 'project')
|
||||
workflowJob.definition = flow
|
||||
|
||||
rule.assertLogContains('helloWorld', rule.buildAndAssertSuccess(workflowJob))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user