简体   繁体   English

如何从jenkins作业在工作区中创建点文件

[英]How can I create a dot file in the workspace from the jenkins job

I have a jenkins job that amongst other things I want to dynamically create a .foo and a .bar file in my jenkins workspace home directory as the job is running. 我有一个jenkins作业,除其他外,我想在作业运行时在jenkins工作区主目录中动态创建.foo.bar文件。

How can I do that with bash as a part of the job? 如何将bash作为工作的一部分来做到这一点?

The job will run after a Docker container has been created with the Docker Plugin. 该作业将在使用Docker插件创建Docker容器后运行。

So the order of precedence I want is : 所以我想要的优先顺序是:

Job starts: 工作开始:

  1. docker container get's created 创建docker容器
  2. create .foo file (and enter foobarbaz as a content in the file) 创建.foo文件(并在文件中输入foobarbaz作为内容)
  3. create .bar file (and enter foobarbaz as a content in the file) 创建.bar文件(并在文件中输入foobarbaz作为内容)

How can I achieve this? 我该如何实现?

One simple solution would be to associate your Jenkins job with a source controlled repository URL, which already include the files with the right content. 一种简单的解决方案是将您的Jenkins作业与源代码控制的存储库URL相关联,该URL已包含具有正确内容的文件。

Each job execution would create a workspace populated with that repo content, and launch your docker container. 每次作业执行都会创建一个工作区,其中填充了该回购内容,然后启动docker容器。

If not, you would need to add a script step, like this one in Groovy . 如果没有,则需要添加一个脚本步骤,例如Groovy中的这一步。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 创建 Jenkins 作业以在服务器上部署文件 - Create a Jenkins job to deploy a file on a server 如何在Jenkins中将文件附加到电子邮件? - How can I attach a file to the email in Jenkins? 如何以编程方式创建新的 cron 作业? - How can I programmatically create a new cron job? 如何在Linux上作为cron作业启动的程序中锁定文件? - How can I lock a file from a program started as a cron job on Linux? 如何通过 jenkins 作业在 docker 中创建 httpd 容器? - How to create a httpd container in docker through jenkins job? 如何创建 perforce 工作区 - How to create a perforce workspace in a 如何使用 cron 作业记录轮换我的日志文件 - how can i log rotation my log file with cron job 如何将Jenkins主目录从/ var / lib更改为app并为原始位置创建符号链接,因为作业不会受到影响 - How to change the Jenkins Home Directory from /var/lib to app and create a symlink for orginal location as job wont get affected 如何将Jenkins作业从Windows本地计算机迁移到Linux服务器? - How to migrate Jenkins job from windows local machine to Linux server? Jenkins + Build Flow,如何将变量从一个作业传递到另一个作业 - Jenkins + Build Flow, how to pass a variable from one job to another
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM