Пример #1
0
        /// <summary>
        /// Update artifact's absolute path to relative path to project-folder
        /// </summary>
        /// <param name="job"></param>
        /// <returns></returns>
        private static Job UpdateArtifactPath(Job job, string subFolderPath)
        {
            var argSets = job?.Arguments;

            if (argSets == null)
            {
                return(job);
            }

            //var checkedArtis = new List<JobPathArgument>();
            var newJob = job.DuplicateJob();

            newJob.Arguments.Clear();

            foreach (var argSet in argSets)
            {
                //add an empty argument set.
                newJob.AddArgumentSet();
                foreach (var item in argSet)
                {
                    if (item.Obj is JobPathArgument path)
                    {
                        // only update the path for ProjectFolderSource for a relative path
                        var projFolderSource = path.Source.Obj as ProjectFolder;
                        if (projFolderSource == null)
                        {
                            continue;
                        }

                        // update artifact arguments
                        var newFileOrDirname = Path.GetFileName(projFolderSource.Path);
                        if (!string.IsNullOrEmpty(subFolderPath))
                        {
                            newFileOrDirname = $"{subFolderPath}/{newFileOrDirname}";
                        }
                        var pSource = new ProjectFolder(path: newFileOrDirname);
                        var newPath = new JobPathArgument(path.Name, pSource);

                        // add it to the last available argument set.
                        newJob.AddArgument(newPath);
                    }
                    else if (item.Obj is JobArgument valueArg)
                    {
                        // add it to the last available argument set.
                        newJob.AddArgument(valueArg);
                    }
                }
            }

            return(newJob);
        }
Пример #2
0
 public void AddArgument(JobPathArgument arg) => this.Job.AddArgument(arg);