add bash scripts & modified jenkinsfile
This commit is contained in:
parent
3d8b38aaa5
commit
0aa380be3b
51
Jenkinsfile
vendored
51
Jenkinsfile
vendored
@ -1,25 +1,50 @@
|
|||||||
node {
|
node {
|
||||||
stage('Preparation') {
|
stage('Preparation') {
|
||||||
properties([
|
properties([
|
||||||
parameters([
|
parameters([
|
||||||
string(
|
string(
|
||||||
defaultValue: 'Hello World!',
|
defaultValue: 'filippatyk',
|
||||||
description: 'Tekst do wyświetlenie',
|
description: 'Kaggle username',
|
||||||
name: 'INPUT_TEXT',
|
name: 'KAGGLE_USERNAME',
|
||||||
trim: false
|
trim: false
|
||||||
)
|
),
|
||||||
|
password(
|
||||||
|
defaultValue: '',
|
||||||
|
description: 'Kaggle token taken from kaggle.json file, as described in https://github.com/Kaggle/kaggle-api#api-credentials',
|
||||||
|
name: 'KAGGLE_KEY'
|
||||||
|
),
|
||||||
|
string(
|
||||||
|
defaultValue: '200',
|
||||||
|
description: 'CUTOFF',
|
||||||
|
name: 'CUTOFF',
|
||||||
|
trim: false
|
||||||
|
),
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
stage('Hello') {
|
|
||||||
//Wypisz wartość parametru w konsoli (To nie jest polecenie bash, tylko groovy!)
|
stage('Git clone') {
|
||||||
echo "INPUT_TEXT: ${INPUT_TEXT}"
|
//cloning git repo
|
||||||
//Wywołaj w konsoli komendę "figlet", która generuje ASCI-art
|
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: 's424714', url: 'https://git.wmi.amu.edu.pl/s424714/ium_424714']]])
|
||||||
sh "figlet \"${INPUT_TEXT}\" | tee output.txt"
|
|
||||||
}
|
}
|
||||||
stage('Goodbye') {
|
|
||||||
|
stage('Shell Script') {
|
||||||
|
|
||||||
|
// creating global envs for kaggle CLI
|
||||||
|
withEnv(["KAGGLE_USERNAME=${params.KAGGLE_USERNAME}",
|
||||||
|
"KAGGLE_KEY=${params.KAGGLE_KEY}" ]) {
|
||||||
|
sh 'echo KAGGLE_USERNAME: $KAGGLE_USERNAME'
|
||||||
|
|
||||||
|
sh "chmod +x -R ${env.WORKSPACE}"
|
||||||
|
sh "./create-dataset.sh ${CUTOFF}"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Saving artefacts') {
|
||||||
echo 'Goodbye!'
|
echo 'Goodbye!'
|
||||||
//Zarchiwizuj wynik
|
archiveArtifacts 'data/dataset.csv'
|
||||||
archiveArtifacts 'output.txt'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
36
Jenkinsfile2
Normal file
36
Jenkinsfile2
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
node {
|
||||||
|
stage('Preparation') {
|
||||||
|
properties([
|
||||||
|
parameters([
|
||||||
|
buildSelector(
|
||||||
|
defaultSelector: lastSuccessful(),
|
||||||
|
description: 'Which build to use for copying artifacts',
|
||||||
|
name: 'BUILD_SELECTOR'
|
||||||
|
)
|
||||||
|
])
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Git clone') {
|
||||||
|
//cloning git repo
|
||||||
|
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: 's424714', url: 'https://git.wmi.amu.edu.pl/s424714/ium_424714']]])
|
||||||
|
}
|
||||||
|
stage('cloning artifacts') {
|
||||||
|
//coping artifacts
|
||||||
|
copyArtifacts fingerprintArtifacts: true, projectName: 's424714-create-dataset', selector: buildParameter('BUILD_SELECTOR')
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
stage('Shell Script') {
|
||||||
|
// executing bash scripts
|
||||||
|
sh "chmod +x -R ${env.WORKSPACE}"
|
||||||
|
sh "./stats-dataset.sh"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Saving artefacts') {
|
||||||
|
echo 'Goodbye!'
|
||||||
|
archiveArtifacts 'data/stats.txt'
|
||||||
|
}
|
||||||
|
}
|
20
create-dataset.sh
Executable file
20
create-dataset.sh
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
mkdir -p data
|
||||||
|
kaggle datasets download -p data --unzip clmentbisaillon/fake-and-real-news-dataset
|
||||||
|
##############################
|
||||||
|
INPUT_FAKE=data/Fake.csv
|
||||||
|
INPUT_TRUE=data/True.csv
|
||||||
|
DATASET=data/dataset.csv
|
||||||
|
|
||||||
|
# INPUT_FAKE=data/test.csv
|
||||||
|
# INPUT_TRUE=data/test.csv
|
||||||
|
|
||||||
|
FAKE_DATA=$(tail -n +2 $INPUT_FAKE)
|
||||||
|
TRUE_DATA=$(tail -n +2 $INPUT_TRUE)
|
||||||
|
DATA="${FAKE_DATA}\n${TRUE_DATA}"
|
||||||
|
# DATA =$(head -n $1 $DATA)
|
||||||
|
echo -e "$DATA" | shuf | head -n $1 > $DATASET
|
||||||
|
rm data/True.csv
|
||||||
|
rm data/Fake.csv
|
||||||
|
|
5
stats-dataset.sh
Executable file
5
stats-dataset.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
DATASET=data/dataset.csv
|
||||||
|
records=$(wc -l < $DATASET)
|
||||||
|
echo "Records: $records" > data/stats.txt
|
Loading…
Reference in New Issue
Block a user