microsoft / azure-pipelines-yaml

Azure Pipelines YAML examples, templates, and community interaction
MIT License
1.19k stars 924 forks source link

python task ran successfull but pipeline is faiing with bash exit code 1 #592

Closed bharuk closed 3 months ago

bharuk commented 1 year ago

`trigger: none

resources: webhooks:

variables:

stages:

def main():
target_Branch = sys.argv[1] cmd=f'git diff --name-status {target_Branch} vlocity/' cmdoutput, =call_subprocess(cmd) print(cmd_output) if cmd_output: print("=====EXIT CODE 123=====") print("Changes detected") print(cmd_output) exit(123) else: print("=====EXIT CODE 1=====") print("No changes detected") print(cmd_output) exit(1)

def call_subprocess(command, verbose=True): ''' Calls subprocess, returns output and return code, if verbose flag is active it will print the output ''' try: stdout = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True).decode('utf-8') if verbose: print_output(f'{stdout}') return stdout, 0 except subprocess.CalledProcessError as exc: output = exc.output.decode('utf-8') returncode = exc.returncode if verbose: print(f'[ERROR]Subprocess returned non-zero exit ' f'status {returncode}') print_output(output) return output, returncode

def print_output(output, color='', tab_level=1): ''' Prints output in the color passed ''' formated = '\t' tab_level + output.replace('\n', '\n' + '\t' tab_level) print(f'{formated}') if name=='main': main()` ERROR: Previous HEAD position was a35d7eb Create form.json Switched to a new branch 'master' branch 'master' set up to track 'origin/master'. Switched to a new branch 'develop' branch 'develop' set up to track 'origin/develop'.

=====EXIT CODE 1===== No changes detected

[debug]Exit code 1 received from tool '/usr/bin/bash'

[debug]STDIO streams have closed for tool '/usr/bin/bash'

[error]Bash exited with code '1'.

[debug]Processed: ##vso[task.issue type=error;]Bash exited with code '1'.

[debug]task result: Failed

[debug]Processed: ##vso[task.complete result=Failed;done=true;]

Finishing: Bash

I want perform the condition in azure if exist code 1 task will run successfull or if exist code 123 task will fail as per the above python i am trying to perform the task but it is failing any solution failure task

ivanduplenskikh commented 1 year ago

Hi @bharuk thanks for reporting! We are working on more prioritized issues at the moment, but will get back to this one soon.

bharuk commented 1 year ago

Any reponse regarding the issue why it is getting error..

max-zaytsev commented 3 months ago

Please post your questions on the Developer Community to get the right eyes on it, since this repo is mostly for questions about templates located in this repo.