Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
b9b42cb
commit1
rohanmane21 Sep 6, 2023
7c80755
Create my_script.py
rohanmane21 Sep 6, 2023
cfef905
Create my_script2.py
rohanmane21 Sep 6, 2023
f74b44b
Create Jenkinsfile
rohanmane21 Sep 7, 2023
bb8249d
Update Jenkinsfile
rohanmane21 Sep 7, 2023
f708bca
Update Jenkinsfile
rohanmane21 Sep 7, 2023
4dc8590
Update Jenkinsfile
rohanmane21 Sep 7, 2023
7d7bd4a
Update Jenkinsfile
rohanmane21 Sep 7, 2023
89256e6
Update Jenkinsfile
rohanmane21 Sep 7, 2023
3e67b88
Update Jenkinsfile
rohanmane21 Sep 7, 2023
914d5ea
Update Jenkinsfile
rohanmane21 Sep 7, 2023
b8de771
Update Jenkinsfile
rohanmane21 Sep 7, 2023
2dd0448
Update Jenkinsfile
rohanmane21 Sep 7, 2023
8eafb36
Update Jenkinsfile
rohanmane21 Sep 7, 2023
87d4d02
Update Jenkinsfile
rohanmane21 Sep 7, 2023
7fda932
Create create_instance
rohanmane21 Sep 8, 2023
6398242
Create Jenkinsfile
rohanmane21 Sep 8, 2023
161b19a
Create jenkins.pem
rohanmane21 Sep 8, 2023
a0198f0
Update
rohanmane21 Sep 11, 2023
88eb07b
Update Jenkinsfile
rohanmane21 Sep 11, 2023
b412956
Update Jenkinsfile
rohanmane21 Sep 11, 2023
e90ce87
Update Jenkinsfile
rohanmane21 Sep 11, 2023
9fb4887
Update Jenkinsfile
rohanmane21 Sep 11, 2023
22aca30
Update Jenkinsfile
rohanmane21 Sep 11, 2023
fe2b8a6
Update Jenkinsfile
rohanmane21 Sep 11, 2023
9c4388a
Update create_instance.py
rohanmane21 Sep 11, 2023
b289f7e
Update Jenkinsfile
rohanmane21 Sep 11, 2023
5a3fbd5
Update create_instance.py
rohanmane21 Sep 11, 2023
72f2251
Update create_instance.py
rohanmane21 Sep 11, 2023
b1c422b
Update create_instance.py
rohanmane21 Sep 11, 2023
f7cb390
Update Jenkinsfile
rohanmane21 Sep 11, 2023
0430636
Update Jenkinsfile
rohanmane21 Sep 11, 2023
890e135
Update Jenkinsfile
rohanmane21 Sep 11, 2023
70460f3
Update Jenkinsfile
rohanmane21 Sep 11, 2023
5d930c3
Update Jenkinsfile
rohanmane21 Sep 11, 2023
35387ae
Update create_instance.py
rohanmane21 Sep 11, 2023
7760031
Update Jenkinsfile
rohanmane21 Sep 11, 2023
6d85b43
Update Jenkinsfile
rohanmane21 Sep 11, 2023
4bc7e40
Update Jenkinsfile
rohanmane21 Sep 11, 2023
839e8d3
Update create_instance.py
rohanmane21 Sep 11, 2023
c01a4fe
Update Jenkinsfile
rohanmane21 Sep 11, 2023
c40d8a0
Update Jenkinsfile
rohanmane21 Sep 11, 2023
449b164
Update Jenkinsfile
rohanmane21 Sep 11, 2023
8ef67b5
Update Jenkinsfile
rohanmane21 Sep 11, 2023
81b9549
Update Jenkinsfile
rohanmane21 Sep 11, 2023
73f3d71
Update Jenkinsfile
rohanmane21 Sep 11, 2023
483b54b
Update Jenkinsfile
rohanmane21 Sep 14, 2023
04c8dd6
Create policy.py
rohanmane21 Sep 14, 2023
944b80a
Create policy.json
rohanmane21 Sep 14, 2023
f5b33d5
Create Jenkinsfile
rohanmane21 Sep 14, 2023
9625c08
Update policy.json
rohanmane21 Sep 14, 2023
9ccf5a0
Update policy.json
rohanmane21 Sep 14, 2023
6a2f8a9
Update policy.py
rohanmane21 Sep 14, 2023
eb94590
Update Jenkinsfile
rohanmane21 Sep 14, 2023
43f3501
Update policy.py
rohanmane21 Sep 14, 2023
7acbd55
Update policy.py
rohanmane21 Sep 14, 2023
c14cf4d
Update policy.py
rohanmane21 Sep 14, 2023
7af036c
Update policy.py
rohanmane21 Sep 14, 2023
4c6f5af
Update policy.py
rohanmane21 Sep 14, 2023
7276709
Update policy.py
rohanmane21 Sep 14, 2023
0988727
Update policy.py
rohanmane21 Sep 14, 2023
2e1c276
Update policy.py
rohanmane21 Sep 14, 2023
51541b7
Create Jenkinsfile
rohanmane21 Sep 14, 2023
454a8d3
Create Jenkinsfile
rohanmane21 Sep 14, 2023
c747b9e
Create Jenkinsfile
rohanmane21 Sep 14, 2023
f9e38c1
Update and rename Jenkinsfile to Jenkinsfile.py
rohanmane21 Sep 14, 2023
d10c3f5
Update and rename Jenkinsfile to Jenkinsfile.py
rohanmane21 Sep 14, 2023
8677642
Update Jenkinsfile.py
rohanmane21 Sep 14, 2023
8beb209
Update and rename Jenkinsfile to Jenkinsfile.py
rohanmane21 Sep 14, 2023
2e8a1e5
Update Jenkinsfile.py
rohanmane21 Sep 14, 2023
cccdf4a
Create policy.json
rohanmane21 Sep 14, 2023
daa5d18
Create Jenkinsfile
rohanmane21 Sep 14, 2023
5958c33
Update Jenkinsfile
rohanmane21 Sep 14, 2023
9887447
Rename Jenkinsfile.py to create_policy.py
rohanmane21 Sep 14, 2023
791b4bf
Create Jenkinsfile
rohanmane21 Sep 14, 2023
0891605
Rename Jenkinsfile.py to create_user.py
rohanmane21 Sep 14, 2023
f3cfade
Create Jenkinsfile
rohanmane21 Sep 14, 2023
62ce27b
Update Jenkinsfile
rohanmane21 Sep 14, 2023
e480068
Rename Jenkinsfile.py to map.py
rohanmane21 Sep 14, 2023
f3fe60f
Create Jenkinsfile
rohanmane21 Sep 14, 2023
044b0ba
Update Jenkinsfile
rohanmane21 Sep 14, 2023
1871ab9
Update Jenkinsfile
rohanmane21 Sep 14, 2023
70de0ed
Update Jenkinsfile
rohanmane21 Sep 14, 2023
2a81bf5
Update Jenkinsfile
rohanmane21 Sep 14, 2023
61125cf
Create Jenkinsfile
rohanmane21 Sep 15, 2023
d985b7c
Create sent_email.py
rohanmane21 Sep 15, 2023
0d551ff
Create failed.py
rohanmane21 Sep 15, 2023
836b016
Rename sent_email.py to success.py
rohanmane21 Sep 15, 2023
4f5b5f5
Update success.py
rohanmane21 Sep 15, 2023
61b270d
Update failed.py
rohanmane21 Sep 15, 2023
a9fead6
Update success.py
rohanmane21 Sep 15, 2023
bda1f0f
Update Jenkinsfile
rohanmane21 Sep 15, 2023
8dfbbbc
Update success.py
rohanmane21 Sep 15, 2023
1679ef3
Update failed.py
rohanmane21 Sep 15, 2023
bdcf5f7
Update Jenkinsfile
rohanmane21 Sep 15, 2023
462263d
Update Jenkinsfile
rohanmane21 Sep 15, 2023
8eea8a7
Update Jenkinsfile
rohanmane21 Sep 15, 2023
2ec2c0e
Update Jenkinsfile
rohanmane21 Sep 15, 2023
c3289af
Update Jenkinsfile
rohanmane21 Sep 15, 2023
359dbea
Update Jenkinsfile
rohanmane21 Nov 28, 2023
e9ceb31
Update Jenkinsfile
rohanmane21 Nov 28, 2023
5dde5d8
Update Jenkinsfile
rohanmane21 Nov 28, 2023
e582755
Update Jenkinsfile
rohanmane21 Nov 28, 2023
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
37 changes: 37 additions & 0 deletions Gmail/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
pipeline {
agent any

environment {
AWS_DEFAULT_REGION = 'ap-south-1'
AWS_ACCESS_KEY_ID = credentials('admin')
IAM_USERNAME = 'new55'
GIT_REPO_URL = 'https://github.com/rohanmane21/Python.git'
}
stages{
stage('Adding git credentials'){
steps {
script {
git branch: 'Testing', credentialsId: 'Git-Token', url: env.GIT_REPO_URL
}
}
}
stage('Create IAM User') {
steps {
script {
sh """
aws iam create-user --user-name ${env.IAM_USERNAME}
"""
}
}
}
}
post{
success{
sh'python Gmail/success.py '
}
failure{
sh'python Gmail/failed.py '
}
}
}

28 changes: 28 additions & 0 deletions Gmail/failed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# Gmail account details
gmail_user = 'rohan4562002@gmail.com' # Your Gmail address
gmail_app_password = 'D3E0A81974662ABDCDDAF2E377A98D973E98' # Use the App Password generated earlier
# Email details
to_email = 'hr@technobrilliant.com' # Recipient's email address
subject = 'Rohan Mane'
message = 'Pipeline Failed.'
# Create a MIMEText object with your message
msg = MIMEMultipart()
msg['From'] = gmail_user
msg['To'] = to_email
msg['Subject'] = subject
msg.attach(MIMEText(message, 'plain'))
# Connect to Gmail's SMTP server
try:
server = smtplib.SMTP('smtp.elasticemail.com', 2525)
server.starttls()
server.login(gmail_user, gmail_app_password)
# Send the email
server.sendmail(gmail_user, to_email, msg.as_string())
print('Email sent successfully!')
except Exception as e:
print(f'Error: {str(e)}')
finally:
server.quit()
28 changes: 28 additions & 0 deletions Gmail/success.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# Gmail account details
gmail_user = 'rohan4562002@gmail.com' # Your Gmail address
gmail_app_password = 'D3E0A81974662ABDCDDAF2E377A98D973E98' # Use the App Password generated earlier
# Email details
to_email = 'hr@technobrilliant.com' # Recipient's email address
subject = 'Rohan Mane'
message = 'Pipeline run successful.'
# Create a MIMEText object with your message
msg = MIMEMultipart()
msg['From'] = gmail_user
msg['To'] = to_email
msg['Subject'] = subject
msg.attach(MIMEText(message, 'plain'))
# Connect to Gmail's SMTP server
try:
server = smtplib.SMTP('smtp.elasticemail.com', 2525)
server.starttls()
server.login(gmail_user, gmail_app_password)
# Send the email
server.sendmail(gmail_user, to_email, msg.as_string())
print('Email sent successfully!')
except Exception as e:
print(f'Error: {str(e)}')
finally:
server.quit()
13 changes: 13 additions & 0 deletions create_policy/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pipeline {
agent any
stages {
stage('Create Policy') {
steps {
withAWS(credentials: 'admin', region: 'ap-south-1')
{
sh 'python create_policy/create_policy.py'
}
}
}
}
}
12 changes: 12 additions & 0 deletions create_policy/create_policy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import boto3
import json

user = boto3.client('iam')
def create_policy():
with open('pipeline4/policy.json', 'r') as f:
policy_document = json.load(f)
response = user.create_policy(
PolicyName="All_Policy",
PolicyDocument=json.dumps(policy_document)
)
# create_policy()
13 changes: 13 additions & 0 deletions create_policy/policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Statement1",
"Effect": "Allow",
"Action": [
"ec2:*"
],
"Resource": "arn:aws:ec2:::*"
}
]
}
13 changes: 13 additions & 0 deletions create_user/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pipeline {
agent any
stages {
stage('Create IAM User') {
steps {
withAWS(credentials: 'admin', region: 'ap-south-1')
{
sh 'python create_user/create_user.py'
}
}
}
}
}
10 changes: 10 additions & 0 deletions create_user/create_user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import boto3
import json

user = boto3.client('iam')

def create_user():
response = user.create_user(
UserName='boburao'
)
create_user()
13 changes: 13 additions & 0 deletions map_policy/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pipeline {
agent any
stages {
stage('Create Policy') {
steps {
withAWS(credentials: 'admin', region: 'ap-south-1')
{
sh 'python map_policy/map.py'
}
}
}
}
}
11 changes: 11 additions & 0 deletions map_policy/map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

import boto3
import json

user = boto3.client('iam')
def attach_policy():
response = user.attach_user_policy(
UserName= 'boburao',
PolicyArn='arn:aws:iam::190616427825:policy/All_Policy'
)
attach_policy()
35 changes: 35 additions & 0 deletions pipeline1/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
pipeline {
agent any

stages {
stage('Checkout') {
steps {
// This step checks out your source code from the repository.
// If your Jenkinsfile and Python script are in the same folder, it will be checked out here.
checkout scm
}
}

stage('Run Python Script') {
steps {
script {
// Assuming your Python script is named 'my_script.py'

// Execute the Python script using the 'sh' step
// You may need to specify the Python interpreter if it's not in the PATH
sh 'python my_script.py'
}
}
}
}

post {
success {
echo 'Python script ran successfully'
}

failure {
echo 'Python script execution failed'
}
}
}
1 change: 1 addition & 0 deletions pipeline1/my_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("Hello World")
1 change: 1 addition & 0 deletions pipeline1/my_script2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("Hello")
31 changes: 31 additions & 0 deletions pipeline2/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
pipeline {
agent any

stages {
stage('Clone Repository') {
steps {
// Define the Git repository URL and credentials (if required)
script {
def gitRepoUrl = 'https://github.com/rohanmane21/Python.git'
def gitCredentialsId = 'Git-Token' // Optional, if using credentials

// Clone the repository
checkout([$class: 'GitSCM',
branches: [[name: '*/Testing']],
doGenerateSubmoduleConfigurations: false,
extensions: [],
userRemoteConfigs: [[credentialsId: gitCredentialsId, url: gitRepoUrl]]
])
}
}
}

stage("Run Python file"){
steps{
sh 'python test.py'
}
}// Add more stages for building, testing, deploying, etc.
}

// Post-build actions, notifications, etc.
}
82 changes: 82 additions & 0 deletions pipeline3/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
pipeline {
agent any
stages {
stage('test AWS credentials') {
steps {
withAWS(credentials: 'admin', region: 'ap-south-1')
{
sh 'python pipeline3/create_instance.py'
}
}
}
}
}
// pipeline {
// agent any
// stages {
// stage('Example') {
// steps {
// script {
// withCredentials([[$class: 'AmazonWebServicesCredentialsBinding',
// credentialsId: 'admin',
// accessKeyVariable: 'AKIASYYM73UY4Q7QQNWO',
// secretKeyVariable: 'KmmFRTfbmn0r3d+FRZAo0BGcUrQpSEx6pM+UYTkK']]) {
// sh 'aws ec2 describe-instances --region ap-south-1'

// }
// }
// }
// }
// }
// }
// pipeline {
// agent any


// stages {
// stage('Clone Repository') {
// steps {
// // Define the Git repository URL and credentials (if required)
// script {
// def gitRepoUrl = 'https://github.com/rohanmane21/Python.git'
// def gitCredentialsId = 'admin' // Optional, if using credentials
// sh 'aws ec2 describe-instances --region ap-south-1' // Clone the repository
// checkout([$class: 'GitSCM',
// branches: [[name: '*/Testing']],
// doGenerateSubmoduleConfigurations: false,
// extensions: [],
// userRemoteConfigs: [[credentialsId: gitCredentialsId, url: gitRepoUrl]]
// ])
// }
// }
// }
// stage('Checkout') {
// steps {
// checkout scm
// }
// }

// stage('Create EC2 Instance') {
// steps {
// sh 'python pipeline3/create_instance.py'
// }
// }
// }
// }
// al we created.

// pipeline {
// agent any
// stages {
// stage('test AWS credentials') {
// steps {
// withAWS(credentials: 'jenkins-test-user', region: 'us-east-1') {
// sh 'echo "hello Jenkins">hello.txt'
// s3Upload acl: 'Private', bucket: 'devopslee', file: 'hello.txt'
// s3Download bucket: 'devopslee', file: 'downloadedHello.txt', path: 'hello.txt'
// sh 'cat downloadedHello.txt'
// }
// }
// }
// }
// }
38 changes: 38 additions & 0 deletions pipeline3/create_instance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import boto3

# # Get environment variables
# import os
# AWS_ACCESS_KEY_ID = os.environ.get('AKIASYYM73UY4Q7QQNWO')
# AWS_SECRET_ACCESS_KEY = os.environ.get('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')
# AWS_REGION = os.environ.get('ap-south-1' )
# Create an EC2 client
ec2 = boto3.client('ec2')
# , region_name=AWS_REGION, aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY)

# Define EC2 instance parameters
instance_params = {
'ImageId': 'ami-02bb7d8191b50f4bb',
'InstanceType': 't2.micro',
'KeyName': 'jenkins',
'MinCount': 1,
'MaxCount': 1,
'TagSpecifications':[
{
'ResourceType': 'instance',
'Tags':[
{
'Key':'Name',
'Value':'Ec2_user'
},
]
},
]
}

# Create the EC2 instance
response = ec2.run_instances(**instance_params)

# Print the instance ID
instance_id = response['Instances'][0]['InstanceId']
print(f"EC2 instance created with ID: {instance_id}")

Loading