Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion api/restHandler/GlobalPluginRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (handler *GlobalPluginRestHandlerImpl) GetAllGlobalVariables(w http.Respons
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
return
}
globalVariables, err := handler.globalPluginService.GetAllGlobalVariables()
globalVariables, err := handler.globalPluginService.GetAllGlobalVariables(app.AppType)
if err != nil {
handler.logger.Errorw("error in getting global variable list", "err", err)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand Down
2 changes: 1 addition & 1 deletion pkg/pipeline/CiService.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ func (impl *CiServiceImpl) buildWfRequestForCiPipeline(pipeline *pipelineConfig.
PreCiSteps: preCiSteps,
PostCiSteps: postCiSteps,
RefPlugins: refPluginsData,
AppName: pipeline.App.AppName,
AppName: pipeline.App.DisplayName,
TriggerByAuthor: userEmailId,
CiBuildConfig: ciBuildConfigBean,
CiBuildDockerMtuValue: impl.config.CiRunnerDockerMTUValue,
Expand Down
26 changes: 18 additions & 8 deletions pkg/plugin/GlobalPluginService.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package plugin
import (
"errors"
"fmt"
"github.com/devtron-labs/devtron/internal/sql/repository/helper"
repository2 "github.com/devtron-labs/devtron/pkg/pipeline/repository"
"github.com/devtron-labs/devtron/pkg/plugin/repository"
"github.com/devtron-labs/devtron/pkg/sql"
Expand Down Expand Up @@ -37,7 +38,7 @@ const (
)

type GlobalPluginService interface {
GetAllGlobalVariables() ([]*GlobalVariable, error)
GetAllGlobalVariables(appType helper.AppType) ([]*GlobalVariable, error)
ListAllPlugins(stageTypeReq string) ([]*PluginListComponentDto, error)
GetPluginDetailById(pluginId int) (*PluginDetailDto, error)
GetRefPluginIdByRefPluginName(pluginName string) (refPluginId int, err error)
Expand All @@ -61,7 +62,7 @@ type GlobalPluginServiceImpl struct {
pipelineStageRepository repository2.PipelineStageRepository
}

func (impl *GlobalPluginServiceImpl) GetAllGlobalVariables() ([]*GlobalVariable, error) {
func (impl *GlobalPluginServiceImpl) GetAllGlobalVariables(appType helper.AppType) ([]*GlobalVariable, error) {
globalVariables := []*GlobalVariable{
{
Name: "WORKING_DIRECTORY",
Expand Down Expand Up @@ -93,12 +94,6 @@ func (impl *GlobalPluginServiceImpl) GetAllGlobalVariables() ([]*GlobalVariable,
Description: "Complete image name(repository+registry+tag).",
Type: "ci",
},
{
Name: "APP_NAME",
Format: string(repository.PLUGIN_VARIABLE_FORMAT_TYPE_STRING),
Description: "Name of the app this pipeline resides in.",
Type: "ci",
},
{
Name: "TRIGGER_BY_AUTHOR",
Format: string(repository.PLUGIN_VARIABLE_FORMAT_TYPE_STRING),
Expand Down Expand Up @@ -172,6 +167,21 @@ func (impl *GlobalPluginServiceImpl) GetAllGlobalVariables() ([]*GlobalVariable,
Type: "cd",
},
}
globalVariable := &GlobalVariable{
Name: "APP_NAME",
Format: string(repository.PLUGIN_VARIABLE_FORMAT_TYPE_STRING),
Description: "Name of the app this pipeline resides in.",
Type: "ci",
}
if appType == helper.Job {
globalVariable = &GlobalVariable{
Name: "JOB_NAME",
Format: string(repository.PLUGIN_VARIABLE_FORMAT_TYPE_STRING),
Description: "Name of the Job this pipeline resides in.",
Type: "ci",
}
}
globalVariables = append(globalVariables, globalVariable)
return globalVariables, nil
}

Expand Down