-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decouple behaviours to main script && Fix paths && update deps
- Loading branch information
1 parent
182d946
commit 0cd33c2
Showing
14 changed files
with
236 additions
and
178 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
python-jenkins~=1.8.2 | ||
setuptools~=68.2.0 | ||
requests~=2.32.3 | ||
urllib3~=2.2.3 | ||
urllib3~=2.2.3 | ||
python-dotenv~=1.0.1 |
File renamed without changes.
This file contains 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
Empty file.
This file contains 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
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,65 @@ | ||
import os | ||
|
||
import src.local.main.config as config_module | ||
import src.local.main.services as services | ||
from src.local.main.services import CredentialsType | ||
import config as config_module | ||
import services as services | ||
from services import CredentialsType | ||
|
||
try: | ||
print(f"JENKINS INFO -> Jenkins URL: {config_module.get(config_module.ConfigKeys.JENKINS_URL)}, Username: {config_module.get(config_module.ConfigKeys.JENKINS_USER)}, API Token: {config_module.get(config_module.ConfigKeys.JENKINS_PASS)}") | ||
def fetch(): | ||
try: | ||
print(f"JENKINS INFO -> Jenkins URL: {config_module.get(config_module.ConfigKeys.JENKINS_URL)}, Username: {config_module.get(config_module.ConfigKeys.JENKINS_USER)}, API Token: {config_module.get(config_module.ConfigKeys.JENKINS_PASS)}") | ||
|
||
# Jenkins version | ||
user = services.jenkins_service.get_whoami() | ||
version = services.jenkins_service.get_version() | ||
print('JENKINS INFO -> Hello %s from Jenkins %s' % (user['fullName'], version)) | ||
|
||
# Print all files in the current directory | ||
print(os.listdir('.')) | ||
|
||
# Configured on docker-compose (check volumes) | ||
if config_module.ENV == 'local' or config_module.ENV == 'docker-env': | ||
path_job = '../.data/Jenkinsfile_spring.xml' | ||
else: | ||
path_job = './data/Jenkinsfile_spring.xml' | ||
|
||
# Jenkins version | ||
user = services.jenkins_service.get_whoami() | ||
version = services.jenkins_service.get_version() | ||
print('JENKINS INFO -> Hello %s from Jenkins %s' % (user['fullName'], version)) | ||
# List all content dir | ||
if config_module.ENV != 'local' or config_module.ENV != 'docker-env': | ||
try: | ||
content = os.listdir('../') | ||
print(content) | ||
except Exception as e: | ||
print(e) | ||
|
||
# Print all files in the current directory | ||
print(os.listdir('.')) | ||
# Read XML job | ||
job_config = open(path_job).read() | ||
|
||
# Configured on docker-compose (check volumes) | ||
if config_module.ENV == 'env.local': | ||
path_job = '../.data/Jenkinsfile_spring.xml' | ||
else: | ||
path_job = './data/Jenkinsfile_spring.xml' | ||
# Create credentials | ||
services.build_credentials(CredentialsType.USER) | ||
|
||
job_name = "spring-pipeline" | ||
|
||
# List all content dir | ||
if config_module.ENV != 'env.local': | ||
try: | ||
content = os.listdir('../') | ||
print(content) | ||
if services.jenkins_service.job_exists(job_name): | ||
services.jenkins_service.delete_job(job_name) | ||
print(f'Job {job_name} already exists and was deleted') | ||
else: | ||
print(f'Job {job_name} does not exist') | ||
services.jenkins_service.create_job(job_name, job_config) | ||
print('Job created successfully') | ||
except Exception as e: | ||
print(e) | ||
|
||
# Read XML job | ||
job_config = open(path_job).read() | ||
|
||
# Create credentials | ||
services.build_credentials(CredentialsType.USER) | ||
|
||
job_name = "spring-pipeline" | ||
services.jenkins_service.build_job(job_name) | ||
print('Job execute successfully') | ||
except Exception as e: | ||
print("Error: ", e) | ||
|
||
def start(): | ||
print("Build:: ...") | ||
try: | ||
if services.jenkins_service.job_exists(job_name): | ||
services.jenkins_service.delete_job(job_name) | ||
print(f'Job {job_name} already exists and was deleted') | ||
else: | ||
print(f'Job {job_name} does not exist') | ||
services.jenkins_service.create_job(job_name, job_config) | ||
print('Job created successfully') | ||
fetch() | ||
except Exception as e: | ||
print(e) | ||
print("Error: ", e) | ||
|
||
services.jenkins_service.build_job(job_name) | ||
print('Job execute successfully') | ||
except Exception as e: | ||
print("Error: ", e) | ||
if config_module.ENV == 'local': | ||
start() |
This file contains 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
Oops, something went wrong.