Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jira Ticket #77

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflow/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Fetch JIRA Projects

on:
push:
branches:
- main # Runs on every push to the main branch
workflow_dispatch: # Allows manual execution

jobs:
fetch-jira:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set Up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install Dependencies
run: pip install requests

- name: Fetch JIRA Projects
env:
JIRA_TOKEN: ${{ secrets.JIRA_TOKEN }}
run: |
python - <<EOF
import requests
from requests.auth import HTTPBasicAuth
import json
import os

# JIRA API Credentials
email = "[email protected]"
api_token = os.getenv("JIRA_TOKEN")

if not api_token:
raise ValueError("JIRA_TOKEN environment variable is missing!")

url = "https://prashantsukhadeve123.atlassian.net/rest/api/3/project"
auth = HTTPBasicAuth(email, api_token)

headers = {
"Accept": "application/json"
}

response = requests.request(
"GET",
url,
headers=headers,
auth=auth
)

output = json.loads(response.text)

if response.status_code == 200:
name = output[1]["name"]
print(f"Project Name: {name}")
print(json.dumps(output, sort_keys=True, indent=4, separators=(',', ': ')))
else:
print(f"Error {response.status_code}: {response.text}")

EOF
14 changes: 14 additions & 0 deletions Day-12/prashant_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def update_server_config(file_path, key, value):
with open(file_path, "r") as file:
lines = file.readlines()


with open(file_path,"w") as file:
for line in lines:
if key in line:
file.write(key + "=" + value + "\n")
else:
file.write(line)
update_server_config("server.conf" , "PORT" ,"8080")


34 changes: 17 additions & 17 deletions Day-12/server.conf
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Server Configuration File

# Network Settings
PORT = 8080
MAX_CONNECTIONS=600
TIMEOUT = 30

# Security Settings
SSL_ENABLED = true
SSL_CERT = /path/to/certificate.pem

# Logging Settings
LOG_LEVEL = INFO
LOG_FILE = /var/log/server.log

# Other Settings
ENABLE_FEATURE_X = true
# Server Configuration File
# Network Settings
PORT = 8080
MAX_CONNECTIONS=600
TIMEOUT = 30
# Security Settings
SSL_ENABLED = true
SSL_CERT = /path/to/certificate.pem
# Logging Settings
LOG_LEVEL = INFO
LOG_FILE = /var/log/server.log
# Other Settings
ENABLE_FEATURE_X = true
26 changes: 26 additions & 0 deletions Day-14/jira.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This code sample uses the 'requests' library:
# http://docs.python-requests.org
import requests
from requests.auth import HTTPBasicAuth
import json

url = "https://prashantsukhadeve123.atlassian.net/rest/api/3/project"

auth = HTTPBasicAuth("[email protected]", "JIRA_TOKEN")

headers = {
"Accept": "application/json"
}

response = requests.request(
"GET",
url,
headers=headers,
auth=auth
)
output = json.loads(response.text)
name = output[1]["name"]
print (name)

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

67 changes: 67 additions & 0 deletions Day-15/prashant-Jiraticket-automation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# This code sample uses the 'requests' library:
# http://docs.python-requests.org
import requests
from requests.auth import HTTPBasicAuth
import json
from flask import Flask

app = Flask(__name__)

# Define a route that handles GET requests
@app.route('/createJira', methods=['POST'])
def createJira():


url = "https://prashantsukhadeve123.atlassian.net/rest/api/3/project"




auth = HTTPBasicAuth("[email protected]", "<Please add jira account token here")

headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}

payload = json.dumps( {
"fields": {
"description": {
"content": [
{
"content": [
{
"text": "Order entry fails when selecting supplier.",
"type": "text"
}
],
"type": "paragraph"
}
],
"type": "doc",
"version": 1
},
"project": {
"key": "SCRUM"
},
"issuetype": {
"id": "10003"
},
"summary": "Main order flow broken",
},
"update": {}
} )


response = requests.request(
"POST",
url,
data=payload,
headers=headers,
auth=auth
)

return json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": "))

if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Python Zero to Hero for DevOps Engineers
# Python Zero to Hero for DevOps Engineers.......

<img width="1141" alt="Screenshot 2023-10-12 at 9 57 40 PM" src="https://github.com/iam-veeramalla/python-for-devops/assets/43399466/d70f5fe2-0ba3-449d-b41f-413a38fc4584">

Expand Down