I have a job running on x nodes with some options. I capture some data I need to a child job which consists to send a mail saying that machine A has been updated with version X and so on.
This child job grabs options and global variables from parent jobto get correct values for the mail.
If I run the child job as a node step it's working but it will send one mail per machine. What I would like to do is running the child job as a workflow step to send a single mail saying that machine A/B/C have been updated with version X/Y/Z and so on...
But when running as a workflow step I have a substitution error which is logical without node context :
- defaultTab: nodes
description: ''
executionEnabled: true
group: test
id: 721f1a1a-0e36-4b93-8b71-f5be5f807abd
loglevel: INFO
name: CHILD
nodeFilterEditable: false
nodefilters:
dispatch:
excludePrecedence: true
keepgoing: false
rankOrder: ascending
successOnEmptyNodeFilter: false
threadcount: '1'
filter: 'tags: rundeck'
nodesSelectedByDefault: true
options:
- name: CHANGEMENT
- enforced: true
name: ENV
values:
- REC
- PRD
valuesListDelimiter: ','
- enforced: true
name: NODE
values:
- '10'
- '11'
- '12'
- '13'
- ALL
valuesListDelimiter: ','
- name: Version
- name: nom_machine
required: true
- name: version_installe
required: true
plugins:
ExecutionLifecycle: {}
scheduleEnabled: true
sequence:
commands:
- autoSecureInput: 'false'
passSecureInput: 'false'
script: |-
################
### Function ###
################
function MAIL_FIN_INSTALL ()
{
# Variables avec expansion Rundeck
mail_to="@node.PATH_mail_to@"
mail_cc="@node.PATH_mail_cc@"
mail_exp="@node.PATH_mail_exp@"
version_install="@option.Version@"
version_serveur="@option.version_installe@"
changement="@option.CHANGEMENT@"
machine="@option.nom_machine@"
version_installe="@option.version_installe@"
if [[ "@option.CHANGEMENT@" =~ [A-Z]{1}[0-9]{6}_[0-9]{6} ]]; then
echo "========================================================"
echo "ceci est un envoi de mail pour la mise à jour standard."
echo "========================================================"
else
mail_to="@node.PATH_mail_test_to@"
mail_cc="@node.PATH_mail_test_cc@"
mail_exp="@node.PATH_mail_test_exp@"
echo "========================================"
echo "ceci est un envoi de mail pour du TEST."
echo "========================================"
fi
if [[ "@option.ENV@" = "PRD" ]]; then
environnement="production"
else
environnement="recette"
fi
echo "===================================================="
echo "Nous sommes sur l'environnement de : [$environnement]"
echo "===================================================="
if [[ "@option.NODE@" = "ALL" ]]; then
echo "==============================================================="
echo " nous sommes en [$environnement], envoi du mail en cours"
echo " le mail sera envoyé par [$mail_exp] à [$mail_to] et [$mail_cc]"
echo "==============================================================="
echo '<!DOCTYPE html>
<html xmlns="
http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
<head>
<title>blabla</title>
</head>
<body>
<p>Bonjour,<br /><br />
blabla'$environnement'</strong> est terminée sur la machine : '$machine'.<br /><br />
La version est : '$version_installe' ('$version_install') <br /><br />
</body>
</html>' | EMAIL="$mail_exp" mutt -e 'set content_type="text/html"' "$mail_to" -c "$mail_cc" -s "[PBI ON CLOUD][@option.ENV@][@option.CHANGEMENT@] Mise a jour Datagateway Powerbi"
echo -e "\n ### MAIL INSTALL @option.ENV@ sent.### \n"
else
echo "======================================================================================="
echo " nous sommes en TEST sur l'environnement : [$environnement], envoi du mail en cours"
echo " le mail de TEST sera envoyé par [$mail_exp] à [$mail_to] et [$mail_cc]"
echo "======================================================================================="
echo '<!DOCTYPE html>
<html xmlns="
http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
<head>
<title>PBI Auto Deploy</title>
</head>
<body>
<p>Bonjour,<br /><br />
Ceci est un <span style="color: red"><strong>test</strong></span>.<br /><br />
blabla'$environnement'</strong> est terminée sur la machine : '$machine'.<br /><br />
La version est : '$version_installe' ('$version_install') <br /><br />
N°'$changement'<br /><br />
Service Intégration Technique et Applicative 1</p>
</body>
</html>' | EMAIL="$mail_exp" mutt -e 'set content_type="text/html"' "$mail_to" -c "$mail_cc" -s "[PBI ON CLOUD][TEST][@option.ENV@][@option.CHANGEMENT@] bla"
echo -e "\n ### MAIL INSTALL @option.ENV@ sent.### \n"
fi
echo "###########################"
echo "### fin d'envoi de mail ###"
echo "###########################"
}
############
### Main ###
############
MAIL_FIN_INSTALL
keepgoing: false
strategy: node-first
uuid: 721f1a1a-0e36-4b93-8b71-f5be5f807abd