├── lib-compile ├── javac2.jar └── asm4-all.jar ├── server ├── resources │ └── buildServerResources │ │ ├── AdminPage.jsp │ │ ├── EditProjectPage.jsp │ │ ├── ErrorPage.jsp │ │ ├── css │ │ └── ServerConfigurationsAdminPage.css │ │ ├── EditProjectConfigurationsListPage.jsp │ │ ├── js │ │ └── ServerConfigurationsAdminPage.js │ │ ├── EditProjectConfigurationEditPage.jsp │ │ ├── AdminConfigurationsListPage.jsp │ │ ├── AdminTemplateEditPage.jsp │ │ └── AdminConfigurationEditPage.jsp ├── src │ ├── ServerConfigurations │ │ └── server │ │ │ ├── AdminConfiguration │ │ │ ├── PropertiesType.java │ │ │ ├── TemplateProperty.java │ │ │ ├── ServerConfigurationProperty.java │ │ │ ├── AdminPage.java │ │ │ ├── Template.java │ │ │ ├── ServerConfigurations.java │ │ │ ├── ServerConfiguration.java │ │ │ └── Controller.java │ │ │ ├── ServerListener.java │ │ │ ├── ProjectConfiguration │ │ │ ├── SettingsFactory.java │ │ │ ├── ProjectConfiguration.java │ │ │ ├── EditProjectPage.java │ │ │ ├── ProjectConfigurations.java │ │ │ └── Controller.java │ │ │ ├── BuildLogFilter.java │ │ │ ├── ServerUtil.java │ │ │ ├── ParametersPreprocessor.java │ │ │ └── PropertiesProvider.java │ └── META-INF │ │ └── build-server-plugin-ServerConfigurations.xml └── ServerConfigurations-server.iml ├── bin ├── ServerConfigurations.zip ├── ServerConfigurations_tc9.zip ├── ServerConfigurations_jre6_tc9.zip ├── ServerConfigurations_jre7_tc9.zip └── README.md ├── root.iml ├── teamcity-plugin.xml ├── common ├── ServerConfigurations-common.iml └── src │ └── ServerConfigurations │ └── common │ └── Util.java ├── agent ├── src │ ├── META-INF │ │ └── build-agent-plugin-ServerConfigurations.xml │ └── ServerConfigurations │ │ └── agent │ │ └── AgentListener.java └── ServerConfigurations-agent.iml ├── ServerConfigurations.iml ├── README.md ├── LICENSE ├── teamcity-common.xml ├── serverconfigurations.xml └── ServerConfigurations.ipr /lib-compile/javac2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIEII/ServerConfigurations/HEAD/lib-compile/javac2.jar -------------------------------------------------------------------------------- /lib-compile/asm4-all.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIEII/ServerConfigurations/HEAD/lib-compile/asm4-all.jar -------------------------------------------------------------------------------- /server/resources/buildServerResources/AdminPage.jsp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bin/ServerConfigurations.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIEII/ServerConfigurations/HEAD/bin/ServerConfigurations.zip -------------------------------------------------------------------------------- /bin/ServerConfigurations_tc9.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIEII/ServerConfigurations/HEAD/bin/ServerConfigurations_tc9.zip -------------------------------------------------------------------------------- /server/resources/buildServerResources/EditProjectPage.jsp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bin/ServerConfigurations_jre6_tc9.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIEII/ServerConfigurations/HEAD/bin/ServerConfigurations_jre6_tc9.zip -------------------------------------------------------------------------------- /bin/ServerConfigurations_jre7_tc9.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIEII/ServerConfigurations/HEAD/bin/ServerConfigurations_jre7_tc9.zip -------------------------------------------------------------------------------- /root.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /server/resources/buildServerResources/ErrorPage.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="/include.jsp"%> 2 | 3 | 4 | 5 | 6 | 7 |
8 | 10 |
-------------------------------------------------------------------------------- /server/resources/buildServerResources/css/ServerConfigurationsAdminPage.css: -------------------------------------------------------------------------------- 1 | .serverConfigurations h2 { 2 | margin-bottom: 10px; 3 | } 4 | 5 | .serverConfigurations .runnerFormTable { 6 | margin-bottom: 20px; 7 | } 8 | 9 | .serverConfigurations .runnerFormTable tr *:first-child { 10 | width:372px; 11 | } 12 | 13 | .serverConfigurations input[type=text], .serverConfigurations input[type=password], .serverConfigurations select { 14 | width: 372px; 15 | } -------------------------------------------------------------------------------- /bin/README.md: -------------------------------------------------------------------------------- 1 | | File | Description | 2 | | --- | --- | 3 | | bin/ServerConfigurations.zip | this version works with Teamcity >=10 and Java 1.8 | 4 | | bin/ServerConfigurations_jre6_tc9.zip | this version works with Teamcity <=9 and Java 1.6 | 5 | | bin/ServerConfigurations_jre7_tc9.zip | this version works with Teamcity <=9 and Java 1.7 | 6 | | bin/ServerConfigurations_tc9.zip | this version works with Teamcity <=9 and Java 1.8 | -------------------------------------------------------------------------------- /teamcity-plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | ServerConfigurations 6 | Server Configurations 7 | 2.0 8 | Plugin helps you store and use server configurations with list of parameters 9 | Alexander Shepel 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /common/ServerConfigurations-common.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /common/src/ServerConfigurations/common/Util.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2010 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ServerConfigurations.common; 18 | 19 | /** 20 | * Example server and agent shared class 21 | */ 22 | public class Util { 23 | public final static String PLUGIN_NAME = "ServerConfigurations"; 24 | } 25 | -------------------------------------------------------------------------------- /server/src/ServerConfigurations/server/AdminConfiguration/PropertiesType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ServerConfigurations.server.AdminConfiguration; 18 | 19 | /** 20 | * Created by IIIEII on 02.06.15. 21 | */ 22 | public enum PropertiesType { 23 | STRING, 24 | PASSWORD, 25 | } 26 | 27 | -------------------------------------------------------------------------------- /server/src/ServerConfigurations/server/ServerListener.java: -------------------------------------------------------------------------------- 1 | package ServerConfigurations.server; 2 | 3 | import jetbrains.buildServer.log.Loggers; 4 | import jetbrains.buildServer.serverSide.BuildServerAdapter; 5 | import jetbrains.buildServer.serverSide.BuildServerListener; 6 | import jetbrains.buildServer.serverSide.SBuildServer; 7 | import jetbrains.buildServer.util.EventDispatcher; 8 | import org.jetbrains.annotations.NotNull; 9 | import ServerConfigurations.common.Util; 10 | 11 | public class ServerListener extends BuildServerAdapter { 12 | @NotNull 13 | private SBuildServer myServer; 14 | 15 | public ServerListener(@NotNull final EventDispatcher dispatcher, @NotNull SBuildServer server) { 16 | dispatcher.addListener(this); 17 | myServer = server; 18 | } 19 | 20 | @Override 21 | public void serverStartup() { 22 | Loggers.SERVER.info("Plugin '" + Util.PLUGIN_NAME + "'. Is running on server version " + myServer.getFullServerVersion() + "."); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /agent/src/META-INF/build-agent-plugin-ServerConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /agent/ServerConfigurations-agent.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | file://$MODULE_DIR$/src/META-INF/build-agent-plugin-ServerConfigurations.xml 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ServerConfigurations.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /server/src/ServerConfigurations/server/ProjectConfiguration/SettingsFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ServerConfigurations.server.ProjectConfiguration; 18 | 19 | import ServerConfigurations.common.Util; 20 | import jetbrains.buildServer.serverSide.settings.ProjectSettings; 21 | import jetbrains.buildServer.serverSide.settings.ProjectSettingsFactory; 22 | import jetbrains.buildServer.serverSide.settings.ProjectSettingsManager; 23 | import org.jetbrains.annotations.NotNull; 24 | 25 | /** 26 | * Created by IIIEII on 30.05.15. 27 | */ 28 | public class SettingsFactory implements ProjectSettingsFactory { 29 | 30 | public SettingsFactory(@NotNull ProjectSettingsManager projectSettingsManager) { 31 | projectSettingsManager.registerSettingsFactory(Util.PLUGIN_NAME, this); 32 | } 33 | 34 | @NotNull 35 | public ProjectSettings createProjectSettings(String projectId) { 36 | return new ProjectConfigurations(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /server/ServerConfigurations-server.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | file://$MODULE_DIR$/src/META-INF/build-server-plugin-ServerConfigurations.xml 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /server/src/ServerConfigurations/server/AdminConfiguration/TemplateProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ServerConfigurations.server.AdminConfiguration; 18 | 19 | import com.thoughtworks.xstream.annotations.XStreamAlias; 20 | 21 | import java.util.LinkedHashMap; 22 | import java.util.Map; 23 | 24 | /** 25 | * Created by IIIEII on 02.06.15. 26 | */ 27 | @XStreamAlias(Controller.TEMPLATE_PROP_TAG) 28 | public class TemplateProperty { 29 | 30 | @XStreamAlias(Controller.TEMPLATE_PROP_NAME_TAG) 31 | private String name; 32 | 33 | @XStreamAlias(Controller.TEMPLATE_PROP_TYPE_TAG) 34 | private PropertiesType type; 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | public PropertiesType getType() { 44 | return type; 45 | } 46 | public void setType(PropertiesType type) { 47 | this.type = type; 48 | } 49 | 50 | public Map getPropertyMap() { 51 | Map map = new LinkedHashMap(); 52 | map.put(Controller.TEMPLATE_PROP_NAME_TAG, name); 53 | map.put(Controller.TEMPLATE_PROP_TYPE_TAG, type); 54 | return map; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /server/src/ServerConfigurations/server/ProjectConfiguration/ProjectConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ServerConfigurations.server.ProjectConfiguration; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | 22 | /** 23 | * Created by IIIEII on 30.05.15. 24 | */ 25 | public class ProjectConfiguration { 26 | 27 | private String name; 28 | private String prefix; 29 | private String branchFilter; 30 | 31 | public String getName() { 32 | return this.name; 33 | } 34 | public void setName(String name) { 35 | this.name = name; 36 | } 37 | 38 | public String getPrefix() { 39 | return this.prefix; 40 | } 41 | public void setPrefix(String prefix) { 42 | this.prefix = prefix; 43 | } 44 | 45 | public String getBranchFilter() { 46 | return branchFilter; 47 | } 48 | public void setBranchFilter(String branchFilter) { 49 | this.branchFilter = branchFilter; 50 | } 51 | 52 | public Map getConfigurationMap() { 53 | HashMap map = new HashMap(); 54 | map.put(Controller.PROJECT_CONFIGURATION_NAME_TAG, this.name); 55 | map.put(Controller.PROJECT_CONFIGURATION_PREFIX_TAG, this.prefix); 56 | map.put(Controller.PROJECT_CONFIGURATION_BRANCHFILTER_TAG, this.branchFilter); 57 | return map; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /server/src/ServerConfigurations/server/AdminConfiguration/ServerConfigurationProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ServerConfigurations.server.AdminConfiguration; 18 | 19 | import ServerConfigurations.server.ServerUtil; 20 | import com.thoughtworks.xstream.annotations.XStreamAlias; 21 | 22 | import java.util.LinkedHashMap; 23 | import java.util.Map; 24 | 25 | /** 26 | * Created by IIIEII on 02.06.15. 27 | */ 28 | @XStreamAlias(Controller.CONFIGURATION_PROP_TAG) 29 | public class ServerConfigurationProperty { 30 | 31 | @XStreamAlias(Controller.CONFIGURATION_PROP_NAME_TAG) 32 | private String name = null; 33 | 34 | @XStreamAlias(Controller.CONFIGURATION_PROP_VALUE_TAG) 35 | private String value = null; 36 | 37 | public ServerConfigurationProperty(String name, String value, PropertiesType type) { 38 | this.name = name; 39 | this.setValue(value, type); 40 | } 41 | 42 | public String getName() { 43 | return name; 44 | } 45 | public void setName(String name) { 46 | this.name = name; 47 | } 48 | 49 | public String getValue(PropertiesType type) { 50 | if (type.equals(PropertiesType.PASSWORD)) { 51 | return ServerUtil.decrypt(value); 52 | } 53 | return value; 54 | } 55 | public void setValue(String value, PropertiesType type) { 56 | if (type.equals(PropertiesType.PASSWORD)) { 57 | this.value = ServerUtil.encrypt(value); 58 | } else { 59 | this.value = value; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /server/src/META-INF/build-server-plugin-ServerConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Server Configurations for TeamCity 2 | ================================== 3 | 4 | This plugin helps you store and use server configurations with list of parameters (addresses, ports, credentials, etc). 5 | 6 | Features: 7 | 8 | * Create server configuration templates within administration screen 9 | * Create server configuration by choosing template and filling template parameters 10 | * Attach server configuration to your projects and use all parameters in build configurations 11 | * Change server configurations in your projects to use another parameters without any reconfiguration 12 | * Server configurations are inherited from parent projects to all child projects 13 | * Attach different server configurations in your project to different branches 14 | 15 | 16 | Configure template 17 | ------------------------- 18 | ![Template configuration](https://www.evernote.com/shard/s1/sh/b495670e-cb22-4174-9d2a-9cf79bbaa978/d32edfb3dc96849e9e2f73870c7fb656/res/5a928c8a-afb3-495a-8d24-666bb69edacb/skitch.png?resizeSmall&width=832) 19 | 20 | Configure some server configurations 21 | -------------------------------------------------- 22 | ![Server configuration](https://www.evernote.com/shard/s1/sh/a8b92fae-3fb1-4ae6-912b-870e0e95394a/866500c1d6ae3c874a3ee91eaee67717/res/9d78e170-37c1-459c-a396-011f873a4777/skitch.png?resizeSmall&width=832) 23 | 24 | Attach server configuration to project 25 | ------------------------------------------------- 26 | ![Project configuration](https://www.evernote.com/shard/s1/sh/a9dd537b-1d2f-4748-bcd1-7ed8eca4d34d/49768cf8709fc114a4ea6bd8597568a5/res/545b992f-7b4d-45f4-8356-cb32057f0671/skitch.png?resizeSmall&width=832) 27 | ![Project configuration](https://www.evernote.com/shard/s1/sh/3e0f88e9-7b3f-4d29-9c71-611788127976/08ff0710028278b21874a1c0908ecd3d/res/3fe566f8-d429-412d-a631-ec28e3ffebe8/skitch.png?resizeSmall&width=832) 28 | 29 | Use parameters in build configurations 30 | --------------------------------------------------- 31 | Parameters will be available in build configurations with selected prefix. Password values will be hidden from parameters list and build log. 32 | 33 | ![Parameters usage](https://www.evernote.com/shard/s1/sh/f5a411aa-54c1-404b-8768-008a58c2ca37/18134bad3eeb6c5cfc4f5e831c96f6b6/res/6cda0af6-159c-4795-99d2-300cb5c5e064/skitch.png?resizeSmall&width=832) -------------------------------------------------------------------------------- /server/src/ServerConfigurations/server/ProjectConfiguration/EditProjectPage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ServerConfigurations.server.ProjectConfiguration; 18 | 19 | import ServerConfigurations.common.Util; 20 | import jetbrains.buildServer.web.openapi.*; 21 | import org.jetbrains.annotations.NotNull; 22 | 23 | import javax.servlet.http.HttpServletRequest; 24 | import java.util.ArrayList; 25 | import java.util.Map; 26 | 27 | /** 28 | * Created by IIIEII on 29.05.15. 29 | */ 30 | public class EditProjectPage extends SimpleCustomTab { 31 | 32 | private static final String AFTER_PAGE_ID = "projectParams"; 33 | private static final String BEFORE_PAGE_ID = "metaRunner"; 34 | private static final String PAGE = "EditProjectPage.jsp"; 35 | 36 | private static final String TAB_TITLE = "Server Configurations"; 37 | 38 | public EditProjectPage(@NotNull PagePlaces pagePlaces, 39 | @NotNull PluginDescriptor descriptor) { 40 | super(pagePlaces); 41 | setPluginName(Util.PLUGIN_NAME); 42 | setIncludeUrl(descriptor.getPluginResourcesPath(PAGE)); 43 | setPlaceId(PlaceId.EDIT_PROJECT_PAGE_TAB); 44 | addCssFile(descriptor.getPluginResourcesPath("css/ServerConfigurationsAdminPage.css")); 45 | addJsFile(descriptor.getPluginResourcesPath("js/ServerConfigurationsAdminPage.js")); 46 | addCssFile("/css/forms.css"); 47 | setTabTitle(TAB_TITLE); 48 | ArrayList after = new ArrayList(); 49 | after.add(AFTER_PAGE_ID); 50 | ArrayList before = new ArrayList(); 51 | before.add(BEFORE_PAGE_ID); 52 | setPosition(PositionConstraint.between(after, before)); 53 | register(); 54 | } 55 | 56 | @Override 57 | public boolean isAvailable(@NotNull HttpServletRequest request) { 58 | return super.isAvailable(request); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /server/src/ServerConfigurations/server/BuildLogFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ServerConfigurations.server; 18 | 19 | import jetbrains.buildServer.UserDataStorage; 20 | import jetbrains.buildServer.messages.BuildMessage1; 21 | import jetbrains.buildServer.messages.BuildMessagesTranslator; 22 | import jetbrains.buildServer.messages.DefaultMessagesInfo; 23 | import jetbrains.buildServer.serverSide.RunningBuildEx; 24 | import jetbrains.buildServer.serverSide.SRunningBuild; 25 | import org.jetbrains.annotations.NotNull; 26 | 27 | import java.util.ArrayList; 28 | import java.util.Collections; 29 | import java.util.List; 30 | import java.util.Set; 31 | 32 | /** 33 | * Created by IIIEII on 08.01.15. 34 | */ 35 | public class BuildLogFilter implements BuildMessagesTranslator { 36 | 37 | private final ServerUtil myUtil; 38 | 39 | public BuildLogFilter(@NotNull ServerUtil util) { 40 | myUtil = util; 41 | } 42 | 43 | @NotNull 44 | public List translateMessages(@NotNull final SRunningBuild build, 45 | @NotNull final List messages 46 | ) { 47 | final UserDataStorage storage = ((RunningBuildEx) build).getUserDataStorage(); 48 | Set storedPasswords = storage.getValue(myUtil.passwordsKEY); 49 | 50 | List result = new ArrayList(); 51 | for (BuildMessage1 originalMessage : messages) { 52 | final Object data = originalMessage.getValue(); 53 | if (!DefaultMessagesInfo.MSG_TEXT.equals(originalMessage.getTypeId()) || data == null || !(data instanceof String)) { 54 | result.add(originalMessage); 55 | continue; 56 | } 57 | String text = (String) data; 58 | 59 | if (storedPasswords != null) { 60 | for (String value : storedPasswords) { 61 | if (!value.equals("")) 62 | text = text.replaceAll(value, "******"); 63 | } 64 | } 65 | result.add(DefaultMessagesInfo.createTextMessage(originalMessage, text)); 66 | } 67 | return result; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /server/src/ServerConfigurations/server/AdminConfiguration/AdminPage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ServerConfigurations.server.AdminConfiguration; 18 | 19 | import ServerConfigurations.common.Util; 20 | import jetbrains.buildServer.serverSide.SBuildServer; 21 | import jetbrains.buildServer.serverSide.auth.Permission; 22 | import jetbrains.buildServer.web.openapi.*; 23 | 24 | import org.jetbrains.annotations.NotNull; 25 | 26 | import javax.servlet.http.HttpServletRequest; 27 | 28 | import java.util.ArrayList; 29 | 30 | /** 31 | * Created by IIIEII on 27.05.15. 32 | */ 33 | public class AdminPage extends jetbrains.buildServer.controllers.admin.AdminPage { 34 | 35 | private static final String AFTER_PAGE_ID = "auth"; 36 | private static final String BEFORE_PAGE_ID = "email"; 37 | private static final String PAGE = "AdminPage.jsp"; 38 | 39 | private static final String TAB_TITLE = "Server Configurations"; 40 | 41 | public AdminPage(@NotNull SBuildServer server, 42 | @NotNull PagePlaces pagePlaces, 43 | @NotNull PluginDescriptor descriptor) { 44 | super(pagePlaces); 45 | setPluginName(Util.PLUGIN_NAME); 46 | setIncludeUrl(descriptor.getPluginResourcesPath(PAGE)); 47 | addCssFile(descriptor.getPluginResourcesPath("css/ServerConfigurationsAdminPage.css")); 48 | addJsFile(descriptor.getPluginResourcesPath("js/ServerConfigurationsAdminPage.js")); 49 | addCssFile("/css/forms.css"); 50 | setTabTitle(TAB_TITLE); 51 | ArrayList after = new ArrayList(); 52 | after.add(AFTER_PAGE_ID); 53 | ArrayList before = new ArrayList(); 54 | before.add(BEFORE_PAGE_ID); 55 | setPosition(PositionConstraint.between(after, before)); 56 | register(); 57 | } 58 | 59 | @Override 60 | public boolean isAvailable(@NotNull HttpServletRequest request) { 61 | return super.isAvailable(request) && checkHasGlobalPermission(request, Permission.CHANGE_SERVER_SETTINGS); 62 | } 63 | 64 | @NotNull 65 | public String getGroup() { 66 | return SERVER_RELATED_GROUP; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /server/src/ServerConfigurations/server/ServerUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ServerConfigurations.server; 18 | 19 | import ServerConfigurations.common.Util; 20 | import com.sun.xml.internal.messaging.saaj.packaging.mime.util.BASE64DecoderStream; 21 | import com.sun.xml.internal.messaging.saaj.packaging.mime.util.BASE64EncoderStream; 22 | import jetbrains.buildServer.UserDataKey; 23 | 24 | import javax.crypto.Cipher; 25 | import javax.crypto.SecretKey; 26 | import javax.crypto.spec.SecretKeySpec; 27 | import java.util.Set; 28 | 29 | /** 30 | * Created by IIIEII on 12.01.15. 31 | */ 32 | public class ServerUtil { 33 | public final UserDataKey currentBuildNumberKEY; 34 | public final UserDataKey passwordsKEY; 35 | private static final String key = "4a6XUJr0kRezhJlFeyZkSg=="; 36 | private static Cipher ecipher; 37 | private static Cipher dcipher; 38 | 39 | 40 | public ServerUtil () { 41 | currentBuildNumberKEY = new UserDataKey(String.class, Util.PLUGIN_NAME + ".currentBuildNumber"); 42 | passwordsKEY = new UserDataKey(Set.class, Util.PLUGIN_NAME + ".passwords"); 43 | try { 44 | ecipher = Cipher.getInstance("AES"); 45 | ecipher.init(Cipher.ENCRYPT_MODE, getKey()); 46 | dcipher = Cipher.getInstance("AES"); 47 | dcipher.init(Cipher.DECRYPT_MODE, getKey()); 48 | } catch (Exception e) { } 49 | } 50 | 51 | private static SecretKey getKey () { 52 | byte[] encodedKey = BASE64DecoderStream.decode(key.getBytes()); 53 | return new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES"); 54 | } 55 | 56 | public static String encrypt(String str) { 57 | try { 58 | byte[] utf8 = str.getBytes("UTF8"); 59 | byte[] enc = ecipher.doFinal(utf8); 60 | enc = BASE64EncoderStream.encode(enc); 61 | return new String(enc); 62 | } catch (Exception e) { } 63 | return ""; 64 | } 65 | 66 | public static String decrypt(String str) { 67 | try { 68 | byte[] dec = BASE64DecoderStream.decode(str.getBytes()); 69 | byte[] utf8 = dcipher.doFinal(dec); 70 | return new String(utf8, "UTF8"); 71 | } catch (Exception e) { } 72 | return ""; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /agent/src/ServerConfigurations/agent/AgentListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ServerConfigurations.agent; 18 | 19 | import jetbrains.buildServer.agent.*; 20 | import jetbrains.buildServer.log.Loggers; 21 | import jetbrains.buildServer.util.EventDispatcher; 22 | import org.jetbrains.annotations.NotNull; 23 | import ServerConfigurations.common.Util; 24 | 25 | import java.util.Iterator; 26 | import java.util.Map; 27 | 28 | /** 29 | * Created by IIIEII on 27.05.15. 30 | */ 31 | public class AgentListener extends AgentLifeCycleAdapter { 32 | public AgentListener(@NotNull EventDispatcher dispatcher) { 33 | dispatcher.addListener(this); 34 | } 35 | 36 | @Override 37 | public void agentInitialized(@NotNull final BuildAgent agent) { 38 | Loggers.AGENT.info("Plugin '" + Util.PLUGIN_NAME + "'. is running."); 39 | } 40 | 41 | @Override 42 | public void beforeRunnerStart(@NotNull 43 | BuildRunnerContext runner) { 44 | Iterator paramIter = runner.getConfigParameters().entrySet().iterator(); 45 | while(paramIter.hasNext()) { 46 | Map.Entry param = (Map.Entry)paramIter.next(); 47 | if (param.getValue().matches("^%secure:configuration\\.password[^%]+%$")) { 48 | runner.addConfigParameter(param.getKey(), runner.getConfigParameters().get(param.getValue().substring(1, param.getValue().length() - 1))); 49 | } 50 | } 51 | paramIter = runner.getBuildParameters().getEnvironmentVariables().entrySet().iterator(); 52 | while(paramIter.hasNext()) { 53 | Map.Entry param = (Map.Entry)paramIter.next(); 54 | if (param.getValue().matches("^%secure:configuration\\.password[^%]+%$")) { 55 | runner.addEnvironmentVariable(param.getKey(), runner.getConfigParameters().get(param.getValue().substring(1, param.getValue().length() - 1))); 56 | } 57 | } 58 | paramIter = runner.getBuildParameters().getSystemProperties().entrySet().iterator(); 59 | while(paramIter.hasNext()) { 60 | Map.Entry param = (Map.Entry)paramIter.next(); 61 | if (param.getValue().matches("^%secure:configuration\\.password[^%]+%$")) { 62 | runner.addSystemProperty(param.getKey(), runner.getConfigParameters().get(param.getValue().substring(1, param.getValue().length() - 1))); 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /server/src/ServerConfigurations/server/AdminConfiguration/Template.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ServerConfigurations.server.AdminConfiguration; 18 | 19 | import com.thoughtworks.xstream.annotations.XStreamAlias; 20 | import com.thoughtworks.xstream.annotations.XStreamImplicit; 21 | 22 | import java.util.ArrayList; 23 | import java.util.LinkedHashMap; 24 | import java.util.List; 25 | import java.util.Map; 26 | 27 | /** 28 | * Created by IIIEII on 02.06.15. 29 | */ 30 | @XStreamAlias(Controller.TEMPLATE_TAG) 31 | public class Template { 32 | 33 | @XStreamAlias(Controller.TEMPLATE_NAME_TAG) 34 | private String name = null; 35 | 36 | @XStreamImplicit 37 | private List properties = new ArrayList(); 38 | 39 | public String getName() { 40 | return name; 41 | } 42 | public void setName(String name) { 43 | this.name = name; 44 | } 45 | 46 | public Map getTemplateMap() { 47 | Map templatesMap = new LinkedHashMap(); 48 | templatesMap.put(Controller.TEMPLATE_NAME_TAG, name); 49 | templatesMap.put(Controller.TEMPLATE_PROPS_TAG, this.getProperties()); 50 | return templatesMap; 51 | }; 52 | 53 | public List getProperties() { 54 | if (this.properties == null) 55 | this.properties = new ArrayList(); 56 | return this.properties; 57 | } 58 | public TemplateProperty getPropertyByName(String name) { 59 | for (TemplateProperty property : this.getProperties()) { 60 | if (property.getName().contentEquals(name)) { 61 | return property; 62 | } 63 | } 64 | return null; 65 | } 66 | public void setProperty(TemplateProperty newProperty) { 67 | boolean found = false; 68 | for (TemplateProperty property : this.getProperties()) { 69 | if (property.getName().contentEquals(newProperty.getName())) { 70 | property.setType(newProperty.getType()); 71 | found = true; 72 | } 73 | } 74 | if (!found) { 75 | this.getProperties().add(newProperty); 76 | } 77 | } 78 | public void setProperty(String name, PropertiesType type) { 79 | TemplateProperty property = new TemplateProperty(); 80 | property.setName(name); 81 | property.setType(type); 82 | this.setProperty(property); 83 | } 84 | public void clearProperties() { 85 | this.getProperties().clear(); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /server/resources/buildServerResources/EditProjectConfigurationsListPage.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="/include.jsp"%> 2 | 3 | <%-- 4 | ~ Copyright 2000-2015 JetBrains s.r.o. 5 | ~ 6 | ~ Licensed under the Apache License, Version 2.0 (the "License"); 7 | ~ you may not use this file except in compliance with the License. 8 | ~ You may obtain a copy of the License at 9 | ~ 10 | ~ http://www.apache.org/licenses/LICENSE-2.0 11 | ~ 12 | ~ Unless required by applicable law or agreed to in writing, software 13 | ~ distributed under the License is distributed on an "AS IS" BASIS, 14 | ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ~ See the License for the specific language governing permissions and 16 | ~ limitations under the License. 17 | --%> 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 |

Server configurations

27 |
This page contains server configurations defined in the current project. Parameters from server configurations could be used in any build configuration with desired prefix (e.g. %{some_prefix}.domain.name%).
28 | 31 |
32 | 33 | 34 | There are no server configurations in this project. 35 | 36 | 37 | 38 | 39 | Parameters Prefix 40 | Branch Filter 41 | Configuration Name 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | BS.openUrl(event, '${confEditUrl}'); return false; 56 | 57 | 58 | 59 | 60 | 61 | Edit 62 | 63 | 64 | Delete 65 | 66 | 67 | 68 | 69 | 70 | 71 |
72 |
-------------------------------------------------------------------------------- /server/resources/buildServerResources/js/ServerConfigurationsAdminPage.js: -------------------------------------------------------------------------------- 1 | var ServerConfigurations = { 2 | getFunction: function (buttonName, formName, paramsList, messageComponentName, componentName) { 3 | return function (event, success, failure) { 4 | $(buttonName).disabled = 'true'; 5 | BS.Util.show($('saving')); 6 | BS.ajaxRequest($(formName).action, { 7 | parameters: ServerConfigurations.getParams(paramsList), 8 | onComplete: function (transport) { 9 | if (transport.responseXML) { 10 | BS.XMLResponse.processErrors(transport.responseXML, { 11 | onProfilerProblemError: function (elem) { 12 | alert(elem.firstChild.nodeValue); 13 | } 14 | }); 15 | } 16 | $j('.successMessage').remove(); 17 | $(messageComponentName).refresh(); 18 | if (transport.status == 500) { 19 | $(buttonName).disabled = ''; 20 | BS.Util.hide($('saving')); 21 | if (failure && typeof failure == 'function') { 22 | failure(event); 23 | } 24 | } else { 25 | if (success && typeof success == 'function') { 26 | success(event); 27 | } else { 28 | $(componentName).refresh(); 29 | } 30 | } 31 | } 32 | } 33 | ); 34 | return false; 35 | } 36 | }, 37 | getParams: function (list) { 38 | var names = list.split(","); 39 | var params = {}; 40 | for (var i = 0; i < names.length; i++) { 41 | var name = names[i].trim(); 42 | if (name.substr(-2) == "[]") { 43 | name = name.substr(0, name.length - 2); 44 | params[name] = $j("[name='" + name + "']").map(function (i, el) { 45 | return el.value 46 | }).toArray(); 47 | } else { 48 | if ($(name)) { 49 | params[name] = $(name).value; 50 | } 51 | } 52 | } 53 | return params; 54 | } 55 | }; 56 | ServerConfigurations.saveTemplate = ServerConfigurations.getFunction( 57 | 'templateSaveButton', 58 | 'templateForm', 59 | 'name,initialName,key[],type[]', 60 | 'templateMessageComponent', 61 | 'templateComponent' 62 | ); 63 | ServerConfigurations.saveServerConfiguration = ServerConfigurations.getFunction( 64 | 'serverConfigurationSaveButton', 65 | 'serverConfigurationForm', 66 | 'initialName,name,templateName,key[],value[],changed[]', 67 | 'serverConfigurationMessageComponent', 68 | 'serverConfigurationComponent' 69 | ); 70 | ServerConfigurations.saveProjectServerConfiguration = ServerConfigurations.getFunction( 71 | 'serverConfigurationSaveButton', 72 | 'serverConfigurationForm', 73 | 'initialPrefix,initialBranchFilter,prefix,name,branchFilter', 74 | 'serverConfigurationMessageComponent', 75 | 'serverConfigurationComponent' 76 | ); 77 | ServerConfigurations.changeConfigurationParameter = function(event) { 78 | $j('.successMessage').remove(); 79 | $j(event.target).closest('tr').find('[name=changed]').val('true'); 80 | return false; 81 | }; 82 | ServerConfigurations.deleteTemplateParameter = function(event) { 83 | $j(event.target).closest('tr').remove(); 84 | return false; 85 | }; 86 | ServerConfigurations.addTemplateParameter = function(event) { 87 | $j('').append( 88 | $j(''), 89 | $j('').append($j('#typesSelect').clone().removeAttr('id').attr('name', 'type').show()), 90 | $j('Delete') 91 | ).insertBefore($j(event.target).closest('tr')); 92 | return false; 93 | }; -------------------------------------------------------------------------------- /server/src/ServerConfigurations/server/ProjectConfiguration/ProjectConfigurations.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ServerConfigurations.server.ProjectConfiguration; 18 | 19 | import ServerConfigurations.common.Util; 20 | import org.jdom.Element; 21 | 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | import java.util.Map; 25 | 26 | /** 27 | * Created by IIIEII on 30.05.15. 28 | */ 29 | public class ProjectConfigurations implements jetbrains.buildServer.serverSide.settings.ProjectSettings { 30 | 31 | private List configurations = new ArrayList(); 32 | 33 | public void dispose() { 34 | 35 | } 36 | public void readFrom(Element rootElement) { 37 | this.getConfigurations().clear(); 38 | List configurationsElm = rootElement.getChildren(Controller.PROJECT_CONFIGURATION_TAG); 39 | for (Element configurationElm : configurationsElm) { 40 | ProjectConfiguration configuration = new ProjectConfiguration(); 41 | configuration.setName(configurationElm.getAttributeValue(Controller.PROJECT_CONFIGURATION_NAME_TAG, "")); 42 | configuration.setPrefix(configurationElm.getAttributeValue(Controller.PROJECT_CONFIGURATION_PREFIX_TAG, "")); 43 | configuration.setBranchFilter(configurationElm.getAttributeValue(Controller.PROJECT_CONFIGURATION_BRANCHFILTER_TAG, "")); 44 | this.getConfigurations().add(configuration); 45 | } 46 | } 47 | public void writeTo(Element parentElement) { 48 | parentElement.removeChildren(Util.PLUGIN_NAME); 49 | for (ProjectConfiguration configuration : this.getConfigurations()) { 50 | Element configurationElm = new Element(Controller.PROJECT_CONFIGURATION_TAG); 51 | configurationElm.setAttribute(Controller.PROJECT_CONFIGURATION_NAME_TAG, String.valueOf(configuration.getName())); 52 | configurationElm.setAttribute(Controller.PROJECT_CONFIGURATION_PREFIX_TAG, String.valueOf(configuration.getPrefix())); 53 | configurationElm.setAttribute(Controller.PROJECT_CONFIGURATION_BRANCHFILTER_TAG, String.valueOf(configuration.getBranchFilter())); 54 | parentElement.addContent(configurationElm); 55 | } 56 | } 57 | 58 | public List getConfigurations() { 59 | if (this.configurations == null) 60 | this.configurations = new ArrayList(); 61 | return this.configurations; 62 | } 63 | public List getConfigurationsList() { 64 | List configurationsList = new ArrayList(); 65 | for (ProjectConfiguration configuration : this.getConfigurations()) { 66 | configurationsList.add(configuration.getConfigurationMap()); 67 | } 68 | return configurationsList; 69 | } 70 | public ProjectConfiguration getConfigurationByPrefixBranchFilter(String configurationPrefix, String branchFilter) { 71 | for (ProjectConfiguration configuration : this.getConfigurations()) { 72 | if (configuration.getPrefix().contentEquals(configurationPrefix) && configuration.getBranchFilter().contentEquals(branchFilter)) { 73 | return configuration; 74 | } 75 | } 76 | return null; 77 | } 78 | public ProjectConfiguration getConfigurationByName(String configurationName) { 79 | for (ProjectConfiguration configuration : this.getConfigurations()) { 80 | if (configuration.getName().contentEquals(configurationName)) { 81 | return configuration; 82 | } 83 | } 84 | return null; 85 | } 86 | public ProjectConfiguration newConfiguration() { 87 | ProjectConfiguration configuration = new ProjectConfiguration(); 88 | this.getConfigurations().add(configuration); 89 | return configuration; 90 | } 91 | public void deleteConfiguration(ProjectConfiguration configuration) { 92 | this.getConfigurations().remove(configuration); 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /server/resources/buildServerResources/EditProjectConfigurationEditPage.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="/include.jsp"%> 2 | 3 | 4 | 5 | 6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 25 | 26 | 27 | 28 | 32 | 33 | 34 | 35 | 44 | 45 | 46 |
22 | 23 |
All server configuration parameters names will be prefixed with this string (e.g. %{some_prefix}.domain.name%).
24 |
29 | 30 |
Apply server configuration parameters only for build configurations in this branches.
31 |
36 | 37 | -- Select server configuration -- 38 | 39 | 40 | 41 | 42 |
Choose server configuration. All parameters will be available in build configurations.
43 |
47 |
48 | 49 | 50 | 51 | return ServerConfigurations.saveProjectServerConfiguration(event, function success() { 52 | BS.openUrl(event, '${pluginUrl}&action=edit&prefix=' + encodeURIComponent($('prefix').value)); 53 | }); 54 | 55 | 56 | return ServerConfigurations.saveProjectServerConfiguration(event); 57 | 58 | 59 | 60 | 63 | 65 | 66 | 67 | 68 |
69 |
70 | 71 |
72 | 73 |
-------------------------------------------------------------------------------- /server/src/ServerConfigurations/server/ParametersPreprocessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ServerConfigurations.server; 18 | 19 | import jetbrains.buildServer.UserDataStorage; 20 | import jetbrains.buildServer.serverSide.*; 21 | import jetbrains.buildServer.serverSide.parameters.AbstractBuildParametersProvider; 22 | import jetbrains.buildServer.serverSide.parameters.ParameterFactory; 23 | import org.jetbrains.annotations.NotNull; 24 | 25 | import java.util.*; 26 | 27 | /** 28 | * Created by IIIEII on 12.01.15. 29 | */ 30 | public class ParametersPreprocessor extends AbstractBuildParametersProvider implements jetbrains.buildServer.serverSide.ParametersPreprocessor { 31 | 32 | private final SBuildServer myServer; 33 | private final ParameterFactory myParameterFactory; 34 | private final ServerUtil myUtil; 35 | 36 | public ParametersPreprocessor(@NotNull SBuildServer server, @NotNull ParameterFactory parameterFactory, @NotNull ServerUtil util) { 37 | myServer = server; 38 | myParameterFactory = parameterFactory; 39 | myUtil = util; 40 | } 41 | 42 | public void fixRunBuildParameters(@NotNull final SRunningBuild build, 43 | @NotNull final Map runParameters, 44 | @NotNull final Map buildParams) { 45 | 46 | // String projectId = build.getValueResolver().resolve("%system.server.configuration.projectId%").getResult(); 47 | // String serverName = build.getValueResolver().resolve("%system.server.configuration.name%").getResult(); 48 | // 49 | // if (projectId != null && serverName != null && 1 == 0) { 50 | // // Получаем проект с конфигурациями серверов 51 | // SProject project = myServer.getProjectManager().findProjectByExternalId(projectId); 52 | // 53 | // if (project != null) { 54 | // // Получаем билд с конфигурацией нужного сервера 55 | // SBuildType configurationBuildType = project.findBuildTypeByName(serverName); 56 | // if (configurationBuildType != null) { 57 | // 58 | // // Собираем набор значений паролей для скрывания из лога 59 | // Set storedPasswords = new HashSet(); 60 | // final UserDataStorage storage = ((RunningBuildEx) build).getUserDataStorage(); 61 | // if (storage.getValue(myUtil.currentBuildNumberKEY) == build.getBuildNumber()) { 62 | // // В рамках одного билда накапливаем значения 63 | // storedPasswords = storage.getValue(myUtil.passwordsKEY); 64 | // } else { 65 | // storage.setValue(myUtil.currentBuildNumberKEY, build.getBuildNumber()); 66 | // } 67 | // 68 | // Collection params = configurationBuildType.getOwnParametersCollection(); 69 | // Map paramsData = myParameterFactory.extractBuildParameters(params); 70 | // /*int i = 0; 71 | // for (String key : paramsData.keySet()) { 72 | // buildParams.put(key, paramsData.get(key)); 73 | // if (((Parameter) (params.toArray()[i++])).getControlDescription().getParameterType().equals("password")) { 74 | // storedPasswords.add(paramsData.get(key)); 75 | // } 76 | // }*/ 77 | // storage.setValue(myUtil.passwordsKEY, storedPasswords); 78 | // Iterator paramIter = params.iterator(); 79 | // while(paramIter.hasNext()) { 80 | // Parameter param = (Parameter)paramIter.next(); 81 | // buildParams.put(param.getName(), paramsData.get(param.getName())); 82 | // ControlDescription controlDescription = param.getControlDescription(); 83 | // if (controlDescription != null && controlDescription.getParameterType().equals("password")) { 84 | // storedPasswords.add(paramsData.get(param.getName())); 85 | // } 86 | // } 87 | // } 88 | // } 89 | // } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /server/resources/buildServerResources/AdminConfigurationsListPage.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="/include.jsp" %> 2 | 3 | 4 | 5 | 6 |
7 | 8 | 9 | 10 |

Server Configurations

11 | 12 | 15 |
16 | 17 | 18 | There are no server configurations. 19 | 20 | 21 | 22 | 23 | Configuration Name 24 | Template 25 | 26 | 27 | ${pluginUrl}&action=edit&name= 28 | ?action=delete&name= 29 | BS.openUrl(event, '${confEditUrl}'); return false; 30 | 31 | 32 | 33 | 34 | Edit 35 | 36 | 37 | Delete 38 | 39 | 40 | 41 | 42 | 43 | 44 |
45 | 46 |

Templates

47 | 48 | 51 |
52 | 53 | 54 | There are no server configuration templates. 55 | 56 | 57 | 58 | 59 | Template Name 60 | Properties Count 61 | 62 | 63 | ${pluginUrl}&action=editTemplate&name= 64 | ?action=deleteTemplate&name= 65 | BS.openUrl(event, '${templEditUrl}'); return false; 66 | 67 | 68 | 69 | 70 | Edit 71 | 72 | 73 | Delete 74 | 75 | 76 | 77 | 78 | 79 | 80 |
81 | 82 |
-------------------------------------------------------------------------------- /server/src/ServerConfigurations/server/AdminConfiguration/ServerConfigurations.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ServerConfigurations.server.AdminConfiguration; 18 | 19 | import com.thoughtworks.xstream.annotations.XStreamAlias; 20 | import com.thoughtworks.xstream.annotations.XStreamImplicit; 21 | 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | import java.util.Map; 25 | 26 | /** 27 | * Created by IIIEII on 27.05.15. 28 | */ 29 | @XStreamAlias(Controller.CONFIGURATIONS_TAG) 30 | public class ServerConfigurations { 31 | 32 | @XStreamImplicit 33 | private List configurations = new ArrayList(); 34 | 35 | @XStreamImplicit 36 | private List