Hello all,
I am getting this kind of error while creating pipeline using api how to resolve this please help me out for this
My script is as bellow #!/bin/bash
machine_ip="server_ip"
g_user="none"
g_pass="none"
while :; do
read -p "What is your machine IP: " machine_ip
[[ $machine_ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "Enter a valid IP"; continue; }
if [[ $machine_ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
break
else
echo "Invalid IP Plese try again"
fi
done
read -p "Please Enter ENV name to Create New ENV: " gocd_env
read -p "Enter Your Username: " g_user
read -p "Enter Your Password: " g_pass
curl 'http://'$machine_ip':8153/go/api/admin/pipelines' \
-u $g_user:$g_pass \
-H 'Accept: application/vnd.go.cd.v11+json' \
-H 'Content-Type: application/json' \
-H 'X-pause-pipeline: true' \
-H 'X-pause-cause: "to have more control over when to start the pipeline after reviewing it"' \
-X POST -d '{ "group": '$gocd_env',
"pipeline": {
"label_template": "${COUNT}",
"lock_behavior": "lockOnFailure",
"name": '$gocd_env'_input_task,
"template": null,
"materials": [
{
"type": "git",
"attributes": {
"destination": "dest",
"filter": null,
"invert_filter": false,
"name": null,
"auto_update": true,
"branch": "main",
"submodule_folder": null,
"shallow_clone": true
}
}
],
"stages": [
{
"name": '$gocd_env'_input_stage,
"fetch_materials": true,
"clean_working_directory": false,
"never_cleanup_artifacts": false,
"approval": {
"type": "success",
"authorization": {
"roles": [],
"users": []
}
},
"environment_variables": [],
"jobs": [
{
"name": '$gocd_env'_input_job,
"run_instance_count": null,
"timeout": 0,
"environment_variables": [],
"resources": [],
"tasks": [
{
"type": "exec",
"attributes": {
"run_if": [
"passed"
],
"command": "echo",
"arguments": [
"Input_Pipeline"
]
}
}
]
}
]
}
]
}
}'
curl 'http://'$machine_ip':8153/go/api/admin/pipelines' \
-u $g_user:$g_pass \
-H 'Accept: application/vnd.go.cd.v11+json' \
-H 'Content-Type: application/json' \
-H 'X-pause-pipeline: true' \
-H 'X-pause-cause: "to have more control over when to start the pipeline after reviewing it"' \
-X POST -d '{ "group": '$gocd_env',
"pipeline": {
"label_template": "${COUNT}",
"lock_behavior": "lockOnFailure",
"name": '$gocd_env'_buffer_01,
"template": "Buffer_01_template",
"materials": [
{
"type": "dependency",
"attributes": {
"pipeline": '$gocd_env'_input_task,
"stage": '$gocd_env'_input_stage,
"name": null,
"auto_update": true,
"ignore_for_scheduling": false
}
}
],
"stages": null
}
}'
Thank you 😁 In Advance