diff --git a/README.md b/README.md index 100452f8541..58545c0f74e 100644 --- a/README.md +++ b/README.md @@ -18,4 +18,4 @@ Documentation Want to contribute to MAS Command Line Interface? ------------------------------------------------------------------------------- We welcome every Maximo Application Suite users, developers and enthusiasts to contribute to the MAS Command Line Interface while fixing code issues and implementing new automated functionalities. -You can contribute to this collection by raising [a new issue](https://github.com/ibm-mas/cli/issues) with suggestions on how to make our MAS automation engine even better, or if you want to become a new code contributor, please refer to the [Contributing Guidelines](CONTRIBUTING.md) and learn more about how to get started. \ No newline at end of file +You can contribute to this collection by raising [a new issue](https://github.com/ibm-mas/cli/issues) with suggestions on how to make our MAS automation engine even better, or if you want to become a new code contributor, please refer to the [Contributing Guidelines](CONTRIBUTING.md) and learn more about how to get started. diff --git a/image/cli/app-root/src/run-playbook.sh b/image/cli/app-root/src/run-playbook.sh index b97ec26ba76..0e657ff1db6 100644 --- a/image/cli/app-root/src/run-playbook.sh +++ b/image/cli/app-root/src/run-playbook.sh @@ -16,7 +16,32 @@ source /opt/app-root/src/env.sh python3 /opt/app-root/src/register-start.py +# Capture the playbook name for notification +PLAYBOOK_NAME="$1" + +# Send Slack start notification if configured +if [ -n "$SLACK_TOKEN" ] && [ -n "$SLACK_CHANNEL" ]; then + python3 /opt/app-root/bin/mas-devops-notify-slack \ + --action ansible-start \ + --task-name "$DEVOPS_SUITE_NAME" \ + --pipeline-name "${PIPELINERUN_NAME:-unknown}" \ + --instance-id "${DEVOPS_ENVIRONMENT:-}" || true + echo "# ----------------- Sending Start Notification Suite: $DEVOPS_SUITE_NAME | pipeline: $PIPELINE_NAME($PIPELINERUN_NAME) | Instance id: $DEVOPS_ENVIRONMENT -------------------- #" +fi + ansible-playbook ibm.mas_devops."$@" rc=$? + +# Send Slack completion notification if configured +if [ -n "$SLACK_TOKEN" ] && [ -n "$SLACK_CHANNEL" ]; then + python3 /opt/app-root/bin/mas-devops-notify-slack \ + --action ansible-complete \ + --rc $rc \ + --task-name "$DEVOPS_SUITE_NAME" \ + --pipeline-name "${PIPELINERUN_NAME:-unknown}" \ + --instance-id "${DEVOPS_ENVIRONMENT:-}" || true + echo "# ----------------- Sending Start Notification Suite: $DEVOPS_SUITE_NAME | pipeline: $PIPELINE_NAME($PIPELINERUN_NAME) | Instance id: $DEVOPS_ENVIRONMENT -------------------- #" +fi + python3 /opt/app-root/src/save-junit-to-mongo.py exit $rc diff --git a/image/cli/app-root/src/run-role.sh b/image/cli/app-root/src/run-role.sh index 4bd182b237c..3783ed2a311 100644 --- a/image/cli/app-root/src/run-role.sh +++ b/image/cli/app-root/src/run-role.sh @@ -15,7 +15,30 @@ python3 /opt/app-root/src/register-start.py export ROLE_NAME=$1 shift + +# Send Slack start notification if configured +if [ -n "$SLACK_TOKEN" ] && [ -n "$SLACK_CHANNEL" ]; then + python3 /opt/app-root/bin/mas-devops-notify-slack \ + --action ansible-start \ + --task-name "$DEVOPS_SUITE_NAME" \ + --pipeline-name "${PIPELINERUN_NAME:-unknown}" \ + --instance-id "${DEVOPS_ENVIRONMENT:-}" || true + echo "# ----------------- Sending Start Notification Suite: $DEVOPS_SUITE_NAME | pipeline: $PIPELINE_NAME($PIPELINERUN_NAME) | Instance id: $DEVOPS_ENVIRONMENT -------------------- #" +fi + ansible-playbook ibm.mas_devops.run_role $@ rc=$? + +# Send Slack completion notification if configured +if [ -n "$SLACK_TOKEN" ] && [ -n "$SLACK_CHANNEL" ]; then + python3 /opt/app-root/bin/mas-devops-notify-slack \ + --action ansible-complete \ + --rc $rc \ + --task-name "$DEVOPS_SUITE_NAME" \ + --pipeline-name "${PIPELINERUN_NAME:-unknown}" \ + --instance-id "${DEVOPS_ENVIRONMENT:-}" || true + echo "# ----------------- Sending Stop Notification Suite: $DEVOPS_SUITE_NAME | pipeline: $PIPELINE_NAME($PIPELINERUN_NAME) | Instance id: $DEVOPS_ENVIRONMENT -------------------- #" +fi + python3 /opt/app-root/src/save-junit-to-mongo.py exit $rc diff --git a/image/cli/app-root/src/update-pipeline-status.py b/image/cli/app-root/src/update-pipeline-status.py index abbf0e924f5..e98945a829b 100755 --- a/image/cli/app-root/src/update-pipeline-status.py +++ b/image/cli/app-root/src/update-pipeline-status.py @@ -8,17 +8,62 @@ import os import sys +import subprocess from datetime import datetime, UTC from pymongo import MongoClient -if __name__ == "__main__": - if "DEVOPS_MONGO_URI" not in os.environ or os.environ['DEVOPS_MONGO_URI'] == "": - sys.exit(0) - print("MongoDb integration enabled (v2 data model)") +def send_slack_notification(action, pipeline_name, instance_id, rc=0): + """ + Send Slack notification for pipeline start or completion using CLI command. - # Initialize the properties we need + Args: + action: Either 'pipeline-start' or 'pipeline-complete' + pipeline_name: Name of the pipeline + instance_id: MAS instance ID + rc: Return code (0 for success, non-zero for failure) + """ + slack_token = os.getenv("SLACK_TOKEN", "") + slack_channel = os.getenv("SLACK_CHANNEL", "") + + if not slack_token or not slack_channel: + return + + try: + print(f"Sending Slack notification: action={action}, pipeline={pipeline_name}, instance={instance_id}") + + if action == "pipeline-start": + cmd = [ + "python3", "/opt/app-root/bin/mas-devops-notify-slack", + "--action", "pipeline-start", + "--instance-id", instance_id, + "--pipeline-name", pipeline_name + ] + elif action == "pipeline-complete": + cmd = [ + "python3", "/opt/app-root/bin/mas-devops-notify-slack", + "--action", "pipeline-complete", + "--rc", str(rc), + "--instance-id", instance_id, + "--pipeline-name", pipeline_name + ] + else: + print(f"Unknown action: {action}") + return + + # Run the command, ignore errors (|| true equivalent) + result = subprocess.run(cmd, capture_output=True, text=True) + if result.returncode == 0: + print("Slack notification sent successfully") + else: + print(f"Slack notification command failed (ignored): {result.stderr}") + + except Exception as e: + print(f"Error sending Slack notification (ignored): {e}") + +if __name__ == "__main__": + # Initialize the properties we need # Note: We don't use MAS_INSTANCE_ID to remove the confusion between when a role actually # needs MAS_INSTANCE_ID and when we are providing it just for the reporting framework instanceId = os.getenv("DEVOPS_ENVIRONMENT", "") @@ -28,11 +73,40 @@ pipelineRunName = os.getenv("PIPELINERUN_NAME", "") pipelineRunNamespace = os.getenv("PIPELINERUN_NAMESPACE", "") - if "" in [instanceId, build, pipelineName, pipelineStatus, pipelineRunName, pipelineRunNamespace]: - print("Pipeline status not recorded because one or more required env vars are not set") - sys.exit(0) + # ========================================================================= + # Slack Notification Logic (runs independently) + # ========================================================================= + SLACK_TOKEN = os.getenv("SLACK_TOKEN", "") + SLACK_CHANNEL = os.getenv("SLACK_CHANNEL", "") - runId = f"{instanceId}:{build}" + if SLACK_TOKEN and SLACK_CHANNEL: + print("\nSlack integration enabled") + + if "" in [instanceId, pipelineName, pipelineRunName, pipelineStatus]: + print("Slack notification skipped: one or more required env vars are not set") + elif pipelineName not in ["mas-install", "mas-update", "mas-upgrade", "mas-uninstall"]: + print(f"No slack notifications for pipeline: {pipelineName}") + else: + if pipelineStatus == "Started": + print("Sending pipeline start notification to Slack...") + send_slack_notification("pipeline-start", pipelineRunName, instanceId) + + elif pipelineStatus in ["Completed", "Succeeded"]: + print("Sending pipeline completion (success) notification to Slack...") + send_slack_notification("pipeline-complete", pipelineRunName, instanceId, rc=0) + + elif pipelineStatus == "Failed": + print("Sending pipeline completion (failure) notification to Slack...") + send_slack_notification("pipeline-complete", pipelineRunName, instanceId, rc=1) + else: + print("\nSlack integration disabled (SLACK_TOKEN or SLACK_CHANNEL not set)") + + # ========================================================================= + # MongoDB Integration Logic (runs independently) + # ========================================================================= + if "DEVOPS_MONGO_URI" not in os.environ or os.environ['DEVOPS_MONGO_URI'] == "": + print("\nMongoDb integration disabled (DEVOPS_MONGO_URI not set)") + sys.exit(0) print(f"Instance ID .............. {instanceId}") print(f"Build .................... {build}") @@ -41,6 +115,14 @@ print(f"PipelineRun Namespace .... {pipelineRunNamespace}") print(f"Status ................... {pipelineStatus}") + print("\nMongoDb integration enabled (v2 data model)") + + if "" in [instanceId, build, pipelineName, pipelineStatus, pipelineRunName, pipelineRunNamespace]: + print("Pipeline status not recorded because one or more required env vars are not set") + sys.exit(0) + + runId = f"{instanceId}:{build}" + # Connect to mongoDb client = MongoClient(os.getenv("DEVOPS_MONGO_URI")) db = client.masfvt @@ -55,16 +137,19 @@ f"pipelines.{pipelineName}.status": "Started", f"pipelines.{pipelineName}.timestamp": datetime.now(UTC) } + elif pipelineStatus in ["Completed", "Succeeded"]: updates = { f"pipelines.{pipelineName}.status": "Completed", f"pipelines.{pipelineName}.timestampFinished": datetime.now(UTC) } + elif pipelineStatus == "Failed": updates = { f"pipelines.{pipelineName}.status": "Failed", f"pipelines.{pipelineName}.timestampFinished": datetime.now(UTC) } + else: print("Unexpected state detected") sys.exit(0) @@ -85,3 +170,5 @@ }, upsert=True ) + + print("Pipeline status recorded in MongoDB successfully") diff --git a/image/cli/mascli/functions/internal/save_config b/image/cli/mascli/functions/internal/save_config index d20732bde93..33766a9a05d 100644 --- a/image/cli/mascli/functions/internal/save_config +++ b/image/cli/mascli/functions/internal/save_config @@ -252,5 +252,9 @@ export MAS_MANUAL_CERT_MGMT=$MAS_MANUAL_CERT_MGMT # Guided Tour export MAS_ENABLE_WALKME=$MAS_ENABLE_WALKME +# Slack +export SLACK_TOKEN=$SLACK_TOKEN +export SLACK_CHANNEL=$SLACK_CHANNEL + EOF } diff --git a/python/Makefile b/python/Makefile index f4ddc7166c3..1cffe1ca4bf 100644 --- a/python/Makefile +++ b/python/Makefile @@ -24,4 +24,3 @@ lint: venv pyinstaller: venv rm -f README.rst . .venv/bin/activate && pyinstaller src/mas-upgrade --onefile --noconfirm --add-data="src/mas/devops/templates/ibm-mas-tekton.yaml:mas/devops/templates" --add-data="src/mas/devops/templates/subscription.yml.j2:mas/devops/templates/" --add-data="src/mas/devops/templates/pipelinerun-upgrade.yml.j2:mas/devops/templates/" - diff --git a/python/src/mas/cli/aiservice/install/app.py b/python/src/mas/cli/aiservice/install/app.py index 4d0bb5f3aac..827e115c1fa 100644 --- a/python/src/mas/cli/aiservice/install/app.py +++ b/python/src/mas/cli/aiservice/install/app.py @@ -493,7 +493,9 @@ def install(self, argv): slsLicenseFile=self.slsLicenseFileSecret, additionalConfigs=self.additionalConfigsSecret, podTemplates=self.podTemplatesSecret, - certs=self.certsSecret + certs=self.certsSecret, + slack_token=self.getParam("slack_token"), + slack_channel=self.getParam("slack_channel") ) self.setupApprovals(pipelinesNamespace) diff --git a/python/src/mas/cli/aiservice/install/params.py b/python/src/mas/cli/aiservice/install/params.py index 83efc7697ee..e2050315db0 100644 --- a/python/src/mas/cli/aiservice/install/params.py +++ b/python/src/mas/cli/aiservice/install/params.py @@ -106,4 +106,8 @@ # Enable IPv6 networking "enable_ipv6", + + # Slack + "slack_token", + "slack_channel", ] diff --git a/python/src/mas/cli/aiservice/install/summarizer.py b/python/src/mas/cli/aiservice/install/summarizer.py index bd114e54cb8..75cb435ca56 100644 --- a/python/src/mas/cli/aiservice/install/summarizer.py +++ b/python/src/mas/cli/aiservice/install/summarizer.py @@ -110,6 +110,13 @@ def mongoSummary(self) -> None: else: self.fatalError(f"Unexpected value for mongodb_action parameter: {self.getParam('mongodb_action')}") + def slackSummary(self) -> None: + self.printH2("Slack Integration") + if self.getParam("slack_channel") != "": + self.printParamSummary("Slack Channel", "slack_channel") + else: + self.printSummary("Slack Channel", "Not Configured") + def displayInstallSummary(self) -> None: self.printH1("Review Settings") self.printDescription([ @@ -129,3 +136,6 @@ def displayInstallSummary(self) -> None: self.slsSummary() self.mongoSummary() self.db2Summary() + + # Notification Integration + self.slackSummary() diff --git a/python/src/mas/cli/install/app.py b/python/src/mas/cli/install/app.py index e1395166975..3fcc22d11fc 100644 --- a/python/src/mas/cli/install/app.py +++ b/python/src/mas/cli/install/app.py @@ -2120,7 +2120,9 @@ def install(self, argv): slsLicenseFile=self.slsLicenseFileSecret, additionalConfigs=self.additionalConfigsSecret, podTemplates=self.podTemplatesSecret, - certs=self.certsSecret + certs=self.certsSecret, + slack_token=self.getParam("slack_token"), + slack_channel=self.getParam("slack_channel") ) self.setupApprovals(pipelinesNamespace) diff --git a/python/src/mas/cli/install/argBuilder.py b/python/src/mas/cli/install/argBuilder.py index eeb9891f69d..8208eb2ce62 100644 --- a/python/src/mas/cli/install/argBuilder.py +++ b/python/src/mas/cli/install/argBuilder.py @@ -579,6 +579,11 @@ def buildCommand(self) -> str: if self.getParam('approval_aiservice') != "": command += f" --approval-aiservice \"{self.getParam('approval_aiservice')}\"{newline}" + # Slack + # ----------------------------------------------------------------------------- + if self.getParam('slack_channel') != "" and self.getParam('slack_token'): + command += f" --slack-channel \"{self.getParam('slack_channel')}\" --slack-token $SLACK_TOKEN{newline}" + # More Options # ----------------------------------------------------------------------------- if self.devMode: diff --git a/python/src/mas/cli/install/argParser.py b/python/src/mas/cli/install/argParser.py index ff0134a245c..c11601e8ea4 100644 --- a/python/src/mas/cli/install/argParser.py +++ b/python/src/mas/cli/install/argParser.py @@ -1581,6 +1581,18 @@ def isValidFile(parser: argparse.ArgumentParser, arg: str) -> str: default=False, help="Don't show advanced install options (in interactive mode)" ) +otherArgGroup.add_argument( + "--slack-token", + dest="slack_token", + required=False, + help="Slack bot token for sending pipeline notifications" +) +otherArgGroup.add_argument( + "--slack-channel", + dest="slack_channel", + required=False, + help="Slack channel(s) for notifications (comma-separated for multiple channels)" +) otherArgGroup.add_argument( "--accept-license", diff --git a/python/src/mas/cli/install/params.py b/python/src/mas/cli/install/params.py index 187dfd90546..19784de1b4e 100644 --- a/python/src/mas/cli/install/params.py +++ b/python/src/mas/cli/install/params.py @@ -221,5 +221,9 @@ # Grafana "skip_grafana_install", "grafana_v5_namespace", - "grafana_instance_storage_size" + "grafana_instance_storage_size", + + # Slack Integration + "slack_token", + "slack_channel" ] diff --git a/python/src/mas/cli/install/summarizer.py b/python/src/mas/cli/install/summarizer.py index 3de50649aac..9a2d57f1991 100644 --- a/python/src/mas/cli/install/summarizer.py +++ b/python/src/mas/cli/install/summarizer.py @@ -411,6 +411,13 @@ def grafanaSummary(self) -> None: else: self.printSummary("Install Grafana", "Do Not Install") + def slackSummary(self) -> None: + self.printH2("Slack Integration") + if self.getParam("slack_channel") != "": + self.printParamSummary("Slack Channel", "slack_channel") + else: + self.printSummary("Slack Channel", "Not Configured") + def installSummary(self) -> None: pass # self.printH2("Install Process") @@ -451,5 +458,8 @@ def displayInstallSummary(self) -> None: self.cp4dSummary() self.grafanaSummary() + # Notification Integration + self.slackSummary() + # Install options self.installSummary() diff --git a/python/src/mas/cli/uninstall/app.py b/python/src/mas/cli/uninstall/app.py index 464a55390f0..d15686296e0 100644 --- a/python/src/mas/cli/uninstall/app.py +++ b/python/src/mas/cli/uninstall/app.py @@ -39,6 +39,10 @@ def uninstall(self, argv): droNamespace = args.dro_namespace self.noConfirm = args.no_confirm + # Set image_pull_policy if provided + if args.image_pull_policy and args.image_pull_policy != "": + self.setParam("image_pull_policy", args.image_pull_policy) + if args.uninstall_all_deps: uninstallGrafana = True uninstallIBMCatalog = True diff --git a/python/src/mas/cli/uninstall/argParser.py b/python/src/mas/cli/uninstall/argParser.py index 4048bdb48a9..e187cbc523c 100644 --- a/python/src/mas/cli/uninstall/argParser.py +++ b/python/src/mas/cli/uninstall/argParser.py @@ -13,6 +13,8 @@ from .. import __version__ as packageVersion from ..cli import getHelpFormatter +IMAGE_PULL_POLICIES = ["IfNotPresent", "Always"] + uninstallArgParser = argparse.ArgumentParser( prog='mas uninstall', description="\n".join([ @@ -101,6 +103,24 @@ default=False, help="Launch the upgrade without prompting for confirmation", ) +otherArgGroup.add_argument( + '--slack-token', + required=False, + help="Slack bot token for sending pipeline status notifications" +) +otherArgGroup.add_argument( + '--slack-channel', + required=False, + help="Slack channel(s) for pipeline notifications (comma-separated for multiple channels)" +) +otherArgGroup.add_argument( + "--image-pull-policy", + dest="image_pull_policy", + required=False, + help="Image pull policy for Tekton Pipeline", + choices=IMAGE_PULL_POLICIES, + metavar="{IfNotPresent,Always}" +) otherArgGroup.add_argument( '-h', "--help", action='help', diff --git a/python/src/mas/cli/update/app.py b/python/src/mas/cli/update/app.py index fdedb98a10e..47e4b23722f 100644 --- a/python/src/mas/cli/update/app.py +++ b/python/src/mas/cli/update/app.py @@ -23,7 +23,7 @@ from mas.devops.ocp import createNamespace, getConsoleURL, getClusterVersion, isClusterVersionInRange from mas.devops.mas import listMasInstances, getCurrentCatalog from mas.devops.aiservice import listAiServiceInstances -from mas.devops.tekton import preparePipelinesNamespace, installOpenShiftPipelines, updateTektonDefinitions, launchUpdatePipeline +from mas.devops.tekton import preparePipelinesNamespace, installOpenShiftPipelines, updateTektonDefinitions, launchUpdatePipeline, prepareUpdateSlackSecrets logger = logging.getLogger(__name__) @@ -57,9 +57,13 @@ def update(self, argv): "skip_pre_check", "dev_mode", "cpd_product_version", + "image_pull_policy", # Dev Mode "artifactory_username", - "artifactory_token" + "artifactory_token", + # Slack Integration + "slack_token", + "slack_channel" ] for key, value in vars(self.args).items(): @@ -201,6 +205,16 @@ def update(self, argv): preparePipelinesNamespace(dynClient=self.dynamicClient) h.stop_and_persist(symbol=self.successIcon, text=f"Namespace is ready ({pipelinesNamespace})") + # Create slack secret if slack token and channel are provided + if self.getParam("slack_token") and self.getParam("slack_channel"): + with Halo(text='Creating Slack notification secret', spinner=self.spinner) as h: + prepareUpdateSlackSecrets( + dynClient=self.dynamicClient, + slack_token=self.getParam("slack_token"), + slack_channel=self.getParam("slack_channel") + ) + h.stop_and_persist(symbol=self.successIcon, text="Slack notification secret created") + with Halo(text=f'Installing latest Tekton definitions (v{self.version})', spinner=self.spinner) as h: updateTektonDefinitions(pipelinesNamespace, self.tektonDefsPath) h.stop_and_persist(symbol=self.successIcon, text=f"Latest Tekton definitions are installed (v{self.version})") diff --git a/python/src/mas/cli/update/argParser.py b/python/src/mas/cli/update/argParser.py index 8487cd892e9..b7dfeacc535 100644 --- a/python/src/mas/cli/update/argParser.py +++ b/python/src/mas/cli/update/argParser.py @@ -13,6 +13,8 @@ from ..cli import getHelpFormatter +IMAGE_PULL_POLICIES = ["IfNotPresent", "Always"] + class UpdateArgumentParser(argparse.ArgumentParser): """Custom argument parser that validates --catalog requirement""" @@ -208,6 +210,24 @@ def parse_args(self, args=None, namespace=None): # type: ignore[override] default=False, help="Skips the 'pre-update-check' and 'post-update-verify' tasks in the update pipeline", ) +otherArgGroup.add_argument( + '--slack-token', + required=False, + help="Slack bot token for sending pipeline status notifications" +) +otherArgGroup.add_argument( + '--slack-channel', + required=False, + help="Slack channel(s) for pipeline notifications (comma-separated for multiple channels)" +) +otherArgGroup.add_argument( + "--image-pull-policy", + dest="image_pull_policy", + required=False, + help="Image pull policy for Tekton Pipeline", + choices=IMAGE_PULL_POLICIES, + metavar="{IfNotPresent,Always}" +) otherArgGroup.add_argument( '-h', "--help", action='help', diff --git a/python/src/mas/cli/upgrade/app.py b/python/src/mas/cli/upgrade/app.py index c00a89b822f..ff8a9598d93 100644 --- a/python/src/mas/cli/upgrade/app.py +++ b/python/src/mas/cli/upgrade/app.py @@ -79,6 +79,10 @@ def upgrade(self, argv): self.nextChannel = args.next_channel self.devMode = args.dev_mode + # Set image_pull_policy if provided + if args.image_pull_policy and args.image_pull_policy != "": + self.setParam("image_pull_policy", args.image_pull_policy) + if instanceId is None: self.printH1("Set Target OpenShift Cluster") # Connect to the target cluster diff --git a/python/src/mas/cli/upgrade/argParser.py b/python/src/mas/cli/upgrade/argParser.py index 697c8e48207..b56e93beb4f 100644 --- a/python/src/mas/cli/upgrade/argParser.py +++ b/python/src/mas/cli/upgrade/argParser.py @@ -13,6 +13,8 @@ from .. import __version__ as packageVersion from ..cli import getHelpFormatter +IMAGE_PULL_POLICIES = ["IfNotPresent", "Always"] + upgradeArgParser = argparse.ArgumentParser( prog='mas upgrade', description="\n".join([ @@ -72,6 +74,24 @@ default="", help="The Target Mas channel to Upgrade on" ) +otherArgGroup.add_argument( + '--slack-token', + required=False, + help="Slack bot token for sending pipeline status notifications" +) +otherArgGroup.add_argument( + '--slack-channel', + required=False, + help="Slack channel(s) for pipeline notifications (comma-separated for multiple channels)" +) +otherArgGroup.add_argument( + "--image-pull-policy", + dest="image_pull_policy", + required=False, + help="Image pull policy for Tekton Pipeline", + choices=IMAGE_PULL_POLICIES, + metavar="{IfNotPresent,Always}" +) otherArgGroup.add_argument( '-h', "--help", action='help', diff --git a/python/test/install/test_dev_mode.py b/python/test/install/test_dev_mode.py index 90b666559b4..01afdccf777 100644 --- a/python/test/install/test_dev_mode.py +++ b/python/test/install/test_dev_mode.py @@ -525,4 +525,73 @@ def test_install_master_dev_mode_non_interactive_with_path_routing(tmpdir): # Run the test run_install_test(tmpdir, config) + +def test_install_master_dev_mode_non_interactive_with_slack(tmpdir): + """Test non-interactive installation with Slack notification parameters. + + This test verifies that slack_token and slack_channel parameters are properly + handled in non-interactive mode and passed through to the pipeline configuration. + """ + + # Define prompt handlers - should be empty for non-interactive mode + prompt_handlers = {} + + # Create test configuration with Slack parameters + config = InstallTestConfig( + prompt_handlers=prompt_handlers, + current_catalog=None, # No catalog installed + architecture='amd64', + is_sno=False, + is_airgap=False, + storage_class_name='nfs-client', + storage_provider='nfs', + storage_provider_name='NFS Client', + ocp_version='4.18.0', + timeout_seconds=30, + argv=[ + "--dev-mode", + "--artifactory-username", "ARTIFACTORY_USERNAME", + "--artifactory-token", "ARTIFACTORY_TOKEN", + "--mas-catalog-version", "v9-master-amd64", + "--mas-instance-id", "fvtcore", + "--mas-workspace-id", "masdev", + "--mas-workspace-name", "MAS Development", + "--superuser-username", "MAS_SUPERUSER_USERNAME", + "--superuser-password", "MAS_SUPERUSER_PASSWORD", + "--mas-channel", "9.2.x-dev", + "--iot-channel", "9.2.x-dev", + "--db2-system", "--kafka-provider", "strimzi", + "--manage-channel", "9.2.x-dev", + "--manage-components", "", + "--db2-manage", "--manage-jdbc", "workspace-application", + "--cos", "ibm", + "--cos-resourcegroup", "fvt-layer3", + "--cos-apikey", "IBMCLOUD_APIKEY", + "--cos-instance-name", "Object Storage for MAS - fvtcore", + "--cos-bucket-name", "fvtcore-masdev-bucket-20260209-0209", + "--db2-channel", "rotate", + "--skip-grafana-install", + "--additional-configs", f"{tmpdir}", + "--storage-class-rwx", "ibmc-file-gold-gid", + "--storage-class-rwo", "ibmc-block-gold", + "--storage-pipeline", "ibmc-file-gold-gid", + "--storage-accessmode", "ReadWriteMany", + "--ibm-entitlement-key", "IBM_ENTITLEMENT_KEY", + "--license-file", f"{tmpdir}/authorized_entitlement.lic", + "--uds-email", "iotf@uk.ibm.com", + "--uds-firstname", "First", + "--uds-lastname", "Last", + "--sls-namespace", "sls-fvtcore", + "--sls-channel", "3.x-dev", + # Slack notification parameters + "--slack-token", "xoxb-test-slack-token-12345", + "--slack-channel", "mas-notifications,mas-alerts", + "--accept-license", + "--no-confirm", + ] + ) + # Run the test + run_install_test(tmpdir, config) + run_install_test(tmpdir, config) + # Made with Bob diff --git a/python/test/test_slack_params.py b/python/test/test_slack_params.py new file mode 100644 index 00000000000..35a8ec55e7d --- /dev/null +++ b/python/test/test_slack_params.py @@ -0,0 +1,57 @@ +# ***************************************************************************** +# Copyright (c) 2026 IBM Corporation and other Contributors. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# ***************************************************************************** + +""" +Test suite to verify Slack integration parameters are properly configured. + +This test ensures that slack_token and slack_channel parameters are included +in the optionalParams list for the install command, allowing them to be passed +through to Tekton pipelines for Slack notifications. +""" + +from mas.cli.install.params import optionalParams + + +class TestSlackParameters: + """Test that Slack parameters are properly configured""" + + def test_slack_token_in_optional_params(self): + """Verify slack_token is in the optionalParams list""" + assert "slack_token" in optionalParams, \ + "slack_token should be in optionalParams to support Slack notifications" + + def test_slack_channel_in_optional_params(self): + """Verify slack_channel is in the optionalParams list""" + assert "slack_channel" in optionalParams, \ + "slack_channel should be in optionalParams to support Slack notifications" + + def test_slack_params_are_optional(self): + """Verify Slack parameters are optional (not required)""" + from mas.cli.install.params import requiredParams + + assert "slack_token" not in requiredParams, \ + "slack_token should be optional, not required" + assert "slack_channel" not in requiredParams, \ + "slack_channel should be optional, not required" + + def test_slack_params_documentation(self): + """Document the purpose of Slack parameters""" + # This test serves as documentation + slack_params_doc = { + "slack_token": "OAuth token for Slack API authentication (optional)", + "slack_channel": "Comma-separated list of Slack channels for notifications (optional)" + } + + # Verify both parameters exist + for param, description in slack_params_doc.items(): + assert param in optionalParams, \ + f"{param} should be in optionalParams. Purpose: {description}" + +# Made with Bob diff --git a/tekton/src/params/common.yml.j2 b/tekton/src/params/common.yml.j2 index fe3e70199a6..20459f66aa4 100644 --- a/tekton/src/params/common.yml.j2 +++ b/tekton/src/params/common.yml.j2 @@ -20,6 +20,16 @@ - name: custom_labels type: string default: "" + +# Slack Notifications +- name: slack_token + type: string + default: "" + description: Slack bot token for sending pipeline notifications +- name: slack_channel + type: string + default: "" + description: Slack channel(s) for notifications (comma-separated for multiple channels) description: Optional custom labels, comma separated list of key=value pairs {% if application is not defined %} diff --git a/tekton/src/pipelines/mas-uninstall.yml.j2 b/tekton/src/pipelines/mas-uninstall.yml.j2 index 9fdfa9b95bd..9ba7b6568cc 100644 --- a/tekton/src/pipelines/mas-uninstall.yml.j2 +++ b/tekton/src/pipelines/mas-uninstall.yml.j2 @@ -81,7 +81,14 @@ spec: value: $(params.image_pull_policy) - name: configmap_name value: approval-uninstall - + - name: pipeline_status + value: Started + - name: pipeline_name + value: $(context.pipeline.name) + - name: pipelinerun_name + value: $(context.pipelineRun.name) + - name: pipelinerun_namespace + value: $(context.pipelineRun.namespace) # 1. Uninstall IBM Maximo Application Suite Applications # ------------------------------------------------------------------------- @@ -94,6 +101,7 @@ spec: kind: Task name: mas-devops-suite-app-uninstall params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_app_id @@ -110,6 +118,7 @@ spec: kind: Task name: mas-devops-suite-app-uninstall params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_app_id @@ -126,6 +135,7 @@ spec: kind: Task name: mas-devops-suite-app-uninstall params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_app_id @@ -142,6 +152,7 @@ spec: kind: Task name: mas-devops-suite-app-uninstall params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_app_id @@ -158,6 +169,7 @@ spec: kind: Task name: mas-devops-suite-app-uninstall params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_app_id @@ -174,6 +186,7 @@ spec: kind: Task name: mas-devops-suite-app-uninstall params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_app_id @@ -190,6 +203,7 @@ spec: kind: Task name: mas-devops-suite-app-uninstall params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_app_id @@ -206,6 +220,7 @@ spec: kind: Task name: mas-devops-suite-app-uninstall params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_app_id @@ -229,8 +244,7 @@ spec: kind: Task name: mas-devops-suite-uninstall params: - - name: image_pull_policy - value: $(params.image_pull_policy) + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_wipe_mongo_data @@ -244,8 +258,7 @@ spec: - name: uninstall-sls timeout: "0" params: - - name: image_pull_policy - value: $(params.image_pull_policy) + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: sls_action value: $(params.sls_action) - name: devops_suite_name @@ -266,8 +279,7 @@ spec: - name: uninstall-mongodb timeout: "0" params: - - name: image_pull_policy - value: $(params.image_pull_policy) + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mongodb_action value: $(params.mongodb_action) - name: devops_suite_name @@ -288,8 +300,7 @@ spec: - name: uninstall-dro timeout: "0" params: - - name: image_pull_policy - value: $(params.image_pull_policy) + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: dro_action value: $(params.dro_action) - name: dro_namespace @@ -312,8 +323,7 @@ spec: - name: uninstall-cert-manager timeout: "0" params: - - name: image_pull_policy - value: $(params.image_pull_policy) + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: cert_manager_action value: $(params.cert_manager_action) - name: cert_manager_provider @@ -336,8 +346,7 @@ spec: - name: uninstall-ibm-catalogs timeout: "0" params: - - name: image_pull_policy - value: $(params.image_pull_policy) + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: ibm_catalogs_action value: $(params.ibm_catalogs_action) - name: devops_suite_name @@ -358,8 +367,7 @@ spec: - name: uninstall-grafana timeout: "0" params: - - name: image_pull_policy - value: $(params.image_pull_policy) + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: grafana_action value: $(params.grafana_action) - name: devops_suite_name diff --git a/tekton/src/pipelines/mas-update.yml.j2 b/tekton/src/pipelines/mas-update.yml.j2 index 95b219a0395..ce20b8eaf40 100644 --- a/tekton/src/pipelines/mas-update.yml.j2 +++ b/tekton/src/pipelines/mas-update.yml.j2 @@ -173,6 +173,14 @@ spec: value: $(params.image_pull_policy) - name: configmap_name value: approval-update + - name: pipeline_status + value: Started + - name: pipeline_name + value: $(context.pipeline.name) + - name: pipelinerun_name + value: $(context.pipelineRun.name) + - name: pipelinerun_namespace + value: $(context.pipelineRun.namespace) {{ lookup('template', 'taskdefs/cluster-setup/ocp-verify-all.yml.j2', template_vars={'name': 'pre-update-check', 'devops_suite_name': 'pre-update-check'}) | indent(4) }} runAfter: @@ -189,6 +197,7 @@ spec: runAfter: - pre-update-check params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: devops_suite_name value: update-catalog - name: mas_catalog_version @@ -221,6 +230,7 @@ spec: runAfter: - post-update-verify params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: devops_suite_name value: update-ocs - name: ocs_action @@ -238,6 +248,7 @@ spec: runAfter: - post-update-verify params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: grafana_action value: update - name: devops_suite_name @@ -255,6 +266,7 @@ spec: runAfter: - post-update-verify params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: devops_suite_name value: dependencies-rhoai-migration @@ -266,6 +278,7 @@ spec: runAfter: - post-update-verify params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: devops_suite_name value: update-db2 - name: db2_action @@ -281,6 +294,7 @@ spec: runAfter: - post-update-verify params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: devops_suite_name value: update-mongodb - name: mongodb_action @@ -308,6 +322,7 @@ spec: runAfter: - post-update-verify params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: devops_suite_name value: update-kafka - name: kafka_action @@ -356,6 +371,7 @@ spec: runAfter: - post-update-verify params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: aiservice_instance_ids value: $(params.aiservice_instance_ids) diff --git a/tekton/src/pipelines/mas-upgrade.yml.j2 b/tekton/src/pipelines/mas-upgrade.yml.j2 index 7a0a7bcba97..5b8ea20d244 100644 --- a/tekton/src/pipelines/mas-upgrade.yml.j2 +++ b/tekton/src/pipelines/mas-upgrade.yml.j2 @@ -44,6 +44,14 @@ spec: value: $(params.image_pull_policy) - name: configmap_name value: approval-upgrade + - name: pipeline_status + value: Started + - name: pipeline_name + value: $(context.pipeline.name) + - name: pipelinerun_name + value: $(context.pipelineRun.name) + - name: pipelinerun_namespace + value: $(context.pipelineRun.namespace) {{ lookup('template', 'taskdefs/cluster-setup/ocp-verify-all.yml.j2', template_vars={'name': 'pre-upgrade-check', 'devops_suite_name': 'pre-upgrade-check'}) | indent(4) }} runAfter: @@ -60,6 +68,7 @@ spec: runAfter: - pre-upgrade-check params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_channel @@ -72,6 +81,7 @@ spec: - name: core-verify timeout: "0" params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_channel @@ -169,6 +179,7 @@ spec: - name: app-manage-upgrade timeout: "0" params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_app_id @@ -194,6 +205,7 @@ spec: - name: app-monitor-upgrade-before-iot timeout: "0" params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_app_id @@ -219,6 +231,7 @@ spec: - name: app-iot-upgrade-after-monitor timeout: "0" params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_app_id @@ -244,6 +257,7 @@ spec: - name: app-iot-upgrade timeout: "0" params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_app_id @@ -269,6 +283,7 @@ spec: - name: app-visualinspection-upgrade timeout: "0" params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_app_id @@ -291,6 +306,7 @@ spec: - name: app-assist-upgrade timeout: "0" params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_app_id @@ -313,6 +329,7 @@ spec: - name: app-optimizer-upgrade timeout: "0" params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_app_id @@ -334,6 +351,7 @@ spec: - name: app-monitor-upgrade timeout: "0" params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_app_id @@ -359,6 +377,7 @@ spec: - name: app-predict-upgrade timeout: "0" params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} - name: mas_instance_id value: $(params.mas_instance_id) - name: mas_app_id diff --git a/tekton/src/pipelines/taskdefs/common/cli-params.yml.j2 b/tekton/src/pipelines/taskdefs/common/cli-params.yml.j2 index e3f2d2911ca..a717732b2b0 100644 --- a/tekton/src/pipelines/taskdefs/common/cli-params.yml.j2 +++ b/tekton/src/pipelines/taskdefs/common/cli-params.yml.j2 @@ -1,3 +1,11 @@ # Controls the image pull policy for the ibmmas/cli image - name: image_pull_policy value: $(params.image_pull_policy) + +# Pipeline context information +- name: pipelinerun_namespace + value: $(context.pipelineRun.namespace) +- name: pipelinerun_name + value: $(context.pipelineRun.name) +- name: pipeline_name + value: $(context.pipeline.name) diff --git a/tekton/src/tasks/common/cli-env-nosuitename.yml.j2 b/tekton/src/tasks/common/cli-env-nosuitename.yml.j2 index 52a744384b2..7c0d216ed7a 100644 --- a/tekton/src/tasks/common/cli-env-nosuitename.yml.j2 +++ b/tekton/src/tasks/common/cli-env-nosuitename.yml.j2 @@ -13,6 +13,24 @@ - name: DEVOPS_ENVIRONMENT valueFrom: secretKeyRef: - name: mas-devops + name: mas-devops-slack key: MAS_INSTANCE_ID optional: true +- name: SLACK_TOKEN + valueFrom: + secretKeyRef: + name: mas-devops-slack + key: SLACK_TOKEN + optional: true +- name: SLACK_CHANNEL + valueFrom: + secretKeyRef: + name: mas-devops-slack + key: SLACK_CHANNEL + optional: true +- name: PIPELINE_NAMESPACE + value: $(params.pipelinerun_namespace) +- name: PIPELINERUN_NAME + value: $(params.pipelinerun_name) +- name: PIPELINE_NAME + value: $(params.pipeline_name) diff --git a/tekton/src/tasks/common/cli-env.yml.j2 b/tekton/src/tasks/common/cli-env.yml.j2 index 44e71a2c635..c3880cf3ed6 100644 --- a/tekton/src/tasks/common/cli-env.yml.j2 +++ b/tekton/src/tasks/common/cli-env.yml.j2 @@ -13,8 +13,26 @@ - name: DEVOPS_ENVIRONMENT valueFrom: secretKeyRef: - name: mas-devops + name: mas-devops-slack key: MAS_INSTANCE_ID optional: true - name: DEVOPS_SUITE_NAME value: $(params.devops_suite_name) +- name: SLACK_TOKEN + valueFrom: + secretKeyRef: + name: mas-devops-slack + key: SLACK_TOKEN + optional: true +- name: SLACK_CHANNEL + valueFrom: + secretKeyRef: + name: mas-devops-slack + key: SLACK_CHANNEL + optional: true +- name: PIPELINE_NAMESPACE + value: $(params.pipelinerun_namespace) +- name: PIPELINERUN_NAME + value: $(params.pipelinerun_name) +- name: PIPELINE_NAME + value: $(params.pipeline_name) diff --git a/tekton/src/tasks/common/cli-params.yml.j2 b/tekton/src/tasks/common/cli-params.yml.j2 index 38dbd229f24..87b0864353f 100644 --- a/tekton/src/tasks/common/cli-params.yml.j2 +++ b/tekton/src/tasks/common/cli-params.yml.j2 @@ -8,3 +8,17 @@ type: string description: Optional name for the junit suite, used to enable save-junit-to-mongo.py default: "" + +# Common: Pipeline context information (passed from Pipeline) +- name: pipelinerun_namespace + type: string + description: Namespace where the pipeline is running + default: "" +- name: pipelinerun_name + type: string + description: Name of the PipelineRun + default: "" +- name: pipeline_name + type: string + description: Name of the Pipeline + default: "" \ No newline at end of file diff --git a/tekton/src/tasks/framework/update-pipeline-status.yml.j2 b/tekton/src/tasks/framework/update-pipeline-status.yml.j2 index 81c70b4c9be..f8f97114d01 100644 --- a/tekton/src/tasks/framework/update-pipeline-status.yml.j2 +++ b/tekton/src/tasks/framework/update-pipeline-status.yml.j2 @@ -5,6 +5,9 @@ metadata: name: mas-devops-update-pipeline-status spec: params: + - name: image_pull_policy + type: string + default: IfNotPresent - name: pipeline_status type: string description: "Started = started, Succeeded = all tasks succeeded. Completed = all tasks succeeded, including one or more skipped. Any other value is treated as a failure" @@ -20,6 +23,7 @@ spec: steps: - name: update-pipeline-status image: quay.io/ibmmas/cli:latest + imagePullPolicy: $(params.image_pull_policy) command: - /opt/app-root/src/update-pipeline-status.py env: @@ -38,9 +42,21 @@ spec: - name: DEVOPS_ENVIRONMENT valueFrom: secretKeyRef: - name: mas-devops + name: mas-devops-slack key: MAS_INSTANCE_ID optional: true + - name: SLACK_TOKEN + valueFrom: + secretKeyRef: + name: mas-devops-slack + key: SLACK_TOKEN + optional: true + - name: SLACK_CHANNEL + valueFrom: + secretKeyRef: + name: mas-devops-slack + key: SLACK_CHANNEL + optional: true - name: PIPELINE_STATUS value: $(params.pipeline_status) - name: PIPELINE_NAME diff --git a/tekton/src/tasks/framework/wait-for-configmap-v2.yml.j2 b/tekton/src/tasks/framework/wait-for-configmap-v2.yml.j2 index 3f382177e6c..ac3ae716da5 100644 --- a/tekton/src/tasks/framework/wait-for-configmap-v2.yml.j2 +++ b/tekton/src/tasks/framework/wait-for-configmap-v2.yml.j2 @@ -5,6 +5,9 @@ metadata: name: mas-devops-wait-for-configmap-v2 spec: params: + - name: image_pull_policy + type: string + default: IfNotPresent - name: configmap_namespace type: string description: "The namespace of the configmap to wait for" @@ -24,14 +27,31 @@ spec: # Optional escape route - name: escape_configmap_name type: string - description: "The name of the configmap wait for" + description: "The name of the configmap to wait for" + default: "" + + # Pipeline context information + - name: pipeline_status + type: string + description: "Pipeline status" + default: "" + - name: pipeline_name + type: string + description: "Name of the Pipeline" + default: "" + - name: pipelinerun_name + type: string + description: "Name of the PipelineRun" default: "" - description: "The key in the configmap to watch for" + - name: pipelinerun_namespace + type: string + description: "Namespace of the PipelineRun" default: "" steps: - name: wait-for-configmap image: quay.io/ibmmas/cli:latest + imagePullPolicy: $(params.image_pull_policy) command: - /opt/app-root/src/wait-for-configmap.sh env: @@ -70,3 +90,30 @@ spec: name: $(params.configmap_name) key: IGNORE_FAILURE optional: true + + - name: DEVOPS_ENVIRONMENT + valueFrom: + secretKeyRef: + name: mas-devops-slack + key: MAS_INSTANCE_ID + optional: true + - name: SLACK_TOKEN + valueFrom: + secretKeyRef: + name: mas-devops-slack + key: SLACK_TOKEN + optional: true + - name: SLACK_CHANNEL + valueFrom: + secretKeyRef: + name: mas-devops-slack + key: SLACK_CHANNEL + optional: true + - name: PIPELINE_STATUS + value: $(params.pipeline_status) + - name: PIPELINE_NAME + value: $(params.pipeline_name) + - name: PIPELINERUN_NAME + value: $(params.pipelinerun_name) + - name: PIPELINERUN_NAMESPACE + value: $(params.pipelinerun_namespace) diff --git a/tekton/src/tasks/fvt/mas-fvt-pipeline-finish-and-deprovision.yml.j2 b/tekton/src/tasks/fvt/mas-fvt-pipeline-finish-and-deprovision.yml.j2 index 9e7d692c099..9a114ea0456 100644 --- a/tekton/src/tasks/fvt/mas-fvt-pipeline-finish-and-deprovision.yml.j2 +++ b/tekton/src/tasks/fvt/mas-fvt-pipeline-finish-and-deprovision.yml.j2 @@ -8,19 +8,10 @@ spec: # Common CLI parameters (required by cli-env.yml.j2) {{ lookup('template', task_src_dir ~ '/common/cli-params.yml.j2') | indent(4) }} - # Pipeline status parameters + # Pipeline status parameter (pipeline_name, pipelinerun_name, pipelinerun_namespace are in cli-params.yml.j2) - name: pipeline_status type: string description: "tasks.status value: Succeeded, Failed, Completed, or None" - - name: pipeline_name - type: string - description: "Provide the name of the pipeline" - - name: pipelinerun_name - type: string - description: "Provide the name of the pipelinerun" - - name: pipelinerun_namespace - type: string - description: "Provide the namespace of the pipelinerun" # Deprovision control parameter - name: deprovision @@ -51,7 +42,7 @@ spec: - name: DEVOPS_ENVIRONMENT valueFrom: secretKeyRef: - name: mas-devops + name: mas-devops-slack key: MAS_INSTANCE_ID optional: true - name: PIPELINE_STATUS