diff --git a/.github/scripts/mainframe_operations.sh b/.github/scripts/mainframe_operations.sh index 0db3b02..f2c16af 100644 --- a/.github/scripts/mainframe_operations.sh +++ b/.github/scripts/mainframe_operations.sh @@ -50,7 +50,7 @@ run_cobolcheck() { # Copy the JCL file if it exists if [ -f "${program}.JCL" ]; then - if cp ${program}.JCL "//'${ZOWE_USERNAME}.JCL($program)'"; then + if cp ${program}.JCL "//'Z36963.JCL($program)'"; then echo "Copied ${program}.JCL to ${ZOWE_USERNAME}.JCL($program)" else echo "Failed to copy ${program}.JCL to ${ZOWE_USERNAME}.JCL($program)" @@ -58,6 +58,38 @@ run_cobolcheck() { else echo "${program}.JCL not found" fi + # Submit job + if [ -f "${program}.JCL" ]; then + echo "Submitting job for $program" + job_id=$(zowe jobs submit data-set "Z36963.JCL($program)" --rff jobid --rft string) + if [ $? -eq 0 ]; then + echo "Job submitted successfully. Job ID: $job_id" + + # Check job status + echo "Checking job status..." + for i in {1..10}; do # Try 10 times, waiting 5 seconds between each attempt + status=$(zowe jobs view job-status-by-jobid "$job_id" --rff status --rft string) + echo "Current status: $status" + if [[ "$status" == "OUTPUT" ]]; then + echo "Job completed. Fetching output..." + zowe jobs view sfbi "$job_id" 2 + break + elif [[ "$status" == "ABEND" || "$status" == "CANCELED" ]]; then + echo "Job failed with status: $status" + break + fi + sleep 5 + done + + if [[ "$status" != "OUTPUT" && "$status" != "ABEND" && "$status" != "CANCELED" ]]; then + echo "Job did not complete within the expected time. Last known status: $status" + fi + else + echo "Failed to submit job for $program" + fi + else + echo "JCL file for $program not found. Job not submitted." + fi } # Run for each program