【发布时间】:2021-07-11 18:39:17
【问题描述】:
我为我的应用程序创建了多阶段 azure 构建管道,在第一阶段,我正在构建源代码并执行 test.sh - 这个 shell 脚本创建一个新的 shell 脚本文件叫 data.sh。在我的第二阶段,我正在执行 run.sh 执行这个新创建的文件 data.sh 但我得到 No such file or directory error我的管道在第二阶段失败了。
新创建的文件data.sh不是从我之前的阶段复制的,我如何才能将data.sh进入我的第二阶段,请在下面找到我的代码:
非常感谢有人能帮我解决这个问题,我需要在stage 2 中创建的data.sh 文件,该文件是在stage 1 中创建的
azure-pipeline.yml
trigger:
- none
pool:
vmImage: 'Ubuntu-latest'
stages:
- stage: TestFilecopy
displayName: Extecute test script
jobs:
- job: myJob1
displayName: Execute myJob1
steps:
- task: Bash@3
inputs:
targetType: filePath
filePath: 'myApp/test.sh'
workingDirectory: myApp
- stage: TestFilecopy1
displayName: Extecute new script
jobs:
- job: myJob2
displayName: Execute myJob2
steps:
- task: Bash@3
inputs:
targetType: filePath
filePath: 'myApp/run.sh'
workingDirectory: myApp
test.sh
#!/bin/bash
echo "hello word"
echo $PWD
ls -la
echo "#!/bin/bash
echo 'Hello World'" > data.sh
ls -la
run.sh
echo "hello run file"
echo $PWD
ls -la
./data.sh
文件夹结构
product-pipeline-project/
├─ myApp/
│ ├─ run.sh
│ ├─ test.sh
├─ azure-pipeline.yml
管道控制台输出 第一阶段输出日志
Generating script.
Formatted command: exec bash '/home/vsts/work/1/s/myApp/test.sh'
========================== Starting Command Output ===========================
/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/ef037ffc-0ea8-4366-b074-10120c9b1434.sh
hello word
/home/vsts/work/1/s/myApp
total 16
drwxr-xr-x 2 vsts docker 4096 Jul 11 18:25 .
drwxr-xr-x 4 vsts docker 4096 Jul 11 18:25 ..
-rw-r--r-- 1 vsts docker 48 Jul 11 18:25 run.sh
-rw-r--r-- 1 vsts docker 109 Jul 11 18:25 test.sh
total 20
drwxr-xr-x 2 vsts docker 4096 Jul 11 18:25 .
drwxr-xr-x 4 vsts docker 4096 Jul 11 18:25 ..
-rw-r--r-- 1 vsts docker 37 Jul 11 18:25 data.sh
-rw-r--r-- 1 vsts docker 48 Jul 11 18:25 run.sh
-rw-r--r-- 1 vsts docker 109 Jul 11 18:25 test.sh
第 2 阶段输出日志
Generating script.
Formatted command: exec bash '/home/vsts/work/1/s/myApp/run.sh'
========================== Starting Command Output ===========================
/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/087e12fd-0b7b-4bd5-a4a8-7b7879255f3f.sh
hello run file
/home/vsts/work/1/s/myApp
total 16
drwxr-xr-x 2 vsts docker 4096 Jul 11 18:25 .
drwxr-xr-x 4 vsts docker 4096 Jul 11 18:25 ..
-rw-r--r-- 1 vsts docker 48 Jul 11 18:25 run.sh
-rw-r--r-- 1 vsts docker 109 Jul 11 18:25 test.sh
/home/vsts/work/1/s/myApp/run.sh: line 4: ./data.sh: No such file or directory
##[error]Bash exited with code '127'.
Finishing: Bash
【问题讨论】:
标签: azure-pipelines azure-pipelines-release-pipeline azure-pipelines-build-task azure-pipelines-yaml azure-pipelines-tasks