package org.jenkinsci.plugins.p4workflow; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; 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.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.jvnet.hudson.test.JenkinsRule; import com.cloudbees.plugins.credentials.CredentialsScope; import com.cloudbees.plugins.credentials.SystemCredentialsProvider; public class WorkflowTest { private final String credential = "id"; private static String PWD = System.getProperty("user.dir") + "/"; private static String P4BIN = "src/test/resources/r14.1/"; private final static String P4ROOT = "tmp-p4root"; private final static String P4PORT = "localhost:1999"; private final static int HTTP_PORT = 1888; private final static P4Server p4d = new P4Server(PWD + P4BIN, P4ROOT, P4PORT); @Rule public JenkinsRule jenkins = new JenkinsRule(); @BeforeClass public static void setupServer() throws Exception { File ckp = new File("src/test/resources/checkpoint.gz"); assertTrue(ckp.exists()); File depot = new File("src/test/resources/depot.tar.gz"); assertTrue(depot.exists()); p4d.clean(); File root = new File(P4ROOT); assertTrue(root.exists()); p4d.restore(ckp); p4d.upgrade(); p4d.extract(depot); // start pseudo web server startHttpServer(HTTP_PORT); } @Before public void startServer() throws Exception { p4d.start(); } @After public void stopServer() throws Exception { p4d.stop(); } @AfterClass public static void cleanServer() throws Exception { p4d.clean(); } private P4PasswordImpl createCredentials() throws IOException { P4PasswordImpl auth = new P4PasswordImpl(CredentialsScope.SYSTEM, credential, "desc", P4PORT, null, "jenkins", "0", "jenkins"); SystemCredentialsProvider.getInstance().getCredentials().add(auth); SystemCredentialsProvider.getInstance().save(); return auth; } @Test public void testCheckP4d() throws Exception { int ver = p4d.getVersion(); assertTrue(ver >= 20121); } @Test public void testWorkflow() throws Exception { P4PasswordImpl auth = createCredentials(); 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); } private static void startHttpServer(int port) throws Exception { DummyServer server = new DummyServer(port); new Thread(server).start(); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 15382 | Paul Allen | Update POM and added tests. | ||
//guest/sven_erik_knop/p4jenkins/src/test/java/org/jenkinsci/plugins/p4/client/ConnectionTest.java | |||||
#4 | 15206 | Sven Erik Knop | A simple test case for workflow steps for P4. | ||
#3 | 15143 | Sven Erik Knop | Refactor 1 - create credentials once | ||
#2 | 13620 | Sven Erik Knop | Merge changes from Paul's latest release | ||
#1 | 12955 | Sven Erik Knop | Branching using sknop.p4jenkins-main | ||
//guest/perforce_software/p4jenkins/main/src/test/java/org/jenkinsci/plugins/p4/client/ConnectionTest.java | |||||
#16 | 12953 | Paul Allen |
Update logging to support expand/collapse divs. - Additional Publish logging |
||
#15 | 11566 | Paul Allen | False positive from using incorrect client. | ||
#14 | 11564 | Paul Allen | Enable 'pin hostname' option in test. | ||
#13 | 11563 | Paul Allen | Changed hostname test to use Manual workspace. | ||
#12 | 11472 | Paul Allen |
Pin the Workspace to the build host. Added a check box under the Workspace configuration to allow Jenkins to Pin the workspace, by setting the Host field. The hostname is resolved from the Computer object or InetAddress. |
||
#11 | 11335 | Paul Allen | Remote slave support for Polling. | ||
#10 | 11334 | Paul Allen |
Remote slave support for Publish Perforce Publish commands need to be executed from the remote slave. - Includes refactoring into task package |
||
#9 | 10841 | Paul Allen |
Support for 2014.1 reconcile by MODTIME Feature allows a user check the option ‘Sync with MODTIME for consistency check’ under the ‘Populate’ option to enable reconcile to check files based on MODTIME. Includes test case for MODTIME and minor fix for fetching a Label when there is no previous change. JENKINS-25341 |
||
#8 | 10802 | Paul Allen |
Test cases for SCM Polling Added test case for Polling with Limits (pinning) and Incremental. |
||
#7 | 10775 | Paul Allen |
Fix change detection when using a moving label If a build was pinned or built from a label, the label name was recorded <buildChange>. If the label is updated between builds then comparing against an earlier build will give you the wrong result. This fix stores the automatic label ‘Revision’ field and stores this in <buildChange>. NOTE: you will need to run a manual build to flush the label, so that the last build has a change number. JENKINS-25300 |
||
#6 | 10755 | Paul Allen |
Separate name space for 'label' parameter. Perforce Review endpoint added `label`, `change`, `status`, `pass`, and `fail` parameter into the environment, which is a shared name space. This clashed with the default `label` matrix name and causing users issues. The change prefixes the review parameters with `p4.` on addition to the environment. |
||
#5 | 10013 | Paul Allen |
Added Client support to sync check https://issues.jenkins-ci.org/browse/JENKINS-24055 |
||
#4 | 9980 | Paul Allen |
Changed error reporting to use AbortException. - Use direct access of scm attributes, not via build.getProject().getScm() - Improved logging around labels/changes. |
||
#3 | 9851 | Paul Allen | Merging using p4-jenkins | ||
#2 | 9803 | Paul Allen | Merging using p4-jenkins | ||
#1 | 9690 | Paul Allen |
[Branching using p4-jenkins] Release 1.0.1 |
||
//guest/paul_allen/dev/p4-jenkins/p4-client/src/test/java/org/jenkinsci/plugins/p4/client/ConnectionTest.java | |||||
#2 | 9683 | Paul Allen | Added P4D for win/mac/linux, so tests are ready to run. | ||
#1 | 9672 | Paul Allen | Refactor name from 'p4_client' to 'p4'. | ||
//guest/paul_allen/dev/p4-jenkins/p4-client/src/test/java/org/jenkinsci/plugins/p4_client/client/ConnectionTest.java | |||||
#20 | 9472 | Paul Allen |
Added support to pin build at a label in the populate configuration. - includes help and updates to tests. |
||
#19 | 9137 | Paul Allen | Functional tests for tabBuild endpoint (submitting Labels) and browser (P4Web/Swarm) dummy http server checks. | ||
#18 | 9115 | Paul Allen |
Initial implementation of workspace Cleanup and Sync options. - Includes 3 modes: Automatic Clean/Sync, Force Clean/Sync, Sync Only Automatic Clean/Sync Uses reconcile to clean up workspace and sync changes. Force Clean/Sync Force sync of all files (does not remove files yet...) Sync Only Normal sync with no cleanup TODO: - remove of files in Force Clean/Sync mode - Inline help - Update docs - Add unit/functional tests |
||
#17 | 9091 | Paul Allen |
Added Changelist build filtering for SCM polling: - Configuration uses 'repeatableHeteroProperty' - Filter on Perforce username - Filter on Perforce Depot path (no wildcard support) |
||
#16 | 9055 | Paul Allen |
Label support. Build at a label using the pram 'label'. This includes adding the label to the ChangeEntry, building the change reports and Browser links to Swarm. (TPI-102) |
||
#15 | 8969 | Paul Allen |
Adds all contributing change-lists for the build to the change log (using p4 cstat). - Includes exception logging for server connection to the Jenkins console. |
||
#14 | 8940 | Paul Allen |
Major refactor for the ConnectionHelper class to simplify serialisation. Fixed remote Jenkins JNLP slave connection issue. ClientHelper now extends ConnectionHelper and takes on all methods that require a client workspace. P4StandardCredentials is sent to the remote node instead of Credentials ID due to an issue accessing the Credentials store over a remote connection. For simplicity Client ID (workspace name) is serialised instead of the Workspace object. |
||
#13 | 8926 | Paul Allen |
Bug fix when unshelving files with the Template workspace option. p4-java was unable to switch the worksapce view (without the -f flag) if there were files open. - Improved logging (as this error was hidden) - Added test case for this condition. |
||
#12 | 8922 | Paul Allen | Repo Browser unit tests | ||
#11 | 8916 | Paul Allen | Unit tests for ChangeLog feature and minor fix when listing files if the change is Submitted or Shelved. | ||
#10 | 8915 | Paul Allen |
Support for ChangeLog and RepoBrowser. - Added RepoBrowser for Swarm (porting the others should be easy) - ChangeLog XML file now only stores the changelist number all other information is fetched from Perforce |
||
#9 | 8909 | Paul Allen |
[TPI-83] Clean Workspace that may contain files with wildcards. Added (-f) flag to reconcile and ignore warnings for empty files. |
||
#8 | 8908 | Paul Allen |
Test Workspace Spec used for Manual Workspace configuration. (Total coverage ~80%) |
||
#7 | 8902 | Paul Allen |
Updated test cases: Pushed Workspace 'charset' to abstract Workspace class. Minor bugfixes in Workspace AutoCompletionCandidates method. |
||
#6 | 8898 | Paul Allen | Removed Deprecated 'HudsonTestCase' for Jenkins @Rule | ||
#5 | 8888 | Paul Allen |
Extended test coverage for Workspace and Credentials. - Removed ununsed methods. |
||
#4 | 8865 | Paul Allen | System tests for Workspace behaviours (Static, Manual, Template, Stream). | ||
#3 | 8852 | Paul Allen |
Functional test for unshelve. Includes fix for reconcile and unshelve exclusive locked files. |
||
#2 | 8816 | Paul Allen | Functional tests for build @HEAD and @change; includes build console log check. | ||
#1 | 8815 | Paul Allen | P4D test harness. |