Resource Implementation Question

In my new resource I’m developing. It is based on a top level “ChangeRequest”.

My in/out/check work with the CR but I also want to create “ChangeRequest Tasks” which is a child of a CR.

So I implemented the “addTask” into the out CR resource. This will create a Task but then how in a job can I get this new Task number to be able to “update” the task later?

I didn’t want to create a full resource as it doesn’t really match as the check would in theory use the CR number to get the list of tasks in the CR but the CR does not exist so I can’t have a CR number in the “source” of the check.

I thought that “meta” information might work but I’m not sure the best way to implement this.

It works better as a couple of “tasks” (add CRTask and updateCRTask) . BUT when I want to create the task I want to insert the “$BUILD_JOB_NAME” into the details and that is NOT available in a task it’s only available in a resource which does not really work (as I mentioned above).

Basically the use case is I use the CR resource and have a task in a job to “createCRTask” then later in the job “updateCRTask” with the status. There is no need to make a full blown resource because it will never be passed between jobs.

Any help would be great.

Thanks,

Andrew

Hey Andrew!

I’m struggling to follow the use case pre-caffeine. You’re working on a ServiceNow resource, right?

I think the issue you face is that the only way a put has of sharing state is via a created version. If puts could leave outs for other steps to pick up, then you could write the TaskID out as a file (which generally speaking is the only way for steps to share state).

Given my superficial understanding, I think you have two options:

  • make a Task resource too
  • see if there’s a way to deterministically define the ID of the task before it is created, so you can write this as a file to share between steps before creating the ChangeRequest

I’m not sure I follow how build metadata will help you, but have you looked at https://github.com/mastertinner/build-metadata-resource and https://github.com/olhtbr/metadata-resource ?

Looks like you want to trigger a task in put and get the task info/result in the implied get, where “version” is the only way to pass something from put to the implied get. You may encode whatever info in a version string, as long as make sure the version string is unique, put outputs the version, then the implied get gets the version and decode info from version then proceed. Actually version can be a hash, you may also just use a hash as version rather than encode a version string.