Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/server/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ func setupEvilGlobals(ctx context.Context, c *cli.Command, s store.Store) (err e
server.Config.Pipeline.Proxy.HTTP = c.String("backend-http-proxy")
server.Config.Pipeline.Proxy.HTTPS = c.String("backend-https-proxy")

// pipeline config paths
server.Config.Pipeline.ConfigPaths = c.StringSlice("default-pipeline-configs")
server.Config.Pipeline.ConfigExtensions = c.StringSlice("default-pipeline-config-extensions")

// server configuration
server.Config.Server.JWTSecret, err = setupJWTSecret(s)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ var Config = struct {
HTTP string
HTTPS string
}
ConfigPaths []string
ConfigExtensions []string
// TODO: remove with version 4.x
ForceIgnoreServiceFailure bool
}
Expand Down
21 changes: 21 additions & 0 deletions server/web/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ package web

import (
"encoding/json"
"fmt"
"net/http"
"strconv"
"strings"
"text/template"

"github.com/gin-gonic/gin"
Expand All @@ -39,6 +41,23 @@ func Config(c *gin.Context) {
csrf, _ = t.Sign(user.Hash)
}

var configPaths []string

extensionsClean := make([]string, len(server.Config.Pipeline.ConfigExtensions))
for i, e := range server.Config.Pipeline.ConfigExtensions {
extensionsClean[i] = strings.TrimPrefix(e, ".")
}

extensions := strings.Join(extensionsClean, ",")
for _, p := range server.Config.Pipeline.ConfigPaths {
if strings.HasSuffix(p, "/") {
// it's a directory -> add extensions
configPaths = append(configPaths, fmt.Sprintf("%s*.{%s}", p, extensions))
} else {
configPaths = append(configPaths, p)
}
}

configData := map[string]any{
"user": user,
"csrf": csrf,
Expand All @@ -48,6 +67,7 @@ func Config(c *gin.Context) {
"enable_swagger": server.Config.WebUI.EnableSwagger,
"user_registered_agents": !server.Config.Agent.DisableUserRegisteredAgentRegistration,
"max_pipeline_log_line_count": server.Config.WebUI.MaxPipelineLogLineCount,
"default_config_paths": configPaths,
}

// default func map with json parser.
Expand Down Expand Up @@ -83,4 +103,5 @@ window.WOODPECKER_ENABLE_SWAGGER = {{ .enable_swagger }};
window.WOODPECKER_SKIP_VERSION_CHECK = {{ .skip_version_check }}
window.WOODPECKER_USER_REGISTERED_AGENTS = {{ .user_registered_agents }}
window.WOODPECKER_MAX_PIPELINE_LOG_LINE_COUNT = {{ .max_pipeline_log_line_count }}
window.WOODPECKER_DEFAULT_CONFIG_PATHS = {{ json .default_config_paths }}
`
2 changes: 1 addition & 1 deletion web/src/assets/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"success": "Project settings updated",
"pipeline_path": {
"path": "Pipeline path",
"default": "By default: .woodpecker/*.{'{yaml,yml}'} -> .woodpecker.yaml -> .woodpecker.yml",
"by_default": "By default: {paths}",
"desc": "Path to your pipeline config (for example {0}). Folders should end with a {1}.",
"desc_path_example": "my/path/"
},
Expand Down
2 changes: 2 additions & 0 deletions web/src/compositions/useConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ declare global {
WOODPECKER_ENABLE_SWAGGER: boolean | undefined;
WOODPECKER_USER_REGISTERED_AGENTS: boolean | undefined;
WOODPECKER_MAX_PIPELINE_LOG_LINE_COUNT: number | undefined;
WOODPECKER_DEFAULT_CONFIG_PATHS: string[] | undefined;
}
}

Expand All @@ -22,4 +23,5 @@ export default () => ({
enableSwagger: window.WOODPECKER_ENABLE_SWAGGER === true || false,
userRegisteredAgents: window.WOODPECKER_USER_REGISTERED_AGENTS || false,
maxPipelineLogLineCount: window.WOODPECKER_MAX_PIPELINE_LOG_LINE_COUNT ?? 5000,
defaultConfigPaths: window.WOODPECKER_DEFAULT_CONFIG_PATHS || [],
});
6 changes: 5 additions & 1 deletion web/src/views/repo/settings/General.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@
<TextField
:id="id"
v-model="repoSettings.config_file"
:placeholder="$t('repo.settings.general.pipeline_path.default')"
:placeholder="
$t('repo.settings.general.pipeline_path.by_default', { paths: defaultConfigPaths.join(' ➔ ') })
"
/>
</template>

Expand Down Expand Up @@ -196,6 +198,7 @@ import Settings from '~/components/layout/Settings.vue';
import useApiClient from '~/compositions/useApiClient';
import { useAsyncAction } from '~/compositions/useAsyncAction';
import useAuthentication from '~/compositions/useAuthentication';
import useConfig from '~/compositions/useConfig';
import { requiredInject } from '~/compositions/useInjectProvide';
import useNotifications from '~/compositions/useNotifications';
import { useWPTitle } from '~/compositions/useWPTitle';
Expand All @@ -208,6 +211,7 @@ const notifications = useNotifications();
const { user } = useAuthentication();
const repoStore = useRepoStore();
const i18n = useI18n();
const { defaultConfigPaths } = useConfig();

const repo = requiredInject('repo');
const repoSettings = ref<RepoSettings>();
Expand Down