Last active
September 13, 2024 16:29
-
-
Save cnolanminich/7917012d5773dae7b6f9ef0be83cab4e to your computer and use it in GitHub Desktop.
Jenkinsfile for hybrid
This file contains hidden or 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
pipeline { | |
agent any | |
environment { | |
// Construct the IMAGE_TAG using Jenkins environment variables | |
IMAGE_TAG = "${env.GIT_COMMIT}-${env.BUILD_ID} | |
AWS_ACCESS_KEY_ID = credentials('aws-access-key-id') // Reference to the AWS access key ID secret | |
AWS_SECRET_ACCESS_KEY = credentials('aws-secret-access-key') // Reference to the AWS secret access key secret | |
AWS_REGION = 'us-west-2' // Set your AWS region | |
} | |
stages { | |
stage('Set Build Output') { | |
steps { | |
script { | |
sh 'python3.8 -m pip install dagster-cloud' | |
sh 'dagster-cloud-cli ci set-build-output --location-name=quickstart_etl --image-tag=$IMAGE_TAG-quickstart_etl' | |
} | |
} | |
} | |
stage('Configure AWS Credentials') { | |
when { | |
expression { return env.STEPS_PRERUN_OUTPUTS_RESULT != 'skip' } | |
} | |
steps { | |
script { | |
withCredentials([string(credentialsId: 'aws-access-key-id', variable: 'AWS_ACCESS_KEY_ID'), | |
string(credentialsId: 'aws-secret-access-key', variable: 'AWS_SECRET_ACCESS_KEY')]) { | |
sh ''' | |
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID | |
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY | |
aws configure set region $AWS_REGION | |
''' | |
} | |
} | |
} | |
} | |
stage('Login to ECR') { | |
when { | |
expression { return env.STEPS_PRERUN_OUTPUTS_RESULT != 'skip' } | |
} | |
steps { | |
script { | |
sh ''' | |
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin <your-ecr-repository-url> | |
docker build -t ${IMAGE_REGISTRY}:${IMAGE_TAG}-quickstart_etl . | |
docker push ${IMAGE_REGISTRY}:${IMAGE_TAG}-quickstart_etl | |
''' | |
} | |
} | |
} | |
stage('Deploy to Dagster Cloud') { | |
when { | |
expression { return env.STEPS_PRERUN_OUTPUTS_RESULT != 'skip' } | |
} | |
steps { | |
script { | |
sh 'dagster-cloud-cli ci deploy' | |
} | |
} | |
} | |
stage('Update PR Comment for Branch Deployments') { | |
when { | |
expression { return env.STEPS_PRERUN_OUTPUTS_RESULT != 'skip' } | |
} | |
steps { | |
script { | |
sh 'dagster-cloud-cli ci notify --project-dir=${DAGSTER_PROJECT_DIR}' | |
} | |
} | |
} | |
stage('Generate a Summary') { | |
when { | |
expression { return env.STEPS_PRERUN_OUTPUTS_RESULT != 'skip' } | |
} | |
steps { | |
script { | |
sh 'dagster-cloud-cli ci status --output-format=markdown >> $GITHUB_STEP_SUMMARY' | |
} | |
} | |
} | |
} | |
post { | |
always { | |
script { | |
if (env.STEPS_PRERUN_OUTPUTS_RESULT != 'skip') { | |
sh 'dagster-cloud-cli ci notify --project-dir=${DAGSTER_PROJECT_DIR}' | |
sh 'dagster-cloud-cli ci status --output-format=markdown >> $GITHUB_STEP_SUMMARY' | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment