更改时间戳变量格式或进行替换
我目前正在努力设置 ci/cd 管道来推送 nuget 包。
我想使用内置的 CI_COMMIT_TIMESTAMP 作为版本后缀,但其 ISO 8601 格式对此无效。
示例 ISO 8601 (UTC):2022-03-15T18:34:43Z
至少需要替换冒号。
是否可以对其进行不同的格式或进行某种文本替换?
I am currently working on setting up ci/cd pipeline for pushing nuget packages.
I want to use the built-in CI_COMMIT_TIMESTAMP for version suffix however its ISO 8601 format is not valid for this.
Example ISO 8601 (UTC): 2022-03-15T18:34:43Z
Will need to at least replace colon.
Is it possible to format it differently or do some sort of text replacement?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法更改变量的呈现方式,但可以在作业中重新格式化该值。
unix
date
命令可以做到这一点。例如,您可以将任何有效格式声明为所需的输出格式。这将产生如下输出:
另一种方法是使用
sed
将出现的:
替换为-
。You can't change how the variable is presented, but you can reformat the value in your job.
The unix
date
command can do this. For example, you can declare any valid format as the desired output format.This will have an output like:
An alternative may be to use
sed
to replace the occurrences of:
with-
.