Azure Release Notes Wiki Markdown date - azure-devops

I am completely new to this so any help and explanation would be appreciated.
I have a created a template that will generate my release notes in our wiki. I am using the Generate Release Notes Markdown (crossplatform) extension by Richard Fennell.
In the template section of the extension, I use this short and simple template:
# {{releaseDetails.name}}
**Date** : {{releaseDetails.modifiedOn}}
**Build Number**: {{buildDetails.buildNumber}}
{{#forEach workItems}}
{{#if isFirst}}## Work Items{{/if}}
- **{{lookup this.fields 'System.WorkItemType'}}** #{{this.id}}
{{/forEach}}
The output is as follows:
Release-17
Date : Mon Dec 05 2022 18:19:37 GMT+0000 (Coordinated Universal Time)
Build Number: 20221026.4
Everything is good except I would like to change the date and time format to just show Mon 12/05/2022 12:19 PM. That's it. I don't want the military time or the GMT +0000 stuff in there.
EX:
Release-17
Date : Mon 12/05/2022 12:19:37 PM
Build Number: 20221026.4
Does anyone know how to format the date properly? Any help is appreciated.
Thanks!
Searched forums and have not been able to find any solutions.

To modify the time zone and date format in Generate Release Notes Markdown, you need to add custom Javascript extenstion module in the Generate Release Notes Markdown task -> Custom Handlebars Extension.
Here is an example:
Javascript module
module.exports = {date_formatter(theDate) {
return theDate.toLocaleString("location");
}};
Task sample:
- task: XplatGenerateReleaseNotes#3
displayName: 'Generate Release Notes based on Release Comparison API'
inputs:
outputfile: '$(System.DefaultWorkingDirectory)/releasenotes.md'
templateLocation: InLine
inlinetemplate: |
# {{releaseDetails.name}}
**Date** : {{date_formatter releaseDetails.modifiedOn }}
**Build Number**: {{buildDetails.buildNumber}}
{{#forEach workItems}}
{{#if isFirst}}## Work Items{{/if}}
- **{{lookup this.fields 'System.WorkItemType'}}** #{{this.id}}
{{/forEach}}
replaceFile: true
customHandlebarsExtensionCode: |
module.exports = {date_formatter(theDate) {
return theDate.toLocaleString("location");
}};
Refer to this sample: date_formatter.js and Handlebar Extensions

Related

Mercurial: How can I change default tag message template?

I would like to use some prefix labels in commit messages to quickly identify the kind of commit when viewing the revision log, and for ability to quickly filter down the log.
Some of the prefixes I intend to use are (TAG:, MERGE:, TEST:, STABLE:, TRUE-UP:, FIX():, FEATURE():, & possibly others).
Additionally, for tags I would like to change the default message to be a little more descriptive, like so:
TAG: Added tag v3.4 for e90d0caa766 created on 2022-09-22 01:05:00
Applied fix for foobar.
For tagging, Mercurial seems to not open the editor so I can examine the tag message, so my attempts to debug this have been tedious.
I've tried adding the following to my repo hgrc config file:
[committemplate]
changeset.tag = "TAG: Added tag {tag} for {node|short} created on {date|isodate}\n{desc}"
I've also played around with the [hooks] section and pretag hook.
Additionally, I've tried on the command line with various formatting adjustments:
hg tag -r . -m 'TAG: Added tag {tag} for {node|short} created on {date|isodate}\n{desc}' test4
For the command line attempt above none of this populates the template fields in the message, and for the other attempts in the hgrc config file, this has not altered the commit message not once or even errored.
What am I missing here?
[committemplate] work, if it was added to hgrc (tried at repo-level, not globally), but somehow not in expected form (see below)
Just note: if you'll use "Added tag" wording, you, maybe want to limit area of modified message to only adding tags (hg tag can remove tags also, BTW) with changeset.tag.add
My test-case
Hg 6.2.2
No redefined committemplate in global config
Dumb oneliner for changeset.tag and later for changeset.tag.add
Tagging pure in CLI (due to total fails in THG)
Some logs
Plain hg tag -r 0 0.1 + hg tag --remove 0.1 used with changeset.tag redefined (default messages used by hg)
changeset: 2:006c40256d9b
user: lazybadger
date: Thu Sep 22 17:05:15 2022 +0500
summary: Removed tag 0.1
changeset: 1:1927f74a0ec0
user: lazybadger
date: Thu Sep 22 17:02:46 2022 +0500
summary: Added tag 0.1 for changeset 8385f66bee57
Tagging with -e additional option (BEWARE: tag inserted in editor by hand, {tag} nor {tags} are not expanded in changeset.tag.* text)
changeset: 7:5aee36e13e4d
tag: lazybadger
date: Thu Sep 22 17:13:43 2022 +0500
summary: TAGGING: Tag 0.3 added
...
changeset: 3:9a4b0a117fb1
user: lazybadger
date: Thu Sep 22 17:06:23 2022 +0500
summary: TAG: Tag 0.1 touched

Is there a way to set a date and time (timezone) in Azure DevOps CI/CD build pipeline

I have automated test running in my CI/CD build pipeline, but the time in DevOps is UTC and my assertions tests check the local time.
Is there a way to set a time zone in my build pipeline?
Yes. For example this simple BASH script run using a Microsoft Hosted Agent:
echo "checking date"
date
echo "setting date to Asia/Kolkata"
sudo timedatectl set-timezone "Asia/Kolkata"
date
The results as seen in the log:
2019-07-05T20:26:48.5992486Z checking date
2019-07-05T20:26:48.5992954Z Fri Jul 5 20:26:48 UTC 2019
2019-07-05T20:26:48.5993264Z setting date to Asia/Kolkata
2019-07-05T20:26:48.9107025Z Sat Jul 6 01:56:48 IST 2019
As you can see, you can manipulate the local time on the agent. I do not agree with the other poster that this is necessarily a bad thing to do in the context of running tests.
You put some extra code in your tests to account for the local / target time or you could add 1 line into your build agent and achieve the same thing.
It just depends, the devil is in the details. Be careful with how you handle time.
using Powershell, you can do:
Get-TimeZone
Set-TimeZone "India Standard Time"
Get-TimeZone
Asia/Kolkata and "sudo timedatectl set-timezone" is not working on mac OS vmimage. Use below task for mac.
- task: CmdLine#2
displayName: Set system Timezone to IST
inputs:
script: |
sudo systemsetup -gettimezone
sudo systemsetup -settimezone Asia/Calcutta
sudo systemsetup -gettimezone
Also you can use this command to get the list of all valid timezones
sudo systemsetup -listtimezones
Additional to other replies for Windows Powershell and Linux Bash,
Mac OSX agent such xcode or Xamarin.iOS should use the script below to set timezone:
- task: Bash#3
displayName: Set Mac OS X Timezone
inputs:
targetType: 'inline'
script: sudo systemsetup -settimezone Asia/Shanghai
If ubuntu agent is used, the following commands can be used.
List timezones: timedatectl list-timezones
Set timezone: sudo timedatectl set-timezone '<your timezone>'

Ansible: compare difference between two dates for the last hour

there is a way to compare between the current time using ansible_date_time
with another date (aws ec2 launch time) So I will be able to know if it happened in the last hour?
I have the following var ec2_launch_time: 2018-01-04T15:57:52+00:00
I know that I can compare days with the following method (from here and here):
"{{ (ansible_date_time.iso8601[:19] | to_datetime('%Y-%m-%dT%H:%M:%S') - ec2_launch_time[:19] | to_datetime('%Y-%m-%dT%H:%M:%S')).days }}"
if I will get 0 I will know that it happened on the same day but I'm looking for a way to get true or false if the difference between the dates are 1 hour (on the same day).
there is a filter for this or elegant way to write this or only using shell (like this)?
By subtracting two dates, you get a timedelta Python object.
You can use total_seconds method to get the exact difference in seconds. Add some basic arithmetic to get the number of full hours:
---
- hosts: localhost
gather_facts: no
connection: local
vars:
date_later: 2018-01-05 08:30:00
date_earlier: 2018-01-05 06:50:00
tasks:
- debug:
msg: "{{ ( (date_later - date_earlier).total_seconds() / 3600 ) | int }}"
returns:
ok: [localhost] => {
"msg": "1"
}
Use the above expression in the condition you want.

Protractor CSV file upload doesn't work

I have problem when trying to upload a csv of excel files via protractor. File is valid. When I upload it manually everything is fine. But for some reason, upload with protractor says that size is 0, and type is not recognized.
Screenshot of file details after upload
Upload code:
var fileToUpload = './test.csv';
var absolutePath = path.resolve(__dirname, fileToUpload);
element(by.css("input[type=\"file\"]")).sendKeys(absolutePath);
Also I have tried with absolute path, without path.resolve, and also I have tried with xlsx file. Problem remains the same.
I believe I've found the cause. From my tests it seems like the File type is missing, see below:
For a .csv file:
File
lastModified: 1468589472000
lastModifiedDate: Fri Jul 15 2016 14:31:12 GMT+0100 (BST)
name: "valid-import.csv"
size: 198
type: ""
webkitRelativePath: ""
For a .svg file:
File
lastModified: 1468587182000
lastModifiedDate: Fri Jul 15 2016 13:53:02 GMT+0100 (BST)
name: "valid-import.svg"
size: 1030
type: "image/svg+xml"
webkitRelativePath: ""
Note the missing type attribute — I'm trying to dig further into this, if I find anything I'll update this answer.

Setting Date format for autoprop 'DATE' in SVN

I have some files that use the autoproperty $Date of SVN.
When some colleagues in France do a checkout of the repository, the date is in French. When they do the verification of checksum, these files are KO because of this difference of format for the date.
Note: we are using Windows and our client of choice is TortoiseSVN but are open to use command line clients.
Question 1: Is there any way to force the format for the date during the checkout?
We tried the following:
Setting "English" in Tortoise SVN
Setting environment variable LANG to EN_US and doing a checkout with both TortoiseSVN and svn commandline
None of these solutions is working.
Question 2: Would the time zone impact the date in the header as well?
Thanks
NB: This is the header of our source code, for what it matters.
/*==============================================================================================
* FILENAME : Source.h
* VERSION : $Revision: 85911 $
* MODIFICATION DATE : $Date: 2015-06-12 18:26:22 +0800 (Fri, 12 Jun 2015) $
*============================================================================================*/
A1: I don't know, how to manipulate locale-setting in Windows in easy and automated style - inspired by this old answer in Subversion maillist - (better to ask it SU) and can suggest now only dirty hack: import reg-files for FR and EN locales before and after checkout (how to prepare: switch to FR in Control Panel, save Current Control Set part of registry, return to EN, save CCS again, leave in .reg only mutable part), checkout in bat-file only (change locale around checkout)
A2: Sad, but yes
$Date: 2015-06-19 19:45:22 +0500 (Пт, 19 июн 2015) $
inserts not only language-specific date (trailing part), but also TZ of client
1.8.*-specific solution: you can create and use replacement for $Date keyword, which use UTC-time instead of local (as $Id do for time-part now) with %d variable it it
>svn pl -v file.txt
Properties on 'file.txt':
svn:keywords
Author Date Id Revision URL Header IntDate=%d
and IntDate will expand location-independent
$IntDate: 2015-06-19 14:45:22Z $