Я пытаюсь создать изображение docker с помощью Jenkins (фристайл), но каждый раз, когда я запускаю задание, он показывает:
Started by user admin
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/test
using credential 09baa12b-e5c7-
git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url git@bitbucket.org:abc/product_component.git # timeout=10
Fetching upstream changes from git@bitbucket.org:abc/product_component.git
git --version # timeout=10
using GIT_SSH to set credentials
git fetch --tags --progress -- git@bitbucket.org:abc/product_component.git +refs/heads/*:refs/remotes/origin/* # timeout=10
git rev-parse origin/development^{commit} # timeout=10
Checking out Revision 013e3a66c02e3534ae2e717c37ba94605886869f (origin/development)
git config core.sparsecheckout # timeout=10
git checkout -f 013e3a66c02e3534ae2e717c37ba94605886869f # timeout=10
Commit message: "productDEF1976 1977 - interaction history timestamp in utc"
git rev-list --no-walk 013e3a66c02e3534ae2e717c37ba94605886869f # timeout=10
[test] $ /bin/bash /tmp/jenkins2990566506686066436.sh
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Я сохранил свой код в */var/lib/jenkins/workspace/component/component.sh*
и мой код такой:
#!/bin/bash
set -e
c=`ls -lrt | tail -n1 | awk -F'.' '{print $4}' | grep -o '[0-9]\+'`
TAG=`expr $c + 1`
cp /home/ubuntu/abcsit/yamlFiles/component.yaml .
printf "Current tag - $TAG \n"
echo "Switching directory to component"
pwd
ls -l
git branch -l
if [ -f $WORKSPACE/../CLEAN_BUILD_component ]; then
echo "Doing a clean build"
docker build --no-cache -t product:component.$TAG .
cd $WORKSPACE
kubectl delete deploy component -n abcsit || true # deleting old deployement
kubectl delete service component -n abcsit || true # deleting old service
#creating new deployment
kubectl create -f component.yaml
rm $WORKSPACE/../CLEAN_BUILD_component
else
echo "Doing a normal build"
docker build -t product:component.$TAG .
kubectl set image deployment/component component=product:component.$TAG -n abcsit --record=true # doing rollout deploy
fi
echo $TAG > $WORKSPACE/../LATEST_component
<EOF>