Jenkins-执行Shell构建步骤不起作用 [英] Jenkins - Execute Shell Build Step Not Working

查看:3278
本文介绍了Jenkins-执行Shell构建步骤不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Jenkins中创建一个作业,该作业将执行一个简单的Shell脚本.但是,Jenkins似乎实际上并没有对我的脚本做任何事情.无论我在 Execute Shell Command 部分中输入什么值,Jenkins总是说它已通过.即使我输入了"RandomBogusFilename.sh"之类的虚假文件名,也会说这项工作是成功的.

I'm trying to create a job in Jenkins that will execute a simple shell script. However, it seems that Jenkins isn't actually doing anything with my script. No matter what value I put into the Execute Shell Command section, Jenkins always says that it passes. Even if I put in a bogus filename like "RandomBogusFilename.sh" it'll say the job was a success.

任何人都可以指出我在做错什么以及如何让Jenkins实际使用我的shell脚本吗?

Can anyone point out what I'm doing wrong and how I can get Jenkins to actually use my shell script?

shell脚本,作业配置和控制台输出均显示在下面.我目前正在尝试在 Windows Server 2008 R2 Standard 计算机上执行此操作.

The shell script, the job config, and the console output are all shown below. I'm currently trying to do this on a Windows Server 2008 R2 Standard machine.

谢谢.

文件名: surveyToolRequest.sh
文件位置:/jobs/Jeff Shell脚本测试/工作区
说明: 点击一个网址并获取HTTP响应.然后打印出HTTP响应.

File Name: surveyToolRequest.sh
File Location: /jobs/Jeff Shell Script Test/workspace
Description: Hit a web address and retrieve the HTTP Response. Then print out the HTTP Response.

#!/bin/bash

response_code=$(curl -s -o /dev/null -w "%{http_code}" http://SOME-WEBSITE.COM)
echo "The response code is " $response_code  






推荐答案

我玩了这个,发现如果我指定了脚本的路径,它就可以工作.如果脚本在您工作的工作区目录中,

I played with this and found that it worked if I specified the path to the script. If the script is in your job's workspace directory,

./surveyToolRequest.sh

在詹金斯(Jenkins)查找相对于工作空间根目录的文件时应该起作用.

should work as Jenkins looks for files relative to the root of the workspace.

更常见的是将脚本文件目录的内容放入作业配置中.这样一来,您就可以了解工作的开展情况,并且可以避免此类问题.

It's more common to just put the contents of the script file directory into the job configuration; that way you can see what the job is doing and you'll avoid problems like this one.

这篇关于Jenkins-执行Shell构建步骤不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆