Feature/block96 Undo the changes made in case of pipeline generation failure#108
Feature/block96 Undo the changes made in case of pipeline generation failure#108BenjaminE98 wants to merge 16 commits intodevonfw:masterfrom
Conversation
| else | ||
| # Add the extra artifact to store variable. | ||
| az pipelines variable create --name "artifactPath" --pipeline-name "$pipelineName" --value "${artifactPath}" | ||
| variableResult=$(az pipelines variable create --pipeline-name "$pipelineName" --value "${artifactPath}") || { |
There was a problem hiding this comment.
SC2034: variableResult appears unused. Verify use (or export if used externally).
(at-me in a reply with help or ignore)
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| # Create the new branch. | ||
| git checkout -b ${sourceBranch} | ||
|
|
||
| # clear local-branches |
There was a problem hiding this comment.
clear local-branches comment may be misleading for another developer.
may be something like set undo stage (clear local-branches)
| function removeRemoteBranches { | ||
| cd "${localDirectory}" | ||
|
|
||
| # update list of remotes | ||
| git fetch | ||
|
|
||
| # delete mapped remote-branch | ||
| git push origin --delete ${sourceBranch} | ||
| } |
There was a problem hiding this comment.
I think you have to delete the pull request created by the createPR step before removing the remote branch. that means you need another function to undo the createPR step.
| az pipelines delete --id ${pipelineId} | ||
| } | ||
|
|
||
| function clearPollution { |
There was a problem hiding this comment.
@BenjaminE98
I understand what you mean hear by the name clearPollution but I suggest renaming it to something more self explanatory like undoPreviousSteps or rollbackPreviousActions or something else :-)
| # Undo-Level for the script. Used to clean up the resources in case of a failure | ||
| undoStage=0 |
There was a problem hiding this comment.
This assignment will work but I'd put this one either at the start of the "importConfigFile" function body or I'd put all undoStage assignments at the bottom between where the functions are called. Doesn't matter what you choose but better be consistent, I guess.
| else | ||
| # Add the extra artifact to store variable. | ||
| az pipelines variable create --name "artifactPath" --pipeline-name "$pipelineName" --value "${artifactPath}" | ||
| variableResult=$(az pipelines variable create --pipeline-name "$pipelineName" --value "${artifactPath}") || { |
There was a problem hiding this comment.
| variableResult=$(az pipelines variable create --pipeline-name "$pipelineName" --value "${artifactPath}") || { | |
| az pipelines variable create --pipeline-name "$pipelineName" --value "${artifactPath}" || { |
There was a problem hiding this comment.
Or is there a reason for the assignment?
There was a problem hiding this comment.
Regarding the variable result - not at all. Regarding the pipeline though I need it because I need to extract the id :) Azures Rest API uses the id of the pipeline to delete it :)
| if [ -d "./pipelines" ]; then | ||
| rm -rf ./pipelines | ||
| fi |
There was a problem hiding this comment.
I think we need more granularity than just removing it, as this would also undo any previous runs of the pipeline generator. What we want is to only remove it when there were no previous runs. If there were previous runs, we need to keep a copy of the previous state of the .pipeline, alternatively we could also check what type of config file is currently used and granularly delete only the files belonging to that config.
There was a problem hiding this comment.
This is a really good suggestion that I need to apply! Thank you :) I just need to see how
| else | ||
| # Add the extra artifact to store variable. | ||
| az pipelines variable create --name "artifactPath" --pipeline-name "$pipelineName" --value "${artifactPath}" | ||
| $(az pipelines variable create --pipeline-name "$pipelineName" --value "${artifactPath}") || { |
There was a problem hiding this comment.
SC2091: Remove surrounding $() to avoid executing output (or use eval if intentional).
(at-me in a reply with help or ignore)
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| pipelinesDirectoryAlreadyExists=false | ||
|
|
||
| if [ -d "./.pipelines" ]; then | ||
| pipelinesDirectoryAlreadyExists=true |
There was a problem hiding this comment.
SC2034: pipelinesDirectoryAlreadyExists appears unused. Verify use (or export if used externally).
(at-me in a reply with help or ignore)
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| # visit the directory and switch to the branch which was present before | ||
| cd "${localDirectory}" | ||
|
|
||
| git checkout $originalBranch |
There was a problem hiding this comment.
SC2154: originalBranch is referenced but not assigned.
Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.
When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
This closes #96
If the script fails, we rollback the necessary changes like removing the remote branches. removing the pipeline and local branches.
The idea was to create a variable called undoStage. This sets the stages which need to be undone.