How to: Add a Deploy trigger using the Jython API

Question

How can we add a Deploy trigger using Jython API

Answer

from com.xebialabs.deployit.plugin.api.reflect import Type
from com.xebialabs.xlrelease.domain import PollType

triggerType = Type.valueOf("time.Schedule")
triggerDescriptor = triggerType.descriptor
trigger = triggerDescriptor.newInstance(None)

template = templateApi.getTemplates("trigger")[0]

rel = getCurrentRelease()
trigger.folderId = rel.findFolderId()
trigger.enabled = False
trigger.pollType = PollType.REPEAT
trigger.periodicity = "10"
trigger.template = template.id
trigger.title = "Trigger name"
trigger.releaseTitle = "Release name"
triggersApi.addTrigger(trigger)

 

 

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.