コード例 #1
0
        private void simpleButton_Form_ServerSettings_SaveSettings_Click(object sender, EventArgs e)
        {
            Conf_ServerSettings_xml inst_Conf_ServerSettings_xml = new Conf_ServerSettings_xml();

            inst_Conf_ServerSettings_xml.Change_settings(textEdit_Form_ServerSettings_IP.Text, textEdit_Form_ServerSettings_Port.Text, textEdit_Form_ServerSettings_User.Text, textEdit_Form_ServerSettings_PubKey.Text);
            MessageBox.Show("Config has been saved", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
コード例 #2
0
        public static string Call(string projectName, string serverName)
        {
            //Load server config data from config file
            Conf_ServerSettings_xml inst_Conf_ServerSettings_xml = new Conf_ServerSettings_xml();

            string[] settingsFromFile = inst_Conf_ServerSettings_xml.LoadDataFromFile().Split(new string[] { "#" }, StringSplitOptions.RemoveEmptyEntries);

            if (settingsFromFile.Length != 4)
            {
                return("NotFilledConf");
            }


            try
            {
                string ip   = settingsFromFile[0];
                int    port = Convert.ToInt32(settingsFromFile[1]);
                string user = settingsFromFile[2];
                string key  = settingsFromFile[3];

                Conf_ScriptsSettings_xml inst_Conf_ScriptsSettings_xml = new Conf_ScriptsSettings_xml();
                string path = inst_Conf_ScriptsSettings_xml.LoadDataFromFile();

                ConnectionInfo ConnInfo = new ConnectionInfo(ip, port, user,
                                                             new AuthenticationMethod[] { new PrivateKeyAuthenticationMethod(user, new PrivateKeyFile[]
                    { // Key Based Authentication (using keys in OpenSSH Format)
                        new PrivateKeyFile(@"" + key + "", "passphrase")
                    }), });

                string output = "";
                using (var sshclient = new SshClient(ConnInfo))
                {
                    sshclient.Connect();
                    using (var cmd = sshclient.CreateCommand("python " + path + "jenkins_create_project.py " + GetData_for_call.GetHttp("Jenkins", serverName) + " " + projectName))
                    {
                        cmd.Execute();
                        string[] stepsArray = (cmd.Result).Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);

                        for (int i = 0; i < stepsArray.Length; i++)
                        {
                            output += stepsArray[i] + "\r\n";
                        }
                    }
                    sshclient.Disconnect();
                }
                return(output);
            }

            catch
            { return("NoConnect"); }
        }
コード例 #3
0
        public Form_ServerSettings()
        {
            InitializeComponent();

            Conf_ServerSettings_xml inst_Conf_ServerSettings_xml = new Conf_ServerSettings_xml();

            string[] settingsFromFile = inst_Conf_ServerSettings_xml.LoadDataFromFile().Split('#');
            //if settings were saved before, read these date and output to form
            if (settingsFromFile.Length == 4)
            {
                textEdit_Form_ServerSettings_IP.Text     = settingsFromFile[0];
                textEdit_Form_ServerSettings_Port.Text   = settingsFromFile[1];
                textEdit_Form_ServerSettings_User.Text   = settingsFromFile[2];
                textEdit_Form_ServerSettings_PubKey.Text = settingsFromFile[3];
            }
        }