forked from cloudbees/jenkins-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
move-copy-promote-simulation.groovy
27 lines (22 loc) · 1.14 KB
/
move-copy-promote-simulation.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*** BEGIN META {
"name" : "Move/Copy/Promote Simulation",
"comment" : "Simulate a Move/Copy/Promote operation for troubleshooting purpose. The script create two folders
(names starting with `testF0`) that can be deleted after the test",
"parameters" : [ ],
"core": "1.642",
"authors" : [
{ name : "Allan Burdajewicz, Emilio Escobar Reyero" }
]
} END META**/
import com.cloudbees.hudson.plugins.folder.Folder
import com.cloudbees.opscenter.context.remote.RemotePath;
import com.cloudbees.opscenter.replication.*
def now = new java.text.SimpleDateFormat("yyyyMMddHHmmss").format(new java.util.Date());
def j = Jenkins.instance
def r = new java.security.SecureRandom()
def f1 = j.createProject(Folder.class, "testF01-$now-" + r.nextInt(10000))
def f2 = j.createProject(Folder.class, "testF02-$now-" + r.nextInt(10000))
def job = f1.createProject(FreeStyleProject.class, "TestJob-$now-" + r.nextInt(10000))
def session = new ReplicationSession(job).withRemotePath(new RemotePath(f2)).withFileSet(ItemReplicationFileSet.newInstance(job, ReplicationMode.MOVE))
def result = ItemReplicationTask.scheduleMoveTask(session);
println "Created:" + result.isCreated()