use of org.swift.bamboo.cli.BambooClient in project ArTEMiS by ls1intum.
the class BambooService method updatePlanRepository.
/**
* Updates the configured repository for a given plan to the given Bitbucket Server repository.
*
* @param bambooProject The key of the Bamboo plan's project, e.g. 'EIST16W1'.
* @param bambooPlan The plan key, which is usually the name, e.g. 'ga56hur'.
* @param bambooRepositoryName The name of the configured repository in the Bamboo plan.
* @param bitbucketProject The key for the Bitbucket Server (formerly Stash) project to which we want to update the plan.
* @param bitbucketRepository The name/slug for the Bitbucket Server (formerly Stash) repository to which we want to update the plan.
*/
public String updatePlanRepository(String bambooProject, String bambooPlan, String bambooRepositoryName, String bitbucketProject, String bitbucketRepository) throws BambooException {
final BambooClient bambooClient = new BambooClient();
String[] args = new String[] { "--field1", "repository.stash.projectKey", "--value1", bitbucketProject, // Doesn't seem to be required
"--field2", // Doesn't seem to be required
"repository.stash.repositoryId", // Doesn't seem to be required
"--value2", // Doesn't seem to be required
"2499", "--field3", "repository.stash.repositorySlug", "--value3", bitbucketRepository, // e.g. "ssh://git@repobruegge.in.tum.de:7999/madm/helloworld.git"
"--field4", // e.g. "ssh://git@repobruegge.in.tum.de:7999/madm/helloworld.git"
"repository.stash.repositoryUrl", // e.g. "ssh://git@repobruegge.in.tum.de:7999/madm/helloworld.git"
"--value4", // e.g. "ssh://git@repobruegge.in.tum.de:7999/madm/helloworld.git"
buildSshRepositoryUrl(bitbucketProject, bitbucketRepository), "--field5", "repository.stash.server", "--value5", BITBUCKET_APPLICATION_LINK_ID, "--field6", "repository.stash.branch", "--value6", "master", "-s", BAMBOO_SERVER_URL.toString(), "--user", BAMBOO_USER, "--password", BAMBOO_PASSWORD };
// workaround to pass additional fields
bambooClient.doWork(args);
try {
log.info("Update plan repository for build plan " + bambooProject + "-" + bambooPlan);
String message = bambooClient.getRepositoryHelper().addOrUpdateRepository(bambooRepositoryName, null, null, bambooProject + "-" + bambooPlan, "STASH", null, false, true, true);
log.info("Update plan repository for build plan " + bambooProject + "-" + bambooPlan + " was successful." + message);
return message;
} catch (CliClient.ClientException | CliClient.RemoteRestException e) {
log.error(e.getMessage(), e);
throw new BambooException("Something went wrong while updating the plan repository", e);
}
}
use of org.swift.bamboo.cli.BambooClient in project ArTEMiS by ls1intum.
the class BambooService method getBambooClient.
private BambooClient getBambooClient() {
final BambooClient bambooClient = new BambooClient();
// setup the Bamboo Client to use the correct username and password
String[] args = new String[] { "-s", BAMBOO_SERVER_URL.toString(), "--user", BAMBOO_USER, "--password", BAMBOO_PASSWORD };
// only invoke this to set server address, username and password so that the following action will work
bambooClient.doWork(args);
return bambooClient;
}
Aggregations