Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Extension
- public class CustomGlobalConfiguration extends GlobalConfiguration {
- /** @return the singleton instance */
- public static CustomGlobalConfiguration get() {
- return GlobalConfiguration.all().get(CustomGlobalConfiguration.class);
- }
- private String pcip;
- private String userName;
- private String password;
- public CustomGlobalConfiguration() {
- // When Jenkins is restarted, load any saved configuration from disk.
- load();
- }
- public String getPcip() {
- return pcip;
- }
- public String getUserName() {
- return userName;
- }
- public String getPassword() {
- return password;
- }
- @DataBoundSetter
- public void setPcip(String pcip) {
- this.pcip = pcip;
- save();
- }
- @DataBoundSetter
- public void setUserName(String userName) {
- this.userName = userName;
- save();
- }
- @DataBoundSetter
- public void setPassword(String password) {
- this.password = password;
- save();
- }
- public class IntegrationLeader extends Builder{
- private final String blueprintName, appName;
- private static final String USER_AGENT = "Mozilla/5.0";
- private static final String POST_PARAMS = "{"length":250}";
- @DataBoundConstructor
- public IntegrationLeader(String blueprintName, String appName) {
- this.blueprintName = blueprintName;
- this.appName = appName;
- }
- // We'll use this from the <tt>config.jelly</tt>.
- public String getBlueprintName(){
- return blueprintName;
- }
- public String getAppName() {
- return appName;
- }
- @Override
- public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {
- EnvVars envVars = new EnvVars();
- final EnvVars env = build.getEnvironment(listener);
- PrintStream log = listener.getLogger();
- //Expanding appname to include the env variables in it's name
- String expandedapp = env.expand(appName);
- String ip = getDescriptor().getCalmIP()
- //rest of the other stuff
- }
- @Override
- public DescriptorImpl getDescriptor() {
- return (DescriptorImpl) super.getDescriptor();
- }
- @Extension
- public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {
- private String calmIP;
- private String calmUser;
- private String calmPwd;
- public List<String> offers;
- public List<String> profiles;
- public List<String> projects;
- public List<String> actions;
- public DescriptorImpl() {
- load();
- }
- public boolean isApplicable(Class<? extends AbstractProject> aClass) {
- // Indicates that this builder can be used with all kinds of project types
- return true;
- }
- /**
- * This human readable name is used in the configuration screen.
- */
- public String getDisplayName() {
- return "Nutanix Calm Blueprint Launch";
- }
- @Override
- public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
- CalmGlobalConfiguration calmGlobalConfiguration = CalmGlobalConfiguration.get();
- calmIP = calmGlobalConfiguration.getPcip();
- calmUser = calmGlobalConfiguration.getUserName();
- calmPwd = calmGlobalConfiguration.getPassword();
- save();
- return super.configure(req, formData);
- }
- }
- public class RunActionOnApp extends Builder{
- private final String blueprintName, appName;
- private static final String USER_AGENT = "Mozilla/5.0";
- private static final String POST_PARAMS = "{"length":250}";
- // Fields in config.jelly must match the parameter names in the "DataBoundConstructor"
- @DataBoundConstructor
- public IntegrationLeader(String blueprintName, String appName) {
- this.blueprintName = blueprintName;
- this.appName = appName;
- }
- // We'll use this from the <tt>config.jelly</tt>.
- public String getBlueprintName(){
- return blueprintName;
- }
- public String getAppName() {
- return appName;
- }
- @Override
- public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {
- EnvVars envVars = new EnvVars();
- final EnvVars env = build.getEnvironment(listener);
- PrintStream log = listener.getLogger();
- //Expanding appname to include the env variables in it's name
- String expandedapp = env.expand(appName);
- String ip = getDescriptor().getCalmIP()
- //rest of the other stuff
- }
- @Override
- public DescriptorImpl getDescriptor() {
- return (DescriptorImpl) super.getDescriptor();
- }
- @Extension // This indicates to Jenkins that this is an implementation of an extension point.
- public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {
- /**
- * To persist global configuration information, simply store it in a
- * field and call save().
- *
- * <p>
- * If you don't want fields to be persisted, use <tt>transient</tt>.
- */
- private String calmIP;
- private String calmUser;
- private String calmPwd;
- public List<String> offers;
- public List<String> profiles;
- public List<String> projects;
- public List<String> actions;
- private int lastEditorId = 0;
- private int lastprofId = 0;
- public DescriptorImpl() {
- load();
- }
- public boolean isApplicable(Class<? extends AbstractProject> aClass) {
- // Indicates that this builder can be used with all kinds of project types
- return true;
- }
- /**
- * This human readable name is used in the configuration screen.
- */
- public String getDisplayName() {
- return "Nutanix Calm Blueprint Launch";
- }
- @Override
- public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
- // To persist global configuration information,
- // set that to properties and call save().
- CalmGlobalConfiguration calmGlobalConfiguration = CalmGlobalConfiguration.get();
- calmIP = calmGlobalConfiguration.getPcip();
- calmUser = calmGlobalConfiguration.getUserName();
- calmPwd = calmGlobalConfiguration.getPassword();
- // ^Can also use req.bindJSON(this, formData);
- // (easier when there are many fields; need set* methods for this, like setUseFrench)
- save();
- return super.configure(req, formData);
- }
- }
Add Comment
Please, Sign In to add comment