-
Notifications
You must be signed in to change notification settings - Fork 0
/
Disable-project-executions.xml
79 lines (75 loc) · 3.3 KB
/
Disable-project-executions.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<joblist>
<job>
<context>
<options preserveOrder='true'>
<option name='URL' required='true' value='http://localhost:4440'>
<label>Rundeck URL</label>
</option>
<option name='token' required='true' value='OaBNBpMygsEwyZ2kaEEAiLNuvR7w1swu'>
<label>Rundeck Token</label>
</option>
<option name='tmp_folder' required='true' value='/tmp/newProjectParams'>
<label>Temporary Folder</label>
</option>
<option name='jq_path' value='/var/tmp/jq-linux64'>
<label>jq_path</label>
</option>
<option name='project_list' required='true'>
<description><![CDATA[Project names to export (comma separated in case of exporting multiple projects)
e.g. Project1,Project2,Project3]]></description>
<label>Project Name to Export</label>
</option>
</options>
</context>
<defaultTab>output</defaultTab>
<description><![CDATA[This Job will change the following parameters:
project.disable.executions=true ==> to disable
project.disable.executions=false ==> to enable]]></description>
<executionEnabled>true</executionEnabled>
<group>Export_Projects</group>
<id>e825c65f-5828-4d6f-9608-85fb16c402b0</id>
<loglevel>INFO</loglevel>
<name>Disable-project-executions</name>
<nodeFilterEditable>false</nodeFilterEditable>
<plugins />
<scheduleEnabled>true</scheduleEnabled>
<schedules />
<sequence keepgoing='false' strategy='node-first'>
<command>
<script><![CDATA[#!/bin/bash
set -e
# Temporary folder where projects archives will be saved temporarily
if [ -d $RD_OPTION_TMP_FOLDER ]
then
echo -e "\nTemporary Directory already exists\n"
else
mkdir -p $RD_OPTION_TMP_FOLDER
echo -e "\nTemporary directory created\n"
fi
# Save projects list in projects array
IFS=', ' read -r -a projects <<< "$RD_OPTION_PROJECT_LIST"
# Loop to get projects names
for (( i=0; i<${#projects[@]}; i++ ))
do
project=${projects[$i]}
echo -e "-Retrieving project $project configuration file\n"
cmd=$(curl -s -k -X "GET" "$RD_OPTION_URL/api/21/project/$project/config" --header "Accept: application/json" --header "content-type: application/json" --header "x-rundeck-auth-token:$RD_OPTION_TOKEN" --output "$RD_OPTION_TMP_FOLDER/$project.conf")
sleep 2;
echo -e "-Temporal project file"
echo -e "$RD_OPTION_TMP_FOLDER/$project.conf\n"
sleep 2;
echo -e "-Changing project.disable.executions to true\n"
data=$(cat $RD_OPTION_TMP_FOLDER/$project.conf | $RD_OPTION_JQ_PATH -r .| sed -e 's/"project.disable.executions": "false"/"project.disable.executions": "true"/g' >$RD_OPTION_TMP_FOLDER/$project-tmp.conf)
sleep 1
echo -e "-Upload new project definition:\n"
last_data=$(cat $RD_OPTION_TMP_FOLDER/$project-tmp.conf)
curl -s --location --request PUT "$RD_OPTION_URL/api/21/project/$project/config" --header 'Accept: application/json' --header 'Content-Type: application/json' --header "X-Rundeck-Auth-Token: $RD_OPTION_TOKEN" -d "$last_data"
echo -e "\n-------------------------------------------\n"
done
]]></script>
<scriptargs />
</command>
</sequence>
<uuid></uuid>
</job>
</joblist>