Setting up Default Description Template on P4 Client - perforce

While creating new changelist is there a way that I can create default description template. So whenever I will create new changelist I want some of the details to be pre-populated on my p4 client.
Below is an example to prepopulated template that I would like to have:
Summary:
Fix:
Impact:
Testing:
Unit Testing:
Documentation:
QA:
Localization:
Jira-Id:

To do this for all users on the server, set up a form-out trigger on the change form and replace the default template with your own template. The simplest possible version of this is a sed one-liner:
Triggers:
form-out change "sed -i s/<.*>/fnord/ %formfile%"
You can replace this with something arbitrarily complex (maybe you want to modify the template per user, etc.)
If you want to just do it for yourself on your own client machine, do it in your editor (e.g. have a macro that replaces <enter description here> with your template). If you can't do it in your editor, you can do it outside your editor by wrapping it in a script that does something like:
sed -i s/<.*>/fnord/ $1
vi $1
and then do:
p4 set P4EDITOR=my-wrapper.sh

Related

How can I share a workspace definition between multiple hosts?

I have created a Perforce workspace definition with which I will be able to "run the latest demo" on a PC.
Then I wanted to try and check out the same workspace on another PC in order to run the same demo. I found that I could not do this because the workspace is somehow tied to the first PC where I created it.
I ended up copying the workspace by
inspecting the textual definition of the workspace and copying it to a text editor,
searching and replacing "WantedWorkspaceName" with "WantedWorkspaceName_NewHostname",
creating a new workspace with a new name ("WantedWorkspaceName_NewHostname"),
giving the new workspace the same workspace root path ("D:\Demo") as the original workspace,
pasting the modified textual representation into the textual representation of the new workspace.
Surely there must be a better way to achieve what I want? (Use the same workspace mapping on different hosts.)
Just use the -t template option to p4 client:
p4 client -t WantedWorkspaceName WantedWorkspaceName_NewHostname
You may also want to look at streams, which are an alternative way of setting up client/branch mappings. Rather than configuring each client individually, you define a single "stream" which encapsulates a set of depot mappings and branching relationships to other streams. Then a client can be defined simply in terms of what stream it's associated with, and the views are auto-generated whenever the stream is changed.

Asciidoc inserting Gitlab builder variables when creating the adoc file?

Good day all, been reading the various docs at Gitlab and Asciidoc websites and I'm not seeing if there's a way to autofill a variable created in Gitlab that is included in the asciidoc it creates? For example, if I'm pushing code to my branch and it starts the Gitlab builder. I would like to take the author variable with my name in it and when the asciidoc that the builder generates, can I just put {author} for it to auto-fill my name in it?
Not 100% sure I'm understanding how this works exactly, any help would be greatly appreciated.
Thanks
If your Gitlab builder explicitly calls asciidoctor, you can define attributes using the -a flag. For example:
asciidoctor -a author="My Name" contents.adoc
Environment variables can be added in the same way:
asciidoctor -a author="My Name" -a path=$PATH contents.adoc
See the CLI Options page for other options that you can specify during asciidoctor invocation.
If the builder calls other actions that do the building, and you cannot access those actions, then this won't work.
Note that defining the page author is normally handled by including the name (and email address) immediately after the page title (before the first blank line). See the Using the Author Line page for details.
For example:
= Document
Author name
The standard Asciidoctor theme automatically displays the page author immediately after the page title.
For other attributes that are included in the document, or specified as page attributes, you'd need to include {attribute_name} within the page markup to see them.

How can I list the current user and workspace in perforce?

What is the equivalent to typing whoami (Linux) in Perforce? I would like to programatically find the currently logged in user.
Can I also get the name of the current workspace, somehow?
p4 info gets you everything.
p4 set P4USER gets you the name of the user you've currently set (without connecting to the server to get any information about it -- you may or may not be logged in, and the user may or may not exist).
p4 set P4CLIENT is the same for the client name (doesn't validate that the client exists or anything like that).
p4 login -s gives you the current authentication status of the current user.
p4 user -o and p4 client -o give you more information about the current user and client. You can use the -Ztag and -F global flags (see p4 help usage and p4 help undoc) to programmatically convert those forms into dictionaries and extract specific keys from them without needing to regex the text. The various scripting APIs have this functionality baked in as well.
Currently doing:
p4 info | grep 'User name'
p4 info | grep 'Client name'

Perforce - How to get Label details using Label name with wildcard

I am new to Perforce. I need a 'p4' client command to get Label(s) by providing Label name.
However I don't know complete Label name so I want to provide wildcard in the Label name.
In P4V client I do it this way:
If you look in P4V's log pane you can see what command(s) it's running to get its data. For labels it's probably running something like:
p4 labels -e "cobrands.razor*build_01"

How to create a job and attach it to a new changelist in perforce CLI?

using p4 change, I can create a new changelist but it requires a 'form' to be filled.
Is there a way for me to create a job with a particular template, get that job number and attach it to a new changelist with a particular template?
No, unfortunately you have to use the forms, i.e. temp files, or cmdline I/O redirection.
The alternative is to use a P4 API (e.g. P4Perl, P4Python, etc.) which gives you a way to specify all the change's details (the ones you would fill into the form) as structured data.

Resources