This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| colors = ["cyan", "magenta", "yellow", "black"] | |
| # ❌ | |
| for i in range(len(colors)): | |
| print(f"{i} --> {colors[i]}") | |
| # ✔️ | |
| for i, color in enumerate(colors): | |
| print(f"{i} --> {color}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| colors = ["cyan", "magenta", "yellow", "black"] | |
| # ❌ | |
| for i in range(len(colors) - 1, -1, -1): | |
| print(colors[i]) | |
| # ✔️ | |
| for color in reversed(colors): | |
| print(color) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| colors = ["cyan", "magenta", "yellow", "black"] | |
| # ❌ | |
| for i in range(len(colors)): | |
| print(colors[i]) | |
| # ✔️ | |
| for color in colors: | |
| print(color) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ❌ | |
| i = 0 | |
| while i < 6: | |
| print(i) | |
| i += 1 | |
| # ❌ | |
| for i in [0, 1, 2, 3, 4, 5]: | |
| print(i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| stage('Use the Zowe CLI Image in Jenkins') { | |
| agent { | |
| docker { | |
| image 'zowe-cli:latest' | |
| label 'docker' // Use a label that is used by Jenkins agents with Docker | |
| args '--cap-add ipc_lock' // This capability is needed for the Secure Credential Store | |
| registryUrl 'https://docker.artifactory.acme.net/' | |
| registryCredentialsId 'artifactoryCredentials' | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM node:16 | |
| # Directory where Zowe CLI settings and plug-ins will be stored: | |
| RUN mkdir /zowe | |
| WORKDIR /zowe | |
| ENV ZOWE_CLI_HOME=/zowe | |
| # Install requirements of Zowe CLI Secure Credential Store: | |
| RUN DEBIAN_FRONTEND=noninteractive apt update | |
| RUN DEBIAN_FRONTEND=noninteractive apt install -y libsecret-1-dev gnome-keyring dbus-x11 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| echo "Called with: $@" > zowe-init.log | |
| if [[ "$1" == "zowe-init" || "$1" == "cat" ]]; then | |
| # Start the gnome keyring daemon when a bash session is initialized (requires passing `--privileged` or `--cap-add ipc_lock` when calling `docker run`): | |
| [ -z "$GNOME_KEYRING_CONTROL" ] && RND=$(openssl rand -base64 32) && eval $(echo "$RND" | gnome-keyring-daemon --unlock --components=secrets >> zowe-init.log | sed -e "s/^/export /g") | |
| # Calling Zowe CLI to initialize daemon mode: | |
| zowe --version >> zowe-init.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| prefix = "'ZWE*'" | |
| owner = "ZOWUSER" | |
| for job in zowe(f"zos-jobs list jobs --prefix {prefix} --owner {owner}"): | |
| if job['retcode'] not in ['CC 0000', None]: | |
| print(f"{job['jobname']} {job['jobid']} {job['retcode']}") | |
| for spool_file in zowe(f"zos-jobs list spool-files-by-jobid {job['jobid']}"): | |
| if spool_file['ddname'] == 'SYSOUT': | |
| sysout = zowe(f"zos-jobs view spool-file-by-id {job['jobid']} {spool_file['id']}") | |
| print(sysout) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import subprocess | |
| import json | |
| class ZoweCallError(Exception): | |
| def __init__(self, returncode, cmd, arguments, output=None, stderr=None): | |
| self.cmd = cmd | |
| self.arguments = arguments | |
| self.returncode = returncode | |
| self.output = self.stdout = output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import subprocess | |
| import json | |
| def zowe(arguments): | |
| zowe_command = "zowe " + arguments + " --rfj" | |
| try: | |
| completed_process = subprocess.run(zowe_command, shell=True, capture_output=True, check=True, encoding="utf8") | |
| parsed_output = json.loads(completed_process.stdout) | |
| return parsed_output.get("data", parsed_output) |