- Go back to Jenkins and select your terraform pipeline and click Configure
- Scroll down to Pipeline and click on the drop down to select Pipeline Script From SCM
- Enter credentials for Bitbucket, Leave the Branch master as the default, Make sure script path is Jenkinsfile
- Right click on Pipeline Syntax and open in a new tab.
- Choose Checkout from Version Control in the Sample Step field
- Enter Bitbucket Repository URL and Credentials, leave the branches blank
- Click GENERATE PIPELINE SCRIPT, copy credentialsId and url (This is required for Jenkinsfile script)
Open File Explorer, navigate to Desktop and create a folder cd_pipeline
Once folder has been created, open Visual Code Studio and add folder to workspace
- Open a New Terminal
- Run the command before cloning repo: git init
- Navigate to terraform-pipeline repo in Bitbucket
- Clone the repo with SSH or HTTPS
Create a new file main.tf and copy the below code in yellow color
- Create a new file security.tf and copy the below code in yellow color
name = "u2-${var.environment}-sg-${var.application}"
description = "EC2 SG"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 8081
to_port = 8081
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
from_port = 8082
to_port = 8082
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
#Allow all outbound
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
- Create a new file variable.tf and copy the below code in yellow color.
Bash Script to Deploy Artifactory
- Create a new file deploy.sh and copy the below code in yellow color.
- Create a new file Jenkinsfile and copy the below code in yellow color.
- Commit and push code changes to Repo with the following:
- In Vscode, navigate to Source Code Icon on the right tabs on the side
- Enter commit message
- Click the + icon to stage changes
- Push changes by clicking on the 🔄0 ⬇️ 1 ⬆️ as shown below
- Go to terraform-pipeline on Jenkins and run build
- Enter Artifactory in the AppName field
- Select a Branch/Lifecycle to deploy server
- Choose t2.small or t2.medium for Artifactory server.
- Go to Console Output to track progress
Install Proper Graph Plugin
If graph still doesn’t show, install:
Recommended Modern Plugin:
Plugin ID:
Go to:
Search:
Install and restart.












