Update Jenkinsfile3

This commit is contained in:
s464903 2024-03-30 11:22:43 +01:00
parent 696f04ae7d
commit 51236af46f
1 changed files with 47 additions and 44 deletions

View File

@ -23,56 +23,59 @@ pipeline {
stages {
stage('Build image'){
steps{
checkout scm
//Pierwszy argument to tag, który zostania nadany zbudowanemu obrazowi
//Jeśli chcemy użyć Dockerfile z innej ścieżki niż ./Dockerfile, możemy ją podać jako drugi argument
def testImage = docker.build("test-image", "./Dockerfile")
}
}
stage('Run in container'){
steps{
docker.image('test-image').inside {
stage('Build') {
steps {
// Run the maven build
withEnv(["KAGGLE_USERNAME=${params.KAGGLE_USERNAME}",
"KAGGLE_KEY=${params.KAGGLE_KEY}" ]) {
sh 'echo KAGGLE_USERNAME: $KAGGLE_USERNAME'
sh 'kaggle datasets list'
}
}
}
stage('Checkout') {
steps {
// Krok: Sklonowanie repozytorium git
checkout scm
}
}
stage('Execute Shell Script') {
steps {
withEnv(["CUTOFF=${params.CUTOFF}" ]) {
// Krok: Wywołanie skryptu shella
script {
sh 'chmod +x data_processing_script.sh' // Nadaj uprawnienia do wykonania skryptu
sh './data_processing_script.sh $CUTOFF' // Wykonaj skrypt
checkout scm
// First argument is the tag assigned to the built image
// If you want to use a Dockerfile from a different path than ./Dockerfile, you can specify it as the second argument
def testImage = docker.build("test-image", ".")
}
}
}
}
stage('Archive Artifacts') {
stage('Run in container'){
steps {
// Krok: Zarchiwizowanie artefaktów
archiveArtifacts artifacts: 'processed_data.csv', fingerprint: true
script {
docker.image('test-image').inside {
stage('Checkout') {
steps {
// Step: Clone the git repository
checkout scm
}
}
stage('Build') {
steps {
// Run the maven build
withEnv(["KAGGLE_USERNAME=${params.KAGGLE_USERNAME}",
"KAGGLE_KEY=${params.KAGGLE_KEY}" ]) {
sh 'echo KAGGLE_USERNAME: $KAGGLE_USERNAME'
sh 'kaggle datasets list'
}
}
}
stage('Execute Shell Script') {
steps {
withEnv(["CUTOFF=${params.CUTOFF}" ]) {
// Step: Invoke the shell script
script {
sh 'chmod +x data_processing_script.sh' // Grant permissions to execute the script
sh './data_processing_script.sh $CUTOFF' // Execute the script
}
}
}
}
stage('Archive Artifacts') {
steps {
// Step: Archive artifacts
archiveArtifacts artifacts: 'processed_data.csv', fingerprint: true
}
}
}
}
}
}
}
}
}
}
}
}