Add line to ClearCase config

余生颓废 提交于 2019-12-08 07:54:31

问题


I am running a job on Jenkins which is used to create a view on ClearCase and the ClearCase view creates the default config spec.

I want to edit the config spec by adding some more lines to it but I don't want to edit it manually every time. So I am looking to add some script to Jenkins so that it can edit the configspec every time when it runs the job.

Is there anyone how is clear case expert who can task it out.


回答1:


Once your ClearCase view is created you need to get its config spec as a file with cleartool edcs

cd /path/to/view
cleartool catcs > cs

You need to adds your selection rules before the default one: as mentioned in config spec

Because the rules in a config spec are processed in order, varying the order may affect version selection. For example, suppose this rule appears near the beginning of a config spec:

element * /main/LATEST

Any subsequent rules in the config spec will never be used, because the rule always provides a match; every element has a most recent version on its main branch.

Note:
The order in which the load rules for a snapshot view are specified is not important.

To script that, please see "Using sed, Insert a line below (or above) the pattern?".
Another option: see "How to insert the content of a file into another file before a pattern (marker)?".
Put your additional lines into a file named othercs.

#!/bin/bash
while IFS= read -r line
do
    if [[ "$line" =~ .*CHECKEDOUT.*$ ]]
    then
        cat othercs
    fi
    echo "$line"
done < cs

Once that is done, you can append any additional load rules you want (if you are using a snapshot view, since a dynamic view has no load rules)

Finally, once the cs file has the right selection/load rules, you set it back to the current view with cleartool setcs.

cleartool setcs -tag view-tag  cs
                              ^
                              |
                     name of the file you have modified


来源:https://stackoverflow.com/questions/46934224/add-line-to-clearcase-config

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!