package org.jenkinsci.plugins.p4.client; import org.jenkinsci.plugins.p4.DefaultEnvironment; import org.jenkinsci.plugins.p4.SampleServerRule; import org.jenkinsci.plugins.p4.credentials.P4PasswordImpl; 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.ClassRule; import org.junit.Rule; import org.junit.Test; import org.jvnet.hudson.test.JenkinsRule; import java.util.logging.Logger; import static org.junit.Assert.assertEquals; public class WorkflowTest extends DefaultEnvironment { private static Logger logger = Logger.getLogger(ConnectionTest.class.getName()); private static final String P4ROOT = "tmp-WorkflowTest-p4root"; private static P4PasswordImpl auth; @ClassRule public static JenkinsRule jenkins = new JenkinsRule(); @Rule public SampleServerRule p4d = new SampleServerRule(P4ROOT, R15_1); @Before public void buildCredentials() throws Exception { auth = createCredentials("jenkins", "jenkins", p4d); } @Test public void testWorkflow() throws Exception { String id = auth.getId(); WorkflowJob job = jenkins.jenkins.createProject(WorkflowJob.class, "demo"); job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " p4sync credential: '" + id + "', template: 'test.ws'\n" + " p4tag rawLabelDesc: 'TestLabel', rawLabelName: 'jenkins-label'\n" + " publisher = [$class: 'SubmitImpl', description: 'Submitted by Jenkins', onlyOnSuccess: false, reopen: false]\n" + " buildWorkspace = [$class: 'TemplateWorkspaceImpl', charset: 'none', format: 'jenkins-${NODE_NAME}-${JOB_NAME}', pinHost: false, templateName: 'test.ws']\n" + " p4publish credential: '" + id + "', publish: publisher, workspace: buildWorkspace" + " \n" + "}")); WorkflowRun run = jenkins.assertBuildStatusSuccess(job.scheduleBuild2(0)); jenkins.assertLogContains("P4 Task: syncing files at change", run); jenkins.assertLogContains("P4 Task: tagging build.", run); jenkins.assertLogContains("P4 Task: reconcile files to changelist.", run); } @Test public void testWorkflowEnv() throws Exception { String id = auth.getId(); WorkflowJob job = jenkins.jenkins.createProject(WorkflowJob.class, "workflowEnv"); job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " p4sync credential: '" + id + "', template: 'test.ws'\n" + " println \"P4_CHANGELIST: ${env.P4_CHANGELIST}\"\n" + "}")); WorkflowRun run = jenkins.assertBuildStatusSuccess(job.scheduleBuild2(0)); jenkins.assertLogContains("P4 Task: syncing files at change", run); jenkins.assertLogContains("P4_CHANGELIST: 40", run); } @Test public void testManualP4Sync() throws Exception { String id = auth.getId(); WorkflowJob job = jenkins.jenkins.createProject(WorkflowJob.class, "manualP4Sync"); job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " def workspace = [$class: 'ManualWorkspaceImpl',\n" + " name: 'jenkins-${NODE_NAME}-${JOB_NAME}',\n" + " spec: [view: '//depot/... //jenkins-${NODE_NAME}-${JOB_NAME}/...']]\n" + " def syncOptions = [$class: 'org.jenkinsci.plugins.p4.populate.SyncOnlyImpl',\n" + " revert:true, have:true, modtime:true]\n" + " p4sync workspace:workspace, credential: '" + id + "', populate: syncOptions\n" + "}")); WorkflowRun run = jenkins.assertBuildStatusSuccess(job.scheduleBuild2(0)); jenkins.assertLogContains("P4 Task: syncing files at change", run); } @Test public void testP4GroovyConnectAndSync() throws Exception { WorkflowJob job = jenkins.jenkins.createProject(WorkflowJob.class, "p4groovy"); job.setDefinition(new CpsFlowDefinition("" + "node() {\n" + " ws = [$class: 'StreamWorkspaceImpl', charset: 'none', format: 'jenkins-${NODE_NAME}-${JOB_NAME}', pinHost: false, streamName: '//stream/main']\n" + " p4 = p4(credential: '" + auth.getId() + "', workspace: ws)\n" + " p4.run('sync', '//...')\n" + "}")); job.save(); WorkflowRun run = job.scheduleBuild2(0).get(); jenkins.assertLogContains("p4 sync //...", run); jenkins.assertLogContains("totalFileCount 10", run); } @Test public void testP4GroovySpecEdit() throws Exception { WorkflowJob job = jenkins.jenkins.createProject(WorkflowJob.class, "p4groovy.spec"); job.setDefinition(new CpsFlowDefinition("" + "node() {\n" + " ws = [$class: 'StreamWorkspaceImpl', charset: 'none', format: 'jenkins-${NODE_NAME}-${JOB_NAME}', pinHost: false, streamName: '//stream/main']\n" + " p4 = p4(credential: '" + auth.getId() + "', workspace: ws)\n" + " clientName = p4.getClientName();\n" + " client = p4.fetch('client', clientName)\n" + " echo \"Client: ${client}\"" + " client.put('Description', 'foo')" + " p4.save('client', client)" + "}")); job.save(); WorkflowRun run = job.scheduleBuild2(0).get(); jenkins.assertLogContains("p4 client -o jenkins-master-p4groovy.spec", run); } @Test public void testSyncIDManualP4Sync() throws Exception { String id = auth.getId(); WorkflowJob job = jenkins.jenkins.createProject(WorkflowJob.class, "syncIDmanualP4Sync"); job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " def workspace = [$class: 'ManualWorkspaceImpl',\n" + " name: 'jenkins-${NODE_NAME}-${JOB_NAME}',\n" + " syncID: 'foo-${NODE_NAME}-${JOB_NAME}',\n" + " spec: [view: '//depot/... //jenkins-${NODE_NAME}-${JOB_NAME}/...']]\n" + " def syncOptions = [$class: 'org.jenkinsci.plugins.p4.populate.SyncOnlyImpl',\n" + " revert:true, have:true, modtime:true]\n" + " p4sync workspace:workspace, credential: '" + id + "', populate: syncOptions\n" + "}")); WorkflowRun run = jenkins.assertBuildStatusSuccess(job.scheduleBuild2(0)); jenkins.assertLogContains("P4 Task: syncing files at change", run); WorkflowRun run2 = job.scheduleBuild2(job.getQuietPeriod()).get(); jenkins.assertBuildStatusSuccess(run2); assertEquals(2, job.getLastBuild().getNumber()); jenkins.assertLogContains("Found last change 40 on syncID foo-NODE_NAME-syncIDmanualP4Sync", run2); } @Test public void testP4GroovyMultiArg() throws Exception { WorkflowJob job = jenkins.jenkins.createProject(WorkflowJob.class, "multiArg"); job.setDefinition(new CpsFlowDefinition("" + "node() {\n" + " ws = [$class: 'StreamWorkspaceImpl', charset: 'none', format: 'jenkins-${NODE_NAME}-${JOB_NAME}', pinHost: false, streamName: '//stream/main']\n" + " p4 = p4(credential: '" + auth.getId() + "', workspace: ws)\n" + " p4.run('sync', '//...')\n" + " p4.run('changes', '-m4', '//...@24,27')\n" + "}")); job.save(); WorkflowRun run = job.scheduleBuild2(0).get(); jenkins.assertLogContains("Change 27", run); jenkins.assertLogContains("Change 24", run); jenkins.assertLogNotContains("Change 1", run); jenkins.assertLogNotContains("Change 40", run); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#37 | 29476 | Paul Allen |
Merge pull request #174 from skumar7322/UpdateJenkins346 Update Jenkins Version to 2.346.3 |
||
#36 | 29411 | Paul Allen |
Merge pull request #171 from skumar7322/SecurityPatch Security Patch : Update Jenkins Version and Other Dependencies |
||
#35 | 28495 | Paul Allen |
Extend delay between running both Jobs. Windows seems to miss the second job. |
||
#34 | 28492 | Paul Allen |
Fix Workflow test JenkinsRule. The @Rule 'jenkins' must not be static. |
||
#33 | 28491 | Paul Allen |
Run each test in a new Jenkins instance. Slower, but might prevent failures on Windows |
||
#32 | 28490 | Paul Allen |
Reuse Jenkins Server for slower tests. Change slower tests to use ClassRule. |
||
#31 | 28489 | Paul Allen |
Extend JenkinsRule timeout. Wrap JenkinsRule and for problematic tests on Windows extend the timeout to 7mins. |
||
#30 | 26163 | Paul Allen |
Pre-load build environment. buildEnvironment() is called by Jenkins and tagAction may not be set - so use old pre-load behaviour. JENKINS-60074 |
||
#29 | 26122 | Paul Allen |
Added additional login to resolve parallel connection issue. Includes test case for parallel stages. JENKINS-52806 |
||
#28 | 26099 | Paul Allen |
Prevent infinite polling when last build and current are pinned to a label. Added test to verify support for static lables. JENKINS-58149 |
||
#27 | 24986 | Paul Allen |
Merge pull request #87 from p4charu/jenkinsci-master Test to confirm JENKINS-54628 is fixed. |
||
#26 | 24940 | Paul Allen |
Skip sync when PreviewSync is used with quiet option `p4 sync -q -n`. JENKINS-54153 |
||
#25 | 24780 | Paul Allen |
Merge pull request #80 from p4charu/master Fix and a test for concurrent global libraries using perforce workspaces. JENKINS-50975 |
||
#24 | 24767 | Paul Allen |
Global Library support for multiple instances. Enforce a depot syntax path ending of "/..." Remove 'beta' from Global Library configuration. Generate a unique workspace to sync multiple Libraries. JENKINS-53922 |
||
#23 | 24662 | Paul Allen |
Undo *SCMSource rename to original *ScmSource. Reslove configuration loading issue due to 1.9.0 bad release. |
||
#22 | 24501 | Paul Allen | Refactor to use P4SCMXxx naming convention. | ||
#21 | 24487 | Paul Allen | Perforce Connection Refactor. | ||
#20 | 24458 | Paul Allen |
Verify new View Mapping code supports DepotSource Excludes. JENKINS-52861 |
||
#19 | 24433 | Paul Allen |
Extra arguments support for P4Groovy save function. JENKINS-52782 |
||
#18 | 24404 | Paul Allen |
Support spaces in depot path for MultiBranch and DepotSource Includes filters for leading white space (spaces/tabs). JENKINS-52652 |
||
#17 | 24403 | Paul Allen |
Support spaces in depot path for MultiBranch and DepotSource JENKINS-52604 |
||
#16 | 24402 | Paul Allen |
Fix Ellipsis detection in ClientViewMappingGenerator 'p4sync' was mistaking a single '.' for '...' when building the view. JENKINS-52572 |
||
#15 | 24267 | Paul Allen |
Use JOB_NAME in the Global Library Workspace name. Global Library workspaces must be unique. JENKINS-49525 JENKINS-50975 |
||
#14 | 24233 | Paul Allen |
Merge pull request #74 from msmeeth56/master Updated tests to work against Windows, and lower spec computers. JENKINS-52145 |
||
#13 | 23819 | Paul Allen | Cleanup test cases to use Credential ID. | ||
#12 | 23624 | Paul Allen |
Extended test to cover issues when using global libraries. JENKINS-44800 |
||
#11 | 23320 | Paul Allen | Remove deprecated ID for SCMSource constructor. | ||
#10 | 22999 | Paul Allen |
Fix sync options on FlushOnly and CheckOnly. JENKINS-46352 |
||
#9 | 22894 | Paul Allen |
(minor) remove Pipeline Library after test. Clean up after testGlobalLib and minor refactor on PublishNotifier and PublishNotifierStep. |
||
#8 | 22866 | Paul Allen |
Merge pull request #55 from jenkinsci/hth Global Pipeline Library support. JENKINS-46121 JENKINS-46550 |
||
#7 | 22821 | Paul Allen |
Merge pull request #53 from jenkinsci/TagAction-order Get Last TagAction. JENKINS-37618 JENKINS-45613 |
||
#6 | 22408 | Paul Allen |
Set SCM Environment for Jenkins 2.60+ JENKINS-37584 JENKINS-40885 |
||
#5 | 21936 | Paul Allen |
Refactor tests for 17.1 release. Removed pseudo web server on FreeStyleTest |
||
#4 | 21449 | Paul Allen |
Rename and Deprecated the old P4Groovy run method. Force use of variable arg/Array method over a single String. Add support for List<String> PR #35 JENKINS-40454 |
||
#3 | 21372 | Paul Allen |
Support custom SyncID. Exclude BUILD_NUMBER from SyncID. Pushed logging to higher level, so it is not reporting TagActions when building the Environment. JENKINS-40460 |
||
#2 | 21190 | Paul Allen |
Test for pull request #34 Custom workspace support. |
||
#1 | 21171 | Paul Allen |
Jenkinsfile basic test. Moved Workflow tests out of Connection test class. |