Create a new job in the repository.

Namespace: Perforce.P4
Assembly: p4api.net (in p4api.net.dll) Version: 2017.3.160.836 (2017.3.160.0836)

Syntax

C#
public Job CreateJob(
	Job job,
	Options options
)
Visual Basic
Public Function CreateJob ( _
	job As Job, _
	options As Options _
) As Job
Visual C++
public:
Job^ CreateJob(
	Job^ job, 
	Options^ options
)

Parameters

job
Type: Perforce.P4..::..Job
Job specification for the new job
options
Type: Perforce.P4..::..Options
The '-i' flags is needed when creating a new job

Return Value

The Job object if new job was created, null if creation failed

Remarks

The '-i' flags is added if not specified by the caller

p4 help job

job -- Create or edit a job (defect) specification

p4 job [-f] [jobName]
p4 job -d jobName
p4 job -o [jobName]
p4 job -i [-f]

The 'p4 job' command creates and edits job specifications using an
ASCII form. A job is a defect, enhancement, or other unit of
intended work.The 'p4 fix' command associates changelists with jobs.

With no arguments, 'p4 job' creates an empty job specification
and invokes the user's editor. When the specification is saved,
a job name of the form jobNNNNNN is assigned. If the jobName
parameter is specified on the command line, the job is created or
opened for editing.

As jobs are entered or updated, all fields are indexed for searching
Text fields are broken into individual alphanumeric words (punctuation
and whitespace are ignored) and each word is case-folded and entered
into the word index. Date fields are converted to an internal
representation (seconds since 1970/01/01 00:00:00) and entered
into the date index.

The fields that compose a job are defined by the 'p4 jobspec' command.
Perforce provides a default job specification that you can edit.

The -d flag deletes the specified job. You cannot delete a job if
it has pending or submitted fixes associated with it.

The -o flag writes the job specification to the standard output.
The user's editor is not invoked.

The -i flag reads a job specification from the standard input. The
user's editor is not invoked.

The -f flag enables you set fields that are read-only by default.
The -f flag requires 'admin' access, which is granted using the
'p4 protect' command.

Examples

To create a new job with a name 'Myjob':
CopyC#
Job job = new Job();
job.Id = "Myjob";
job.Add("Status", "open");
job.Add("User", "admin");
job.Add("Description", "this is a test job");
Job job = _repository.CreateJob( job, null);
To create a job with name of the form jobNNNNNN:
CopyC#
Job job = new Job();
job.Id = "new";
job.Add("Status", "open");
job.Add("User", "admin");
job.Add("Description", "this is a test job");
Job job = _repository.CreateJob( job, JobCmdFlags.Input);

See Also