ReactJS - How to use conditionals in render JSX
Introduction In this post, I will show several ways to use conditionals while…
October 07, 2022
I have an automation script, that I want to run on different environments, with a cron schedule. I’m using a web-service, and the endpoints are different for each environment.
Also, I would need credentials for calling that web-service apis.
Recommended read on How to Run job on Cron-schedule
pipeline {
agent {
node {
label "MyNode"
}
}
triggers {
//every 24 hours at 12 AM
cron('0 0 * * *')
}
stages {
stage('Install requirements') {
when {
not { changeset pattern: ".*", comparator: "REGEXP" }
}
steps {
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'my_api_key',
usernameVariable: 'ARTIFACTORY_USERNAME',
passwordVariable: 'ARTIFACTORY_PASSWORD']
]) {
sh """
python3.8 -m pip install virtualenv
python3.8 -m venv python_env
source python_env/bin/activate
python3.8 -m pip install --upgrade pip
python3.8 -m pip install -r requirements.txt -i https://${ARTIFACTORY_USERNAME}:${ARTIFACTORY_PASSWORD}@artifactory.myorg.com/artifactory/api/pypi/pypi-myorg-release/simple
deactivate
"""
}
}
}
stage('Run Workflow Scheduler') {
parallel {
stage('Run Scheduler for Dev') {
steps {
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'mygen',
usernameVariable: 'API_USER',
passwordVariable: 'API_PASSWORD']
]) {
sh """
echo "Running for Dev env"
export WEB_SERVICE_BASE_URL="https://my-dev.myorg.com/api/"
python3.8 -m venv python_env
source python_env/bin/activate
python3.8 app.py
deactivate
"""
}
}
}
stage('Run Scheduler for Stage') {
steps {
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'mygen',
usernameVariable: 'API_USER',
passwordVariable: 'API_PASSWORD']
]) {
sh """
echo "Running for Stage env"
export WEB_SERVICE_BASE_URL="https://my-stg.myorg.com/api/"
python3.8 -m venv python_env
source python_env/bin/activate
python3.8 app.py
deactivate
"""
}
}
}
stage('Run Scheduler for Prod') {
steps {
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'mygen',
usernameVariable: 'API_USER',
passwordVariable: 'API_PASSWORD']
]) {
sh """
echo "Running for Prod env"
export WEB_SERVICE_BASE_URL="https://my-prod.myorg.com/api/"
python3.8 -m venv python_env
source python_env/bin/activate
python3.8 app.py
deactivate
"""
}
}
}
}
}
}
}
I’m doing following in above file:
cron('0 0 * * *')
UsernamePasswordMultiBinding
, and exposing in environment variablesIntroduction In this post, I will show several ways to use conditionals while…
Introduction In this post, we will see: use Grafana Community Edition (Free…
Introduction There are some cases, where I need another git repository while…
I have a custom content type, and there are around 2000 number of nodes in my…
Introduction So you have a Django project, and want to run it using docker image…
Introduction This post has the complete code to send email through smtp server…
Introduction In this post we will see following: How to schedule a job on cron…
Introduction There are some cases, where I need another git repository while…
Introduction In this post, we will see how to fetch multiple credentials and…
Introduction I had to write a CICD system for one of our project. I had to…
Introduction Java log4j has many ways to initialize and append the desired…
Introduction You have a running kubernetes setup, and have a webservice (exposed…