Hi all.

I understand user can go to a job and click watch job to subscribe yourself
for the changes of this job. What I'm trying to do is in system groovy, use
the class in Jenkins email-ext plugin to add other people to the watch job
list.

At the moment, after I run my script, user "build" is not added to the
watch list.
Here's my system groovy script:

import jenkins.model.*;
import hudson.model.*;
import hudson.plugins.emailext.watching.*;

def build = Thread.currentThread().getCurrentExecutable()
def buildEnvVars = new HashMap()
buildEnvVars.putAll(build.getEnvVars())
def JOB_NAME = buildEnvVars["JOB_NAME"]

println JOB_NAME
instance = Jenkins.instance.getItemByFullName(JOB_NAME)

EmailExtWatchAction watch = new EmailExtWatchAction(instance)

User user = User.get("build")

prop = watch.getJobProperty()
prop.addWatcher(user)
instance.save()

println """
IS_WATCHING=${watch.isWatching()}
EMAIL_TRIGGERS=${watch.getTriggers()}
WATCHERS = ${prop.getWatchers()}
"""


Many thanks,
Kevin

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAMV-oz%3DDEdL8g17UPnj%2BA7XCDSg%2BjnGRFwgEiTCh0MqyWaTn7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to