Skip to content

Commit

Permalink
Too much changes for a commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemric committed Nov 26, 2023
1 parent c7b2210 commit 4d211f6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
6 changes: 4 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
def updated = false;

pipeline {
triggers {
cron(env.BRANCH_NAME == 'main' ? 'H H * * 4' : '')
Expand Down Expand Up @@ -120,7 +122,7 @@ pipeline {
echo uploading $FORMAT.$ARTIFACT.$ARCH.$STREAM files
scp $files jenkins@$ARTEFACTS_SERVER:/media/img/coreos/
'''
sh 'touch updated'
script { updated = true }
}
}
}
Expand All @@ -129,7 +131,7 @@ pipeline {
}

stage("Upload versions update") {
when { expression { fileExists('updated') } }
when { expression { updated == true } }
steps {
sshagent(credentials: ['Jenkins-Key']) {
sh '''
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ Options are, space delimited : (e.g.: `./Update.sh -v true`)
- `-s` or `--stream` usually: stable, testing or next -> défault : `stable`
- `-a` or `--arch` usually: aarch64, ppc64le, s390x, x86_64 -> default: `x86_64`
- `-t` or `--artifact` ouch ! aliyun, aws, azure, azurestack, digitalocean, exoscale, gcp, hyperv, ibmcloud, kubevirt, metal, nutanix, openstack, qemu, irtualbox, vmware, vultr... and so on depending previous choices -> default : `metal`
- `-f` or `--format`Arrgh ! Really depending of previous choices -> default : `pxe`
- `-f` or `--format` Arrgh ! Really depending of previous choices -> default : `pxe`
- `-v` or `--verbose` If ever you want to see well formatted json output -> default : `false`
- `-h` or `--history`default file path to `coreos.json` that must at least contains `{}`data, there's no error check for this option !
- `-h` or `--history` default file path to `coreos.json` that must at least contains `{}` data, there's no error check for this option !

It will ouput artefacts, GPG and SHASUM checked, and a file named as `$format.$artifact.$arch.$stream` that contains the list of downloaded files for later use .. or not

`coreos.json`/`--history` file will be updated with version number from released/downloaded artefacts to remember last updates

## Jenkinsfile
Expand Down
26 changes: 15 additions & 11 deletions Update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,46 +59,50 @@ if [ "${FCOSversion}" = "null" ]; then FCOSversion=0; fi;

echo FCOSrelease: $FCOSrelease / FCOSversion: $FCOSversion

failed=false

if $(jq -n "$data" | jq --raw-output --arg version $FCOSversion '.release > $version')
then

echo "Looking for $format files"
files=$(jq -n "$data" | jq .formats.$format) #filtering $format files version
jqverbose "${files}"
filecounter=0

for file in $(jq -n "$files" | jq --raw-output 'keys[]') #downloading all files
do

echo "Looking for $file"
let filecounter+=1
echo "Looking for file #$filecounter : $file"
filename="$file.$format.$artifact.$arch.$stream"
fileinfo=$(jq -n "$files" | jq .$file) #filtering each file informations
jqverbose "${fileinfo}"

for try in {1..2} #let's try 2 times downloading with correct checksum
do

echo "Downloading $(jq -n "$fileinfo" | jq --raw-output .location) to $filename"
curl -C - --no-progress-meter --parallel \
-o $filename $(jq -n "$fileinfo" | jq --raw-output .location) \
-o $filename.sig $(jq -n "$fileinfo" | jq --raw-output .signature) #Downloading fileinfo.location and .signature

echo "Check sha256sum and GPG signature"
if echo "$(jq -n "$fileinfo" | jq --raw-output .sha256) $filename" | sha256sum --check && gpg --verify $filename.sig
then
echo $filename >> $format.$artifact.$arch.$stream
echo $filename >> $format.$artifact.$arch.$stream.part
rm $filename.sig
break
else
rm $filename $filename.sig
fi

if [ try == 2 ]; then failed=true; fi;

done
done

if ! $failed
then
cat <<< $(jq --arg release $FCOSrelease '.'$stream'.'$arch'.'$artifact'.'$format' = $release' $history) > $history
if [[ -f $format.$artifact.$arch.$stream.part ]] then
if [[ $(wc -l < $format.$artifact.$arch.$stream.part) == $filecounter ]]
then
mv $format.$artifact.$arch.$stream.part $format.$artifact.$arch.$stream
cat <<< $(jq --arg release $FCOSrelease '.'$stream'.'$arch'.'$artifact'.'$format' = $release' $history) > $history
fi
fi

else
echo "Up to date, nothing to do"
fi

0 comments on commit 4d211f6

Please sign in to comment.