Example #1
0
        /// <summary>
        /// Job request message sent to the runner
        /// </summary>
        /// <param name="environmentVariables">Hierarchy of environment variables to overlay, last wins.</param>
        public AgentJobRequestMessage(
            TaskOrchestrationPlanReference plan,
            TimelineReference timeline,
            Guid jobId,
            String jobDisplayName,
            String jobName,
            TemplateToken jobContainer,
            TemplateToken jobServiceContainers,
            IList <TemplateToken> environmentVariables,
            IDictionary <String, VariableValue> variables,
            IList <MaskHint> maskHints,
            JobResources jobResources,
            DictionaryContextData contextData,
            WorkspaceOptions workspaceOptions,
            IEnumerable <JobStep> steps,
            IList <String> fileTable,
            TemplateToken jobOutputs,
            IList <TemplateToken> defaults,
            ActionsEnvironmentReference actionsEnvironment)
        {
            this.MessageType          = JobRequestMessageTypes.PipelineAgentJobRequest;
            this.Plan                 = plan;
            this.JobId                = jobId;
            this.JobDisplayName       = jobDisplayName;
            this.JobName              = jobName;
            this.JobContainer         = jobContainer;
            this.JobServiceContainers = jobServiceContainers;
            this.Timeline             = timeline;
            this.Resources            = jobResources;
            this.Workspace            = workspaceOptions;
            this.JobOutputs           = jobOutputs;
            this.ActionsEnvironment   = actionsEnvironment;
            m_variables               = new Dictionary <String, VariableValue>(variables, StringComparer.OrdinalIgnoreCase);
            m_maskHints               = new List <MaskHint>(maskHints);
            m_steps = new List <JobStep>(steps);

            if (environmentVariables?.Count > 0)
            {
                m_environmentVariables = new List <TemplateToken>(environmentVariables);
            }

            if (defaults?.Count > 0)
            {
                m_defaults = new List <TemplateToken>(defaults);
            }

            this.ContextData = new Dictionary <String, PipelineContextData>(StringComparer.OrdinalIgnoreCase);
            if (contextData?.Count > 0)
            {
                foreach (var pair in contextData)
                {
                    this.ContextData[pair.Key] = pair.Value;
                }
            }

            if (fileTable?.Count > 0)
            {
                m_fileTable = new List <String>(fileTable);
            }
        }
Example #2
0
        private Pipelines.AgentJobRequestMessage CreateJobRequestMessage(string jobName)
        {
            TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference()
            {
                PlanId = Guid.NewGuid()
            };
            TimelineReference timeline = null;
            Dictionary <string, VariableValue> variables = new Dictionary <string, VariableValue>(StringComparer.OrdinalIgnoreCase);

            variables[Constants.Variables.System.Culture] = "en-US";
            Pipelines.JobResources resources = new Pipelines.JobResources();
            var serviceEndpoint = new ServiceEndpoint();

            serviceEndpoint.Authorization = new EndpointAuthorization();
            serviceEndpoint.Authorization.Parameters.Add("nullValue", null);
            resources.Endpoints.Add(serviceEndpoint);

            List <Pipelines.ActionStep> actions = new List <Pipelines.ActionStep>();

            actions.Add(new Pipelines.ActionStep()
            {
                Id        = Guid.NewGuid(),
                Reference = new Pipelines.RepositoryPathReference()
                {
                    RepositoryType = "GitHub",
                    Name           = "actions/test",
                    Ref            = "v1"
                }
            });
            Guid JobId             = Guid.NewGuid();
            var  sidecarContainers = new MappingToken(null, null, null)
            {
                {
                    new StringToken(null, null, null, "nginx"),
                    new MappingToken(null, null, null)
                    {
                        {
                            new StringToken(null, null, null, "image"),
                            new StringToken(null, null, null, "nginx")
                        },
                    }
                },
            };
            var context = new Pipelines.ContextData.DictionaryContextData
            {
                {
                    "github",
                    new Pipelines.ContextData.DictionaryContextData()
                },
            };
            var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, JobId, jobName, jobName, new StringToken(null, null, null, "ubuntu"), sidecarContainers, null, variables, new List <MaskHint>(), resources, context, null, actions, null, null, null);

            return(jobRequest);
        }