Reputation: 27
I'm facing some issues and would be glad if someone can help me. My main goal here it's being able to save at the same pipeline, more than one job. The error it’s because the jobs does not exist for the specific branch, since I have 6 branches I don't want to modified one by one. I would like to have only one Yaml version.
When I've tried to save, GitLab show me the following errors.
Found errors in your .gitlab-ci.yml:
jobs:deploy_dc_manual:needs:need job should be a string
You can test your .gitlab-ci.yml in CI Lint.
This, it is a piece of the code. Example if I am in the branch feature the job needs it´s "feature_package_build" If I am at integration branch will be expected "int_package_build".
feature_package_build:
extends: .build
only:
- /^feature\/.*/
script:
# GitLab API query
- LAST=$(curl -s "sensitive data" | jq '.[0] | .sha' | sed '1q;d' | sed 's:^.\(.*\).$:\1:')
- >
if [ "$OLDER_COMMIT" == "none" ]; then
node_modules/sfdx-cli/bin/run sfpowerkit:project:diff -d package -r ${LAST} -x --loglevel debug
elif [ "$OLDER_COMMIT" != "none" ]; then
node_modules/sfdx-cli/bin/run sfpowerkit:project:diff -d package -r $OLDER_COMMIT -x --loglevel debug
fi
int_package_build:
extends: .build
only:
- integration
script:
# GitLab API query
- LAST=$(curl -s "sensitive data" | jq '.[0] | .sha' | sed '1q;d' | sed 's:^.\(.*\).$:\1:')
- >
if [ "$OLDER_COMMIT" == "none" ]; then
node_modules/sfdx-cli/bin/run sfpowerkit:project:diff -d package -r ${LAST} -x --loglevel debug
elif [ "$OLDER_COMMIT" != "none" ]; then
node_modules/sfdx-cli/bin/run sfpowerkit:project:diff -d package -r $OLDER_COMMIT -x --loglevel debug
fi
uat_package_build:
extends: .build
only:
- uat
script:
# GitLab API query
- LAST=$(curl -s "sensitive data" | jq '.[0] | .sha' | sed '1q;d' | sed 's:^.\(.*\).$:\1:')
deploy_DC_Manual:
extends:
- .deployDC_Manual
needs:
- job:
if [uat_package_build]; then
fi
if [feature_package_build]; then
fi
only:
- /^feature\/.*/
- integration
- uat
- release
- master
script:
- nomDeployedDC=${NONDEPLOYEDDC}
- >
if [ -f package/destructiveChanges.xml ] && [ "$VALIDATE" == "no" ]; then
Upvotes: 0
Views: 330
Reputation: 4754
I assume what you are looking for is the optional
-flag for the needs keyword like
deploy_DC_Manual:
extends:
- .deployDC_Manual
needs:
- job: uat_package_build
optional: true
- job: feature_package_build
optional: true
As this makes the needs conditional - but please be aware, that this also means if you mess up your rules, and none of those two is available, your job might be still executed.
Upvotes: 1