we are working with a tool where the elements are all written via .json.
Currently my GIT folder structure looks like this:
elementsfolder -> element1.json, element2.json, element3.json
scriptsfolder -> e.g. transformation.py
testfolder -> run-element.sh
Jenkinsfile
The problem I have now is that the .json files in folder elementsfolder should be tested with the bashscript from the testfolder and (if necessary) a script like transformations.py should be called. This also works so far, but all .json files are always tested (no matter if unchanged or not). But this should not be the case. Only the elements that are either changed or newly created should be tested. We have at the end of the day over 6000 elements, accordingly, the test over all elements would be too costly. Can anyone help me with this? In Jenkins the pipeline looks like this (I only post the stage build, because test and deploy are similar):
stages {
stage('Build') {
environment {
CREDS = credentials('creds')
ENDPOINT = 'automation-api'
}
steps {
sh '''
username=$USR
password=$PSW
# Login curl
login=$(curl -k -s -H "Content-Type: application/json" -X POST -d \\{\\"username\\":\\"$username\\",\\"password\\":\\"$password\\"\\} "$ENDPOINT/session/login" )
token=$(echo ${login##*token\\" : \\"} | cut -d '"' -f 1)
# Build
#1. Validation .json
curl -k -s -H "Authorization: Bearer $token" -X POST -F "definitionsFile=@element/*.json" "$ENDPOINT/build"
#2. Show Error
curl --show-error --fail -k -s -H "Authorization: Bearer $token" -X POST -F "definitionsFile=@element/*.json" "$ENDPOINT/build"
#3. Logout
curl -k -s -H "Authorization: Bearer $token" -X POST "$ENDPOINT/session/logout"
'''
}
}