From c721b1d92b929cdcc754124dfdccb8f6316cc1b0 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 11:26:55 +0200 Subject: [PATCH 01/23] One Shell script for process. --- db/src/scripts/generate_ddl.pl | 7 +- jenkins/libraries/maven/steps/process.groovy | 71 +------------------ jenkins/process.sh | 73 ++++++++++++++++++++ 3 files changed, 79 insertions(+), 72 deletions(-) create mode 100644 jenkins/process.sh diff --git a/db/src/scripts/generate_ddl.pl b/db/src/scripts/generate_ddl.pl index a977683e..e3c4be6c 100644 --- a/db/src/scripts/generate_ddl.pl +++ b/db/src/scripts/generate_ddl.pl @@ -247,7 +247,6 @@ =head1 HISTORY use 5.016003; # Strawberry perl: 5.18.2, Jenkins server: 5.16.3 use Carp; -use Data::Dumper; use English; use File::Basename; use File::Compare; @@ -409,6 +408,8 @@ =head1 HISTORY # SUBROUTINES sub main () { + eval "use Data::Dumper; 1" or warn("Could not load Data::Dumper"); + info("\@ARGV: @ARGV"); process_command_line(); print_run_info(\*STDERR, 0); @@ -589,7 +590,9 @@ () } } - debug(Data::Dumper->Dump([%sql_statements], [qw(sql_statements)])); + eval { + debug(Data::Dumper->Dump([%sql_statements], [qw(sql_statements)])); + }; all_sql_statements_flush($fh_install_sql, \$fh, \$nr_sql_statements, \%sql_statements); smart_close($fh) diff --git a/jenkins/libraries/maven/steps/process.groovy b/jenkins/libraries/maven/steps/process.groovy index ad0690ca..ed200106 100644 --- a/jenkins/libraries/maven/steps/process.groovy +++ b/jenkins/libraries/maven/steps/process.groovy @@ -67,76 +67,7 @@ void call(app_env){ findbugsPublisher(disabled: true), openTasksPublisher(disabled: true)]) { sshagent([env.SCM_CREDENTIALS]) { - sh(''' -pwd -unset JAVA_HOME -export GIT_SSH_COMMAND="ssh -oStrictHostKeyChecking=no" -git config user.name ${SCM_USERNAME} -git config user.email ${SCM_EMAIL} -if [ -n "$SCM_BRANCH_PREV" ] -then - git checkout "$SCM_BRANCH_PREV" - git checkout "$SCM_BRANCH" - git merge "$SCM_BRANCH_PREV" -fi - -db_config_dir=`cd ${CONF_DIR} && pwd` -oracle_tools_dir=$WORKSPACE/oracle-tools - -# First DB run -echo "processing DB actions ${DB_ACTIONS} in ${DB_DIR} with configuration directory $db_config_dir" -set -- ${DB_ACTIONS} -for profile; do mvn -f ${DB_DIR} -Doracle-tools.dir=$oracle_tools_dir -Ddb.config.dir=$db_config_dir -Ddb=${DB} -D$DB_USERNAME_PROPERTY=$DB_USERNAME -Ddb.password=$DB_PASSWORD -P$profile; done -if [ -n "`git status --porcelain`" ] -then - git add . - git commit -m"Database changes. Triggered Build: $BUILD_NUMBER" -fi -if [ "`git diff --stat --cached origin/${SCM_BRANCH} | wc -l`" -ne 0 ] -then - git push --set-upstream origin ${SCM_BRANCH} -fi - -# Second DB run: verify that there are no changes after a second round (just install and generate DDL) -DB_ACTIONS="db-install db-generate-ddl-full" -echo "checking that there are no changes after a second round of ${DB_ACTIONS} (standard output is suppressed)" -set -- ${DB_ACTIONS} -for profile; do mvn -f ${DB_DIR} -Doracle-tools.dir=$oracle_tools_dir -Ddb.config.dir=$db_config_dir -Ddb=${DB} -D$DB_USERNAME_PROPERTY=$DB_USERNAME -Ddb.password=$DB_PASSWORD -P$profile -l mvn-${profile}.log; done -echo "there should be no files to add for Git:" -test -z "`git status --porcelain`" - -echo "processing APEX actions ${APEX_ACTIONS} in ${APEX_DIR} with configuration directory $db_config_dir" -set -- ${APEX_ACTIONS} -for profile; do mvn -f ${APEX_DIR} -Doracle-tools.dir=$oracle_tools_dir -Ddb.config.dir=$db_config_dir -Ddb=${DB} -D$DB_USERNAME_PROPERTY=$DB_USERNAME -Ddb.password=$DB_PASSWORD -P$profile; done - -# ${APEX_DIR}/src/export/application/create_application.sql changes its p_flow_version so use git diff --compact-summary to verify it is just that file and that line -# -# % git diff --compact-summary -# apex/app/src/export/application/create_application.sql | 2 +- -# 1 file changed, 1 insertion(+), 1 deletion(-) - -create_application=${APEX_DIR}/src/export/application/create_application.sql -# Use a little bit of awk to check that the file and its changes are matched and that the total number of lines is just 2 -result="`git diff --compact-summary | awk -f $oracle_tools_dir/jenkins/only_create_application_changed.awk`" -if [ "$result" = "YES" ] -then - git update-index --assume-unchanged $create_application - workspace_changed="`git status --porcelain`" - git update-index --no-assume-unchanged $create_application -else - workspace_changed="`git status --porcelain`" -fi - -if [ -n "$workspace_changed" ] -then - git add . - git commit -m"APEX changes. Triggered Build: $BUILD_NUMBER" -fi -if [ "`git diff --stat --cached origin/${SCM_BRANCH} | wc -l`" -ne 0 ] -then - git push --set-upstream origin ${SCM_BRANCH} -fi - ''') + sh('$WORKSPACE/oracle-tools/jenkins/process.sh') } } } diff --git a/jenkins/process.sh b/jenkins/process.sh new file mode 100644 index 00000000..1e280664 --- /dev/null +++ b/jenkins/process.sh @@ -0,0 +1,73 @@ +#!/bin/sh -eu + +# Script to be invoked from a Jenkins build. +# Environment variables must be set otherwise an error occurs (-eu above). + +oracle_tools_dir="`dirname $0`/.." + +pwd +export GIT_SSH_COMMAND="ssh -oStrictHostKeyChecking=no" +git config user.name ${SCM_USERNAME} +git config user.email ${SCM_EMAIL} +if [ -n "$SCM_BRANCH_PREV" ] +then + git checkout "$SCM_BRANCH_PREV" + git checkout "$SCM_BRANCH" + git merge "$SCM_BRANCH_PREV" +fi + +db_config_dir=`cd ${CONF_DIR} && pwd` + +# First DB run +echo "processing DB actions ${DB_ACTIONS} in ${DB_DIR} with configuration directory $db_config_dir" +set -- ${DB_ACTIONS} +for profile; do mvn -f ${DB_DIR} -Doracle-tools.dir=$oracle_tools_dir -Ddb.config.dir=$db_config_dir -Ddb=${DB} -D$DB_USERNAME_PROPERTY=$DB_USERNAME -Ddb.password=$DB_PASSWORD -P$profile; done +if [ -n "`git status --porcelain`" ] +then + git add . + git commit -m"Database changes. Triggered Build: $BUILD_NUMBER" +fi +if [ "`git diff --stat --cached origin/${SCM_BRANCH} | wc -l`" -ne 0 ] +then + git push --set-upstream origin ${SCM_BRANCH} +fi + +# Second DB run: verify that there are no changes after a second round (just install and generate DDL) +DB_ACTIONS="db-install db-generate-ddl-full" +echo "checking that there are no changes after a second round of ${DB_ACTIONS} (standard output is suppressed)" +set -- ${DB_ACTIONS} +for profile; do mvn -f ${DB_DIR} -Doracle-tools.dir=$oracle_tools_dir -Ddb.config.dir=$db_config_dir -Ddb=${DB} -D$DB_USERNAME_PROPERTY=$DB_USERNAME -Ddb.password=$DB_PASSWORD -P$profile -l mvn-${profile}.log; done +echo "there should be no files to add for Git:" +test -z "`git status --porcelain`" + +echo "processing APEX actions ${APEX_ACTIONS} in ${APEX_DIR} with configuration directory $db_config_dir" +set -- ${APEX_ACTIONS} +for profile; do mvn -f ${APEX_DIR} -Doracle-tools.dir=$oracle_tools_dir -Ddb.config.dir=$db_config_dir -Ddb=${DB} -D$DB_USERNAME_PROPERTY=$DB_USERNAME -Ddb.password=$DB_PASSWORD -P$profile; done + +# ${APEX_DIR}/src/export/application/create_application.sql changes its p_flow_version so use git diff --compact-summary to verify it is just that file and that line +# +# % git diff --compact-summary +# apex/app/src/export/application/create_application.sql | 2 +- +# 1 file changed, 1 insertion(+), 1 deletion(-) + +create_application=${APEX_DIR}/src/export/application/create_application.sql +# Use a little bit of awk to check that the file and its changes are matched and that the total number of lines is just 2 +result="`git diff --compact-summary | awk -f $oracle_tools_dir/jenkins/only_create_application_changed.awk`" +if [ "$result" = "YES" ] +then + git update-index --assume-unchanged $create_application + workspace_changed="`git status --porcelain`" + git update-index --no-assume-unchanged $create_application +else + workspace_changed="`git status --porcelain`" +fi + +if [ -n "$workspace_changed" ] +then + git add . + git commit -m"APEX changes. Triggered Build: $BUILD_NUMBER" +fi +if [ "`git diff --stat --cached origin/${SCM_BRANCH} | wc -l`" -ne 0 ] +then + git push --set-upstream origin ${SCM_BRANCH} +fi From 28f87676c375436298bb76c1cfc8d91ccb7cb534 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 11:43:30 +0200 Subject: [PATCH 02/23] Use git add --all . --- jenkins/Jenkinsfile | 4 ++++ jenkins/pipeline_config.groovy | 29 ++++++++++++----------------- jenkins/process.sh | 4 ++-- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/jenkins/Jenkinsfile b/jenkins/Jenkinsfile index fe75923a..4657a1f4 100644 --- a/jenkins/Jenkinsfile +++ b/jenkins/Jenkinsfile @@ -4,6 +4,10 @@ pipeline { options { skipDefaultCheckout() } + tools { + maven pipelineConfig.maven + jdk pipelineConfig.jdk + } stages { stage("dev") { steps { diff --git a/jenkins/pipeline_config.groovy b/jenkins/pipeline_config.groovy index 45ac1190..6b9ac91b 100644 --- a/jenkins/pipeline_config.groovy +++ b/jenkins/pipeline_config.groovy @@ -1,8 +1,19 @@ // accessible via JTEs pipelineConfig maven = 'maven-3' -scm_branch_oracle_tools = 'development' +jdk = 'jdk-9' + // a clone without credentials scm_url_oracle_tools = 'http://github.com/paulissoft/oracle-tools.git' +scm_branch_oracle_tools = 'development' + +scm_url = 'git@github.com:paulissoft/oracle-tools.git' +scm_credentials = 'paulissoft' +scm_username = 'paulissoft' +scm_email = 'paulissoft@gmail.com' + +conf_dir = 'conf/src' +db_dir = 'db/app' +apex_dir = 'apex/app' libraries{ // merge = true @@ -13,37 +24,21 @@ application_environments{ dev{ // Oracle tools info scm_branch = 'development' - scm_credentials = 'paulissoft' - scm_url = 'git@github.com:paulissoft/oracle-tools.git' - scm_username = 'paulissoft' - scm_email = 'paulissoft@gmail.com' - - conf_dir = 'conf/src' db = 'docker' db_credentials = 'oracle-tools-development' - db_dir = 'db/app' db_actions = 'db-info db-install db-generate-ddl-full' - apex_dir = 'apex/app' apex_actions = 'apex-export' } test{ // Oracle tools info scm_branch = 'test' - scm_credentials = 'paulissoft' - scm_url = 'git@github.com:paulissoft/oracle-tools.git' - scm_username = 'paulissoft' - scm_email = 'paulissoft@gmail.com' - - conf_dir = 'conf/src' db = 'docker' db_credentials = 'oracle-tools-development' - db_dir = 'db/app' db_actions = 'db-info db-install db-generate-ddl-full' - apex_dir = 'apex/app' apex_actions = 'apex-import' } } diff --git a/jenkins/process.sh b/jenkins/process.sh index 1e280664..d300ab16 100644 --- a/jenkins/process.sh +++ b/jenkins/process.sh @@ -24,7 +24,7 @@ set -- ${DB_ACTIONS} for profile; do mvn -f ${DB_DIR} -Doracle-tools.dir=$oracle_tools_dir -Ddb.config.dir=$db_config_dir -Ddb=${DB} -D$DB_USERNAME_PROPERTY=$DB_USERNAME -Ddb.password=$DB_PASSWORD -P$profile; done if [ -n "`git status --porcelain`" ] then - git add . + git add --all . git commit -m"Database changes. Triggered Build: $BUILD_NUMBER" fi if [ "`git diff --stat --cached origin/${SCM_BRANCH} | wc -l`" -ne 0 ] @@ -64,7 +64,7 @@ fi if [ -n "$workspace_changed" ] then - git add . + git add --all . git commit -m"APEX changes. Triggered Build: $BUILD_NUMBER" fi if [ "`git diff --stat --cached origin/${SCM_BRANCH} | wc -l`" -ne 0 ] From ffce67dae4760156679a411e0c03e2736a23a1bb Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 12:58:49 +0200 Subject: [PATCH 03/23] Update generate_ddl.pl --- db/src/scripts/generate_ddl.pl | 69 +++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 6 deletions(-) diff --git a/db/src/scripts/generate_ddl.pl b/db/src/scripts/generate_ddl.pl index e3c4be6c..cd4c752c 100644 --- a/db/src/scripts/generate_ddl.pl +++ b/db/src/scripts/generate_ddl.pl @@ -400,6 +400,7 @@ =head1 HISTORY sub warning (@); sub info (@); sub debug (@); +sub trace (@); # MAIN @@ -408,6 +409,8 @@ =head1 HISTORY # SUBROUTINES sub main () { + trace((caller(0))[3]); + eval "use Data::Dumper; 1" or warn("Could not load Data::Dumper"); info("\@ARGV: @ARGV"); @@ -417,8 +420,9 @@ () process(); } -sub process_command_line () -{ +sub process_command_line () { + trace((caller(0))[3]); + # Windows FTYPE and ASSOC cause the command 'generate_ddl -h -c file' # to have ARGV[0] == ' -h -c file' and number of arguments 1. # Hence strip the spaces from $ARGV[0] and recreate @ARGV. @@ -458,6 +462,8 @@ () } sub process () { + trace((caller(0))[3]); + my $install_sql = ($skip_install_sql ? undef : File::Spec->catfile($output_directory, 'install.sql')); my $in; @@ -473,9 +479,9 @@ () # These files are not needed anymore since the directory contents are used to determine the object sequence for interface V5 unlink(File::Spec->catfile($output_directory, OLD_INSTALL_SEQUENCE_TXT), File::Spec->catfile($output_directory, NEW_INSTALL_SEQUENCE_TXT)); - + # always make the output directory - make_path($output_directory, { verbose => 0 }); + make_path($output_directory, { verbose => $verbose > 0 }); # turn autoflush on for both STDOUT and STDERR select(STDERR); @@ -517,7 +523,7 @@ () # read interface (first line with '-- ') # my $interface_expr = '^-- (' . PKG_DDL_UTIL_V4 . '|' . PKG_DDL_UTIL_V5 . ')$'; - + INTERFACE: while (defined(my $line = <$in>)) { print $fh $line @@ -534,7 +540,7 @@ () } $interface = '' unless defined($interface); - + error("Unknown interface: $interface") unless ( $interface eq PKG_DDL_UTIL_V4 || $interface eq PKG_DDL_UTIL_V5 ); @@ -632,6 +638,8 @@ () } # process sub process_object_type ($$$$) { + trace((caller(0))[3]); + my ($object_type, $r_object_type_lines, $r_ddl_no, $r_sql_statements) = @_; debug("Process object type $object_type with $#$r_object_type_lines lines") if (defined($object_type)); @@ -705,6 +713,8 @@ ($$$$) } sub get_object_type_line ($$) { + trace((caller(0))[3]); + my ($object_type, $r_object_type_lines) = @_; # Remove a block like this: @@ -734,6 +744,8 @@ ($$) } sub parse_object($) { + trace((caller(0))[3]); + my ($owner, $name) = ($source_schema, @_); if ($name =~ qr/(?$id_expr)\s*\.\s*(?$id_expr)/) { @@ -751,6 +763,8 @@ ($) } sub get_object ($$$;$$$) { + trace((caller(0))[3]); + my ($object_schema, $object_type, $object_name, $base_object_schema, $base_object_type, $base_object_name) = @_; my $sep = ':'; @@ -784,6 +798,8 @@ ($$$;$$$) } sub object_file_name ($$$) { + trace((caller(0))[3]); + my ($object_schema, $object_type, $object_name) = @_; if (length($source_schema) > 0 && $object_schema !~ m/^(PUBLIC|$source_schema)$/) { @@ -820,6 +836,8 @@ ($$$) } sub open_file ($$$$) { + trace((caller(0))[3]); + my ($file, $fh_install_sql, $r_fh, $ignore_warning_when_file_exists) = @_; if (defined $fh_install_sql && !$install_sql_preamble_printed) { @@ -848,6 +866,8 @@ ($$$$) } sub close_file ($$) { + trace((caller(0))[3]); + my ($file, $r_fh) = @_; # close before comparing/copying/removing @@ -861,6 +881,8 @@ ($$) # open file for writing sub smart_open ($;$) { + trace((caller(0))[3]); + my ($file, $append) = @_; my $basename = basename($file); my ($tmpfile, $fh) = (File::Spec->catfile($TMPDIR, $basename)); @@ -875,6 +897,8 @@ ($;$) } sub smart_close ($) { + trace((caller(0))[3]); + my $fh = shift @_; error("File handle unknown") @@ -904,6 +928,8 @@ ($) } sub add_sql_statement ($$$$;$) { + trace((caller(0))[3]); + my ($r_sql_line, $r_sql_statements, $object, $ddl_no, $ddl_info) = @_; debug("Adding '$$r_sql_line' for object $object and statement $ddl_no"); @@ -932,6 +958,8 @@ ($$$$;$) } sub sort_sql_statements ($$$) { + trace((caller(0))[3]); + my ($r_sql_statements, $a, $b) = @_; my $result; @@ -947,6 +975,8 @@ ($$$) } sub sort_dependent_objects ($$$) { + trace((caller(0))[3]); + my ($object_type, $a, $b) = @_; if ($object_type eq 'OBJECT_GRANT') { @@ -962,6 +992,8 @@ ($$$) } sub all_sql_statements_flush ($$$$) { + trace((caller(0))[3]); + my ($fh_install_sql, $r_fh, $r_nr_sql_statements, $r_sql_statements) = @_; debug("Flushing all objects"); @@ -979,6 +1011,8 @@ ($$$$) } sub object_sql_statements_flush ($$$$$) { + trace((caller(0))[3]); + my ($fh_install_sql, $r_fh, $r_nr_sql_statements, $r_sql_statements, $object) = @_; my $ignore_warning_when_file_exists = 0; @@ -1087,6 +1121,8 @@ ($$$$$) } # object_sql_statements_flush sub sql_statement_flush ($$$$$$) { + trace((caller(0))[3]); + my ($fh, $r_nr_sql_statements, $r_sql_statement, $object, $ddl_no, $ddl_info) = @_; debug("Flushing statement for $object with ", scalar(@$r_sql_statement), " line(s)"); @@ -1311,6 +1347,8 @@ ($$$$$$) } sub print_run_info ($$) { + trace((caller(0))[3]); + my ($fh, $install) = @_; error("File handle must be defined") unless defined($fh); @@ -1327,12 +1365,16 @@ ($$) } sub remove_cr_lf ($) { + trace((caller(0))[3]); + my $r_line = $_[0]; $$r_line =~ s/\r?\n//mg; } sub remove_leading_empty_lines ($) { + trace((caller(0))[3]); + my $r_lines = $_[0]; REMOVE_LEADING_EMPTY_LINES: { @@ -1349,6 +1391,8 @@ ($) } sub remove_trailing_empty_lines ($) { + trace((caller(0))[3]); + my $r_lines = $_[0]; REMOVE_TRAILING_EMPTY_LINES: { @@ -1365,6 +1409,8 @@ ($) } sub beautify_line ($$$$$$) { + trace((caller(0))[3]); + my ($matched_object, $object_schema, $object_name, $object_type, $line_no, $r_line) = @_; return @@ -1414,6 +1460,8 @@ ($$$$$$) } sub split_single_output_file ($) { + trace((caller(0))[3]); + my $input_file = shift @_; # only one SQL statement allowed @@ -1448,6 +1496,8 @@ ($) } sub add_object_seq ($;$) { + trace((caller(0))[3]); + my ($object, $object_seq) = @_; error("Object '$object' should match 'SCHEMA:TYPE:NAME'") @@ -1474,6 +1524,8 @@ ($;$) } sub read_object_seq () { + trace((caller(0))[3]); + my %objects; opendir my $dh, $output_directory or die "Could not open '$output_directory' for reading '$!'\n"; @@ -1508,3 +1560,8 @@ (@) print STDERR "DEBUG: @_\n" if ($verbose >= 2); } + +sub trace (@) { + carp "TRACE: @_\n" + if ($verbose >= 3); +} From 78f4d78e8a11482a64ccb1de68d4716a98bfe995 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 13:51:55 +0200 Subject: [PATCH 04/23] Update generate_ddl.pl --- db/src/scripts/generate_ddl.pl | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/db/src/scripts/generate_ddl.pl b/db/src/scripts/generate_ddl.pl index cd4c752c..3778bc29 100644 --- a/db/src/scripts/generate_ddl.pl +++ b/db/src/scripts/generate_ddl.pl @@ -394,6 +394,7 @@ =head1 HISTORY sub remove_trailing_empty_lines ($); sub beautify_line ($$$$$$); sub split_single_output_file($); +sub get_object_seq ($); sub add_object_seq ($;$); sub read_object_seq (); sub error (@); @@ -821,13 +822,13 @@ ($$$) my $object_file_name; my $nr_zeros = ($interface eq PKG_DDL_UTIL_V4 ? 2 : 4); - if (!exists($object_seq{$object_seq_key})) { + if (!defined(get_object_seq($object_seq_key))) { add_object_seq($object_seq_key); } $object_file_name = uc(sprintf("%s%0${nr_zeros}d.%s%s.%s", ($object_type_info{$object_type}->{'repeatable'} ? 'R__' : ''), - ($interface eq PKG_DDL_UTIL_V4 ? $object_type_info{$object_type}->{'seq'} : $object_seq{$object_seq_key}), + ($interface eq PKG_DDL_UTIL_V4 ? $object_type_info{$object_type}->{'seq'} : get_object_seq($object_seq_key)), (${strip_source_schema} && $source_schema eq $object_schema ? '' : $object_schema . '.'), $object_type, $object_name)) . '.sql'; @@ -968,7 +969,8 @@ ($$$) $result = ($r_sql_statements->{$a}->{seq} <=> $r_sql_statements->{$b}->{seq}); } else { # $object_seq{$a} and $object_seq{$b} will exists do to call to add_object_seq() in add_sql_statement() - $result = ($object_seq{$a} <=> $object_seq{$b}); + debug(sprintf("get_object_seq('%s'); '%s'; get_object_seq('%s'): '%s'", $a, get_object_seq($a), $b, get_object_seq($b))); + $result = (get_object_seq($a) <=> get_object_seq($b)); } return $result; @@ -1495,16 +1497,34 @@ ($) unlink($input_file); } -sub add_object_seq ($;$) { +sub get_object_seq ($) { trace((caller(0))[3]); my ($object, $object_seq) = @_; + + $object = uc($object); + + error("Object '$object' must be in upper case") + unless $object eq uc($object); + + return exists($object_seq{$object}) ? $object_seq{$object} : undef; +} +sub add_object_seq ($;$) { + trace((caller(0))[3]); + + my ($object, $object_seq) = @_; + + $object = uc($object); + + error("Object '$object' must be in upper case") + unless $object eq uc($object); + error("Object '$object' should match 'SCHEMA:TYPE:NAME'") unless $object =~ m/^.+:.+:.+$/; - + error("Object sequence for '$object' already exists.") - if exists($object_seq{$object}); + if defined(get_object_seq($object)); if (defined($object_seq)) { # strip leading zeros otherwise it will be treated as an octal number From ec5aac887645c7fc973be74e2e948c0a0f5d61b5 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 13:55:15 +0200 Subject: [PATCH 05/23] Update generate_ddl.pl --- db/src/scripts/generate_ddl.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/db/src/scripts/generate_ddl.pl b/db/src/scripts/generate_ddl.pl index 3778bc29..522048be 100644 --- a/db/src/scripts/generate_ddl.pl +++ b/db/src/scripts/generate_ddl.pl @@ -165,6 +165,10 @@ =head1 HISTORY =over 4 +=item 2022-04-26 + +Solved bug for objects named like "name" where name is not totally upper case. + =item 2021-08-27 Create the file in the output directory only when it is different from the From 833f97eebe9e6a5ffbfe8e53675a11b9399f55b0 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 14:10:26 +0200 Subject: [PATCH 06/23] Update generate_ddl.pl --- db/src/scripts/generate_ddl.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/src/scripts/generate_ddl.pl b/db/src/scripts/generate_ddl.pl index 522048be..07a9706c 100644 --- a/db/src/scripts/generate_ddl.pl +++ b/db/src/scripts/generate_ddl.pl @@ -272,7 +272,7 @@ =head1 HISTORY # VARIABLES -my $VERSION = "2021-08-27"; +my $VERSION = "2022-04-26"; my $program = &basename($0); my $encoding = ''; # was :crlf:encoding(UTF-8) From 12773556f1cdd00d16902622785225a0c0dbd673 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 14:13:55 +0200 Subject: [PATCH 07/23] Update process.sh --- jenkins/process.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/process.sh b/jenkins/process.sh index d300ab16..074faa2d 100644 --- a/jenkins/process.sh +++ b/jenkins/process.sh @@ -36,7 +36,7 @@ fi DB_ACTIONS="db-install db-generate-ddl-full" echo "checking that there are no changes after a second round of ${DB_ACTIONS} (standard output is suppressed)" set -- ${DB_ACTIONS} -for profile; do mvn -f ${DB_DIR} -Doracle-tools.dir=$oracle_tools_dir -Ddb.config.dir=$db_config_dir -Ddb=${DB} -D$DB_USERNAME_PROPERTY=$DB_USERNAME -Ddb.password=$DB_PASSWORD -P$profile -l mvn-${profile}.log; done +for profile; do mvn -f ${DB_DIR} -Doracle-tools.dir=$oracle_tools_dir -Ddb.config.dir=$db_config_dir -Ddb=${DB} -D$DB_USERNAME_PROPERTY=$DB_USERNAME -Ddb.password=$DB_PASSWORD -P$profile -l mvn-${profile}.log; rm mvn-${profile}.log; done echo "there should be no files to add for Git:" test -z "`git status --porcelain`" From 38f29bce9982a73c6dab3f899869f33b254bf1b2 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 14:15:38 +0200 Subject: [PATCH 08/23] Update process.groovy --- jenkins/libraries/maven/steps/process.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/libraries/maven/steps/process.groovy b/jenkins/libraries/maven/steps/process.groovy index ed200106..dc741b8a 100644 --- a/jenkins/libraries/maven/steps/process.groovy +++ b/jenkins/libraries/maven/steps/process.groovy @@ -67,7 +67,7 @@ void call(app_env){ findbugsPublisher(disabled: true), openTasksPublisher(disabled: true)]) { sshagent([env.SCM_CREDENTIALS]) { - sh('$WORKSPACE/oracle-tools/jenkins/process.sh') + sh('chmod +x $WORKSPACE/oracle-tools/jenkins/process.sh && $WORKSPACE/oracle-tools/jenkins/process.sh') } } } From fcf847725a9c5f65cf79eab53e208cf81d8aa5a8 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 14:19:41 +0200 Subject: [PATCH 09/23] Update process.sh --- jenkins/process.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jenkins/process.sh b/jenkins/process.sh index 074faa2d..9beef127 100644 --- a/jenkins/process.sh +++ b/jenkins/process.sh @@ -9,12 +9,15 @@ pwd export GIT_SSH_COMMAND="ssh -oStrictHostKeyChecking=no" git config user.name ${SCM_USERNAME} git config user.email ${SCM_EMAIL} + +set +u # SCM_BRANCH_PREV may be unset if [ -n "$SCM_BRANCH_PREV" ] then git checkout "$SCM_BRANCH_PREV" git checkout "$SCM_BRANCH" git merge "$SCM_BRANCH_PREV" fi +set -u db_config_dir=`cd ${CONF_DIR} && pwd` From d25cdf443ca1c570ea5d1ebc93425dd4317fa6b7 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 14:58:06 +0200 Subject: [PATCH 10/23] Update process.groovy --- jenkins/libraries/maven/steps/process.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jenkins/libraries/maven/steps/process.groovy b/jenkins/libraries/maven/steps/process.groovy index dc741b8a..4f67d505 100644 --- a/jenkins/libraries/maven/steps/process.groovy +++ b/jenkins/libraries/maven/steps/process.groovy @@ -67,7 +67,8 @@ void call(app_env){ findbugsPublisher(disabled: true), openTasksPublisher(disabled: true)]) { sshagent([env.SCM_CREDENTIALS]) { - sh('chmod +x $WORKSPACE/oracle-tools/jenkins/process.sh && $WORKSPACE/oracle-tools/jenkins/process.sh') + sh('chmod +x $WORKSPACE/oracle-tools/jenkins/process.sh') + sh('$WORKSPACE/oracle-tools/jenkins/process.sh') } } } From 19f0688dc6a88f63caf025a81ce35322ea822429 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 15:54:56 +0200 Subject: [PATCH 11/23] Update process.sh --- jenkins/process.sh | 47 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/jenkins/process.sh b/jenkins/process.sh index 9beef127..d102ad09 100644 --- a/jenkins/process.sh +++ b/jenkins/process.sh @@ -1,5 +1,24 @@ #!/bin/sh -eu +process_git() +{ + description=$1 + + workspace_changes="`git status --porcelain`" + + echo "workspace changes: ${workspace_changes}" + + if [ -n "$workspace_changes" ] + then + git add --all . + git commit -m"${description}. Triggered Build: $BUILD_NUMBER" + fi + if [ "`git diff --stat --cached origin/${SCM_BRANCH} | wc -l`" -ne 0 ] + then + git push --set-upstream origin ${SCM_BRANCH} + fi +} + # Script to be invoked from a Jenkins build. # Environment variables must be set otherwise an error occurs (-eu above). @@ -25,15 +44,7 @@ db_config_dir=`cd ${CONF_DIR} && pwd` echo "processing DB actions ${DB_ACTIONS} in ${DB_DIR} with configuration directory $db_config_dir" set -- ${DB_ACTIONS} for profile; do mvn -f ${DB_DIR} -Doracle-tools.dir=$oracle_tools_dir -Ddb.config.dir=$db_config_dir -Ddb=${DB} -D$DB_USERNAME_PROPERTY=$DB_USERNAME -Ddb.password=$DB_PASSWORD -P$profile; done -if [ -n "`git status --porcelain`" ] -then - git add --all . - git commit -m"Database changes. Triggered Build: $BUILD_NUMBER" -fi -if [ "`git diff --stat --cached origin/${SCM_BRANCH} | wc -l`" -ne 0 ] -then - git push --set-upstream origin ${SCM_BRANCH} -fi +process_git "Database changes" # Second DB run: verify that there are no changes after a second round (just install and generate DDL) DB_ACTIONS="db-install db-generate-ddl-full" @@ -58,19 +69,7 @@ create_application=${APEX_DIR}/src/export/application/create_application.sql result="`git diff --compact-summary | awk -f $oracle_tools_dir/jenkins/only_create_application_changed.awk`" if [ "$result" = "YES" ] then - git update-index --assume-unchanged $create_application - workspace_changed="`git status --porcelain`" - git update-index --no-assume-unchanged $create_application -else - workspace_changed="`git status --porcelain`" -fi + git checkout -- $create_application +fi -if [ -n "$workspace_changed" ] -then - git add --all . - git commit -m"APEX changes. Triggered Build: $BUILD_NUMBER" -fi -if [ "`git diff --stat --cached origin/${SCM_BRANCH} | wc -l`" -ne 0 ] -then - git push --set-upstream origin ${SCM_BRANCH} -fi +process_git "APEX changes" From 95fe6af1ccfd7299abd38581268fdcc01eaadb42 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 16:06:05 +0200 Subject: [PATCH 12/23] Update process.sh --- jenkins/process.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/jenkins/process.sh b/jenkins/process.sh index d102ad09..66df0bb5 100644 --- a/jenkins/process.sh +++ b/jenkins/process.sh @@ -46,13 +46,18 @@ set -- ${DB_ACTIONS} for profile; do mvn -f ${DB_DIR} -Doracle-tools.dir=$oracle_tools_dir -Ddb.config.dir=$db_config_dir -Ddb=${DB} -D$DB_USERNAME_PROPERTY=$DB_USERNAME -Ddb.password=$DB_PASSWORD -P$profile; done process_git "Database changes" -# Second DB run: verify that there are no changes after a second round (just install and generate DDL) -DB_ACTIONS="db-install db-generate-ddl-full" -echo "checking that there are no changes after a second round of ${DB_ACTIONS} (standard output is suppressed)" -set -- ${DB_ACTIONS} -for profile; do mvn -f ${DB_DIR} -Doracle-tools.dir=$oracle_tools_dir -Ddb.config.dir=$db_config_dir -Ddb=${DB} -D$DB_USERNAME_PROPERTY=$DB_USERNAME -Ddb.password=$DB_PASSWORD -P$profile -l mvn-${profile}.log; rm mvn-${profile}.log; done -echo "there should be no files to add for Git:" -test -z "`git status --porcelain`" +# Both db-install and db-generate-ddl-full part of DB_ACTIONS? +# If so, a second run should change nothing +if echo $DB_ACTIONS | grep db-install && echo $DB_ACTIONS | grep db-generate-ddl-full +then + # Second DB run: verify that there are no changes after a second round (just install and generate DDL) + DB_ACTIONS="db-install db-generate-ddl-full" + echo "checking that there are no changes after a second round of ${DB_ACTIONS} (standard output is suppressed)" + set -- ${DB_ACTIONS} + for profile; do mvn -f ${DB_DIR} -Doracle-tools.dir=$oracle_tools_dir -Ddb.config.dir=$db_config_dir -Ddb=${DB} -D$DB_USERNAME_PROPERTY=$DB_USERNAME -Ddb.password=$DB_PASSWORD -P$profile -l mvn-${profile}.log; rm mvn-${profile}.log; done + echo "there should be no files to add for Git:" + test -z "`git status --porcelain`" +fi echo "processing APEX actions ${APEX_ACTIONS} in ${APEX_DIR} with configuration directory $db_config_dir" set -- ${APEX_ACTIONS} From a6a608d84853e66841e80a118b28c458ec892278 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 16:15:09 +0200 Subject: [PATCH 13/23] Update process.sh --- jenkins/process.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jenkins/process.sh b/jenkins/process.sh index 66df0bb5..7f70712c 100644 --- a/jenkins/process.sh +++ b/jenkins/process.sh @@ -29,13 +29,18 @@ export GIT_SSH_COMMAND="ssh -oStrictHostKeyChecking=no" git config user.name ${SCM_USERNAME} git config user.email ${SCM_EMAIL} -set +u # SCM_BRANCH_PREV may be unset +set +u # come variables may be unset + if [ -n "$SCM_BRANCH_PREV" ] then git checkout "$SCM_BRANCH_PREV" git checkout "$SCM_BRANCH" git merge "$SCM_BRANCH_PREV" fi + +test -n "$DB_ACTIONS" || export DB_ACTIONS="" +test -n "$APEX_ACTIONS" || export APEX_ACTIONS="" + set -u db_config_dir=`cd ${CONF_DIR} && pwd` From d0698b4dbf44a37b0b74c5b6dbb0213834da47f9 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 16:34:08 +0200 Subject: [PATCH 14/23] Update process.sh --- jenkins/process.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/jenkins/process.sh b/jenkins/process.sh index 7f70712c..3bc50bd4 100644 --- a/jenkins/process.sh +++ b/jenkins/process.sh @@ -25,6 +25,7 @@ process_git() oracle_tools_dir="`dirname $0`/.." pwd +git --version export GIT_SSH_COMMAND="ssh -oStrictHostKeyChecking=no" git config user.name ${SCM_USERNAME} git config user.email ${SCM_EMAIL} From d4492f6b1c170b3f16c029db1fbce4dce31bdf91 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 16:46:46 +0200 Subject: [PATCH 15/23] Update process.sh --- jenkins/process.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jenkins/process.sh b/jenkins/process.sh index 3bc50bd4..90e0aae8 100644 --- a/jenkins/process.sh +++ b/jenkins/process.sh @@ -24,8 +24,12 @@ process_git() oracle_tools_dir="`dirname $0`/.." +# checking environment pwd git --version +# this command should succeed +git diff --compact-summary || { echo "Git must be at least 2.17 (git diff --compact-summary)" && exit 1 } + export GIT_SSH_COMMAND="ssh -oStrictHostKeyChecking=no" git config user.name ${SCM_USERNAME} git config user.email ${SCM_EMAIL} From ac3b2b2b8747f436e5979f3b9bbf5a2da5bf1928 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 16:56:23 +0200 Subject: [PATCH 16/23] Update process.sh --- jenkins/process.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jenkins/process.sh b/jenkins/process.sh index 90e0aae8..06af8389 100644 --- a/jenkins/process.sh +++ b/jenkins/process.sh @@ -27,8 +27,6 @@ oracle_tools_dir="`dirname $0`/.." # checking environment pwd git --version -# this command should succeed -git diff --compact-summary || { echo "Git must be at least 2.17 (git diff --compact-summary)" && exit 1 } export GIT_SSH_COMMAND="ssh -oStrictHostKeyChecking=no" git config user.name ${SCM_USERNAME} @@ -81,7 +79,7 @@ for profile; do mvn -f ${APEX_DIR} -Doracle-tools.dir=$oracle_tools_dir -Ddb.con create_application=${APEX_DIR}/src/export/application/create_application.sql # Use a little bit of awk to check that the file and its changes are matched and that the total number of lines is just 2 -result="`git diff --compact-summary | awk -f $oracle_tools_dir/jenkins/only_create_application_changed.awk`" +result="`(git diff --compact-summary 2>/dev/null || git diff --stat) | awk -f $oracle_tools_dir/jenkins/only_create_application_changed.awk`" if [ "$result" = "YES" ] then git checkout -- $create_application From 79db6d582a0b4f411945c3683188065d9e479ed2 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 17:24:15 +0200 Subject: [PATCH 17/23] Update process.sh --- jenkins/process.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/jenkins/process.sh b/jenkins/process.sh index 06af8389..c600e62f 100644 --- a/jenkins/process.sh +++ b/jenkins/process.sh @@ -32,7 +32,7 @@ export GIT_SSH_COMMAND="ssh -oStrictHostKeyChecking=no" git config user.name ${SCM_USERNAME} git config user.email ${SCM_EMAIL} -set +u # come variables may be unset +set +eu # come variables may be unset if [ -n "$SCM_BRANCH_PREV" ] then @@ -44,7 +44,7 @@ fi test -n "$DB_ACTIONS" || export DB_ACTIONS="" test -n "$APEX_ACTIONS" || export APEX_ACTIONS="" -set -u +set -eu db_config_dir=`cd ${CONF_DIR} && pwd` @@ -71,15 +71,15 @@ echo "processing APEX actions ${APEX_ACTIONS} in ${APEX_DIR} with configuration set -- ${APEX_ACTIONS} for profile; do mvn -f ${APEX_DIR} -Doracle-tools.dir=$oracle_tools_dir -Ddb.config.dir=$db_config_dir -Ddb=${DB} -D$DB_USERNAME_PROPERTY=$DB_USERNAME -Ddb.password=$DB_PASSWORD -P$profile; done -# ${APEX_DIR}/src/export/application/create_application.sql changes its p_flow_version so use git diff --compact-summary to verify it is just that file and that line +# ${APEX_DIR}/src/export/application/create_application.sql changes its p_flow_version so use git diff --stat to verify it is just that file and that line # -# % git diff --compact-summary +# % git diff --stat # apex/app/src/export/application/create_application.sql | 2 +- # 1 file changed, 1 insertion(+), 1 deletion(-) create_application=${APEX_DIR}/src/export/application/create_application.sql # Use a little bit of awk to check that the file and its changes are matched and that the total number of lines is just 2 -result="`(git diff --compact-summary 2>/dev/null || git diff --stat) | awk -f $oracle_tools_dir/jenkins/only_create_application_changed.awk`" +result="`git diff --stat | awk -f $oracle_tools_dir/jenkins/only_create_application_changed.awk`" if [ "$result" = "YES" ] then git checkout -- $create_application From 70907fcc39000fc972fac42bb53b66d93c5e127d Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 26 Apr 2022 17:32:08 +0200 Subject: [PATCH 18/23] Update process.sh --- jenkins/process.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jenkins/process.sh b/jenkins/process.sh index c600e62f..8cec2ab4 100644 --- a/jenkins/process.sh +++ b/jenkins/process.sh @@ -1,4 +1,4 @@ -#!/bin/sh -eu +#!/bin/sh -xeu process_git() { @@ -44,7 +44,7 @@ fi test -n "$DB_ACTIONS" || export DB_ACTIONS="" test -n "$APEX_ACTIONS" || export APEX_ACTIONS="" -set -eu +set -xeu db_config_dir=`cd ${CONF_DIR} && pwd` From 56807e2a91897d5b2fba0dac393bef865ac26f14 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 3 May 2022 10:05:22 +0200 Subject: [PATCH 19/23] Ignore innocent changes of create_application.sql --- jenkins/libraries/maven/steps/process.groovy | 2 +- jenkins/only_create_application_changed.awk | 3 --- jenkins/process.sh | 16 ++++++++-------- 3 files changed, 9 insertions(+), 12 deletions(-) delete mode 100644 jenkins/only_create_application_changed.awk diff --git a/jenkins/libraries/maven/steps/process.groovy b/jenkins/libraries/maven/steps/process.groovy index 4f67d505..07ea5006 100644 --- a/jenkins/libraries/maven/steps/process.groovy +++ b/jenkins/libraries/maven/steps/process.groovy @@ -15,7 +15,7 @@ void call(app_env){ env.SCM_BRANCH = app_env.scm_branch assert env.SCM_BRANCH != null - env.SCM_BRANCH_PREV = ( app_env.previous != null ? app_env.previous.scm_branch : '' ) + env.SCM_BRANCH_PREV = ( app_env.scm_branch_prev != null ? app_env.scm_branch_prev : ( app_env.previous != null ? app_env.previous.scm_branch : '' ) ) env.SCM_CREDENTIALS = ( app_env.scm_credentials != null ? app_env.scm_credentials : pipelineConfig.scm_credentials ) assert env.SCM_CREDENTIALS != null env.SCM_URL = ( app_env.scm_url != null ? app_env.scm_url : pipelineConfig.scm_url ) diff --git a/jenkins/only_create_application_changed.awk b/jenkins/only_create_application_changed.awk deleted file mode 100644 index c9ebbd89..00000000 --- a/jenkins/only_create_application_changed.awk +++ /dev/null @@ -1,3 +0,0 @@ -/create_application\.sql/,/1 file changed, 1 insertion\(+\), 1 deletion\(-\)/ { ++m } -{ ++n } -END { if ( n == 2 && m == 2 ) { print "YES" } else { print "NO" } } diff --git a/jenkins/process.sh b/jenkins/process.sh index 8cec2ab4..5b921157 100644 --- a/jenkins/process.sh +++ b/jenkins/process.sh @@ -34,7 +34,7 @@ git config user.email ${SCM_EMAIL} set +eu # come variables may be unset -if [ -n "$SCM_BRANCH_PREV" ] +if [ -n "$SCM_BRANCH_PREV" -a "$SCM_BRANCH_PREV" != "$SCM_BRANCH" ] then git checkout "$SCM_BRANCH_PREV" git checkout "$SCM_BRANCH" @@ -77,12 +77,12 @@ for profile; do mvn -f ${APEX_DIR} -Doracle-tools.dir=$oracle_tools_dir -Ddb.con # apex/app/src/export/application/create_application.sql | 2 +- # 1 file changed, 1 insertion(+), 1 deletion(-) -create_application=${APEX_DIR}/src/export/application/create_application.sql -# Use a little bit of awk to check that the file and its changes are matched and that the total number of lines is just 2 -result="`git diff --stat | awk -f $oracle_tools_dir/jenkins/only_create_application_changed.awk`" -if [ "$result" = "YES" ] -then - git checkout -- $create_application -fi +# 1) Retrieve all create_application.sql files that have changed only in two places (one insertion, one deletion) +# 2) Restore them since the change is due to the version date change +# 3) This prohibits a git commit when the APEX export has not changed really +for create_application in "`git diff --stat -- ${APEX_DIR} | grep -E '\bcreate_application\.sql\s+\|\s+2\s+\+-$' | cut -d '|' -f 1`" +do + git checkout -- $create_application +done process_git "APEX changes" From bd0db4ed2dbbbeb4f825e4fa3c703a0b963dcaf2 Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 3 May 2022 14:22:56 +0200 Subject: [PATCH 20/23] Adding check for only create_application.sql having been changed. --- jenkins/only_create_application_changed.awk | 10 ++++++++++ jenkins/process.sh | 19 ++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 jenkins/only_create_application_changed.awk diff --git a/jenkins/only_create_application_changed.awk b/jenkins/only_create_application_changed.awk new file mode 100644 index 00000000..17cce8a8 --- /dev/null +++ b/jenkins/only_create_application_changed.awk @@ -0,0 +1,10 @@ +# % git diff --stat +# apex/app/src/export/application/create_application.sql | 2 +- +# 1 file changed, 1 insertion(+), 1 deletion(-) + +# count the number of lines with create_application.sql where there are two changes: one insertion and one deletion +/create_application\.sql[ \t\r\n]+\|[ \t\r\n]+2[ \t\r\n]+\+-$/ { ++m } +# count all lines including the last line with totals +{ ++n } +# If only create_application.sql has changed with one insertion and one deletion print YES, else NO. +END { if ( m >= 1 && m == n - 1 ) { print "YES" } else { print "NO" } } diff --git a/jenkins/process.sh b/jenkins/process.sh index 5b921157..b6009485 100644 --- a/jenkins/process.sh +++ b/jenkins/process.sh @@ -77,12 +77,17 @@ for profile; do mvn -f ${APEX_DIR} -Doracle-tools.dir=$oracle_tools_dir -Ddb.con # apex/app/src/export/application/create_application.sql | 2 +- # 1 file changed, 1 insertion(+), 1 deletion(-) -# 1) Retrieve all create_application.sql files that have changed only in two places (one insertion, one deletion) -# 2) Restore them since the change is due to the version date change -# 3) This prohibits a git commit when the APEX export has not changed really -for create_application in "`git diff --stat -- ${APEX_DIR} | grep -E '\bcreate_application\.sql\s+\|\s+2\s+\+-$' | cut -d '|' -f 1`" -do - git checkout -- $create_application -done +# Check if only create_application.sql files have changed their p_flow_version. +result="`git diff --stat -- ${APEX_DIR} | awk -f $oracle_tools_dir/jenkins/only_create_application_changed.awk`" +if [ "$result" = "YES" ] +then + # 1) Retrieve all create_application.sql files that have changed only in two places (one insertion, one deletion) + # 2) Restore them since the change is due to the version date change + # 3) This prohibits a git commit when the APEX export has not changed really + for create_application in "`git diff --stat -- ${APEX_DIR} | grep -E '\bcreate_application\.sql\s+\|\s+2\s+\+-$' | cut -d '|' -f 1`" + do + git checkout -- $create_application + done +fi process_git "APEX changes" From 0cae46535117152356f15d2bc3755cbe930dc72f Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 3 May 2022 18:27:14 +0200 Subject: [PATCH 21/23] Update process.groovy --- jenkins/libraries/maven/steps/process.groovy | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/jenkins/libraries/maven/steps/process.groovy b/jenkins/libraries/maven/steps/process.groovy index 07ea5006..203302d4 100644 --- a/jenkins/libraries/maven/steps/process.groovy +++ b/jenkins/libraries/maven/steps/process.groovy @@ -12,7 +12,7 @@ void call(app_env){ assert pipelineConfig.conf_dir != null assert pipelineConfig.db_dir != null assert pipelineConfig.apex_dir != null - + env.SCM_BRANCH = app_env.scm_branch assert env.SCM_BRANCH != null env.SCM_BRANCH_PREV = ( app_env.scm_branch_prev != null ? app_env.scm_branch_prev : ( app_env.previous != null ? app_env.previous.scm_branch : '' ) ) @@ -58,6 +58,21 @@ void call(app_env){ userRemoteConfigs: [[url: pipelineConfig.scm_url_oracle_tools]] ]) } + + script { + if (pipelineConfig.scm_url_config != null && pipelineConfig.scm_branch_config != null) { + dir('config') { + checkout([ + $class: 'GitSCM', + branches: [[name: '*/' + pipelineConfig.scm_branch_config]], + doGenerateSubmoduleConfigurations: false, + extensions: [[$class: 'CleanCheckout']], + submoduleCfg: [], + userRemoteConfigs: [[url: pipelineConfig.scm_url_config]] + ]) + } + } + } dir('myproject') { git branch: env.SCM_BRANCH, credentialsId: env.SCM_CREDENTIALS, url: env.SCM_URL From 0fe2fa038f01e34357e162a6942c4c6b664f9d7c Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Tue, 3 May 2022 18:34:07 +0200 Subject: [PATCH 22/23] Update process.groovy --- jenkins/libraries/maven/steps/process.groovy | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/jenkins/libraries/maven/steps/process.groovy b/jenkins/libraries/maven/steps/process.groovy index 203302d4..07b18bd2 100644 --- a/jenkins/libraries/maven/steps/process.groovy +++ b/jenkins/libraries/maven/steps/process.groovy @@ -60,16 +60,9 @@ void call(app_env){ } script { - if (pipelineConfig.scm_url_config != null && pipelineConfig.scm_branch_config != null) { + if (pipelineConfig.scm_url_config != null && pipelineConfig.scm_branch_config != null && pipelineConfig.scm_credentials_config != null) { dir('config') { - checkout([ - $class: 'GitSCM', - branches: [[name: '*/' + pipelineConfig.scm_branch_config]], - doGenerateSubmoduleConfigurations: false, - extensions: [[$class: 'CleanCheckout']], - submoduleCfg: [], - userRemoteConfigs: [[url: pipelineConfig.scm_url_config]] - ]) + git url: pipelineConfig.scm_url_config, branch: pipelineConfig.scm_branch_config, credentialsId: pipelineConfig.scm_credentials_config } } } From b0e62492e1f16213dfcb59066cbcbca36005fb7d Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Sat, 11 Jun 2022 18:12:29 +0200 Subject: [PATCH 23/23] Update setup.sh --- jenkins/setup.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jenkins/setup.sh b/jenkins/setup.sh index 3fc9f8ea..2a2629f7 100755 --- a/jenkins/setup.sh +++ b/jenkins/setup.sh @@ -83,7 +83,13 @@ EOF ;; 5) docker container exec -it $jenkins_name /bin/sh -c 'test -f /var/jenkins_home/.ssh/id_rsa || ssh-keygen -t rsa -f /var/jenkins_home/.ssh/id_rsa' # generate SSH keys ;; - 6) nohup open http://localhost:8080 1>/dev/null 2>&1 & + 6) url='http://localhost:8080' + if which open 1>/dev/null + then + nohup open $url 1>/dev/null 2>&1 & + else + echo "Please open $url in your browser." + fi ;; # TBD: setting up SSH agent later 7) docker container exec -it $jenkins_name /bin/sh -c 'test -f /var/jenkins_home/.ssh/jenkins_agent_key || ssh-keygen -t rsa -f /var/jenkins_home/.ssh/jenkins_agent_key' # generate SSH keys