Skip to content

Commit

Permalink
Exit non-zero when rd-jobs load has a job load failure [#285 state:ne…
Browse files Browse the repository at this point in the history
…eds_verification]
  • Loading branch information
gschueler committed Jun 24, 2011
1 parent 9db7511 commit 5299a4c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/src/java/com/dtolabs/rundeck/core/cli/jobs/JobsTool.java
Expand Up @@ -658,6 +658,9 @@ private void loadAction() throws JobsToolException {
logStoredJobItem(item, null);
}
}
if(failed.size()>0) {
throw new JobsToolException("Failed to load " + failed.size() + " Jobs");
}

}

Expand Down
27 changes: 27 additions & 0 deletions test/test.jobs2.xml
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Jobs should fail due to missing project
-->
<joblist>
<job>
<name>Invalid Job</name>
<description>Loading this job should not succeed</description>
<additional/>
<loglevel>INFO</loglevel>
<group>test</group>
<context>
<project>thisProjectDNE</project>
</context>
<sequence threadcount="1" keepgoing="false" strategy="node-first">
<command>
<exec>uptime</exec>
</command>
</sequence>
<dispatch>
<threadcount>1</threadcount>
<keepgoing>false</keepgoing>
</dispatch>
</job>
</joblist>
24 changes: 24 additions & 0 deletions test/test.sh
Expand Up @@ -43,6 +43,30 @@ fi
rm $DIR/load.out
rm $DIR/test.jobs.expanded.xml


###############
# load jobs with failures
###############
#
#copy jobs file to replace template

#load jobs
$RDECK_BASE/tools/bin/rd-jobs load -f $DIR/test.jobs2.xml > $DIR/load.out
if [ 1 != $? ] ; then
echo Should have failed to load a job: $!
exit 2
fi
cat $DIR/load.out

grep -q Failed $DIR/load.out
if [ 1 == $? ] ; then
echo Should have failed to load a job: $!
exit 2
fi

rm $DIR/load.out


# try to run job id 1

$RDECK_BASE/tools/bin/run -i 1
Expand Down

0 comments on commit 5299a4c

Please sign in to comment.