--------------------------------------------------------------------------------
/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 | 
19 |
20 | Configure some server configurations
21 | --------------------------------------------------
22 | 
23 |
24 | Attach server configuration to project
25 | -------------------------------------------------
26 | 
27 | 
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 | 
--------------------------------------------------------------------------------
/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%).