use of hudson.model.Hudson in project hudson-2.x by hudson.
the class QueueServiceImplTest method setUp.
@Before
public void setUp() throws Exception {
// static methods
mockStatic(Hudson.class);
// final and native
hudson = mock(Hudson.class);
MockitoAnnotations.initMocks(this);
queueService = new QueueServiceImpl(security);
queueService.setHudson(hudson);
}
use of hudson.model.Hudson in project hudson-2.x by hudson.
the class UpdateJobCommand method run.
protected int run() throws Exception {
Hudson h = Hudson.getInstance();
TopLevelItem item = h.getItem(name);
if (item == null && !create) {
stderr.println("Job '" + name + "' does not exist and create is set to false");
return -1;
}
if (item == null) {
h.checkPermission(Item.CREATE);
h.createProjectFromXML(name, stdin);
} else {
try {
h.checkPermission(Job.CONFIGURE);
File rootDirOfJob = new File(new File(h.getRootDir(), "jobs"), name);
// place it as config.xml
File configXml = Items.getConfigFile(rootDirOfJob).getFile();
IOUtils.copy(stdin, configXml);
item = h.reloadProjectFromDisk(configXml.getParentFile());
} catch (IOException e) {
throw e;
}
}
return 0;
}
use of hudson.model.Hudson in project hudson-2.x by hudson.
the class AbstractProjectOptionHandler method parseArguments.
@Override
public int parseArguments(Parameters params) throws CmdLineException {
Hudson h = Hudson.getInstance();
String src = params.getParameter(0);
AbstractProject s = h.getItemByFullName(src, AbstractProject.class);
if (s == null)
throw new CmdLineException(owner, "No such job '" + src + "' perhaps you meant " + AbstractProject.findNearest(src) + "?");
setter.addValue(s);
return 1;
}
use of hudson.model.Hudson in project hudson-2.x by hudson.
the class TopLevelItemOptionHandler method parseArguments.
@Override
public int parseArguments(Parameters params) throws CmdLineException {
Hudson h = Hudson.getInstance();
String src = params.getParameter(0);
TopLevelItem s = h.getItem(src);
if (s == null)
throw new CmdLineException(owner, "No such job '" + src + "' perhaps you meant " + AbstractProject.findNearest(src) + "?");
setter.addValue(s);
return 1;
}
use of hudson.model.Hudson in project hudson-2.x by hudson.
the class ClientAuthenticationCache method set.
/**
* Persists the specified authentication.
*/
public void set(Authentication a) throws IOException, InterruptedException {
Hudson h = Hudson.getInstance();
// make sure that this security realm is capable of retrieving the authentication by name,
// as it's not required.
UserDetails u = h.getSecurityRealm().loadUserByUsername(a.getName());
props.setProperty(getPropertyKey(), Secret.fromString(u.getUsername()).getEncryptedValue());
save();
}
Aggregations