21 if {[
catch {
package require yaml} ERROR]} {
22 puts "$ERROR\n If you are running this script on tclsh, you can fix this by installing 'tcllib'"
26 if {[
catch {
package require cmdline} ERROR]} {
27 puts "$ERROR\n If you are running this script on tclsh, you can fix this by installing 'tcllib'"
32 {runall "If set, it will generate a gitlab-ci yml file for all projects in the Top folder, even if it has not been modified with respect to the target branch."}
33 {static "Normally the content of the hog-child.yml file is added at the beginning of the generated yml file. If this flag is set, this will not be done."}
34 {external_path.arg "" "Path for external files not stored in the git repository."}
37 set usage "Generate a gitlab-ci.yml config file for the child pipeline - USAGE: generate_yaml.tcl \[options\]"
40 set tcl_path [
file normalize "[
file dirname [
info script]]/.."]
42 set repo_path [
file normalize $tcl_path/../..]
43 source $tcl_path/hog.tcl
50 if { $options(runall) == 1 } {
55 if { $options(static) == 1 } {
62 if { $options(external_path) != "" } {
63 set ext_path $options(external_path)
64 Msg Info "External path set to $ext_path"
70 set stage_list $CI_STAGES
71 set prop_list $CI_PROPS
74 if { [
file exists "$repo_path/.gitlab-ci.yml"] } {
75 set created_yml "$repo_path/new_gitlab-ci.yml"
76 Msg Warning "$repo_path/.gitlab-ci.yml, will create (and possibly repleace) $created_yml, please rename it if you want Hog-CI to work."
78 set created_yml "$repo_path/.gitlab-ci.yml"
80 Msg Info "Creating new file $created_yml..."
81 set fp [open $created_yml w]
83 Msg Info "Evaluating the current version of Hog to use in the ref in the yml file..."
85 set ref [
Git describe]
90 puts $fp "include:\n - project: 'hog/Hog'\n file: 'hog.yml'\n ref: '$ref'\n"
93 set created_yml "$repo_path/generated-config.yml"
94 Msg Info "Copying $repo_path/Hog/YAML/hog-common.yml to $created_yml..."
95 file copy -force $repo_path/Hog/YAML/hog-common.yml $created_yml
96 set fp [open $created_yml a]
97 Msg Info "Copying $repo_path/Hog/YAML/hog-child.yml to $created_yml..."
98 set fp2 [open "$repo_path/Hog/YAML/hog-child.yml" r]
99 set file_data [read $fp2]
101 regsub -all {\-\-\-} $file_data "" file_data
104 if { [
file exists "$repo_path/hog-ci-users.yml"] == 1} {
105 Msg Info "Copying $repo_path/hog-ci-users.yml to $created_yml..."
106 set fp3 [open "$repo_path/hog-ci-users.yml" r]
107 set file_data [read $fp3]
109 regsub -all {\-\-\-} $file_data "" file_data
116 foreach proj $projects_list {
118 set proj_name [
file tail $proj]
119 set dir $repo_path/Top/$proj
123 if { [
file exists "$dir/ci.conf"] == 1} {
124 Msg Info "Foung CI configuration file $dir/ci.conf, reading configuration for $proj..."
125 set ci_confs [
ReadConf $dir/ci.conf]
126 set f [open $dir/ci.conf "r"]
129 if {[
string first "NO_VER_CHECK" $line]} {
134 if {$ver == 0 || $ver == -1 || $runall == 1 || $no_ver_check == 1} {
135 if {$runall == 0 && $no_ver_check == 0} {
136 Msg Info "$proj was modified, adding it to CI..."
138 Msg Info "$proj is set to always run, adding it to CI..."
140 if { [
file exists "$dir/ci.conf"] == 1} {
141 Msg Info "Found CI configuration file $dir/ci.conf, reading configuration for $proj..."
144 Msg Info "No CI configuration file found ($dir/ci.conf) for $proj, creating all jobs..."
148 Msg Info "$proj was not modified since version: $ver, skipping."
153 Msg Info "$created_yml generated correctly."