我们最近在Windows上设置了Jenkins CI服务器.现在,为了使用Active Directory身份验证,我想要求https(SSL/TLS)进行访问.鉴于此设置,建议的方法是什么?
我是Jenkins的新手,我不确定这是否可行,但我想建立一个网络界面,有人可以点击"开始工作",这将告诉Jenkins开始一个特定的构建工作.
詹金斯有一个允许这样的东西的网络服务吗?如果是这样,那么一个简单的例子是什么?
我删除rm托管作业的旧jenkins构建:
my_job/builds/$ rm -rf [1-9]*
Run Code Online (Sandbox Code Playgroud)
这些旧版本在作业页面中仍然可见.如何使用命令行删除它们?
(每个构建用户界面中没有删除按钮)
是否有一种单命令方式来获取远程仓库的最新镜像?那是
我知道我可以编写脚本(例如if [ -d repo ]; then (cd repo && git pull); else git clone $repourl;fi
),但我需要最简单的跨平台方式(实际上用于Jenkins-CI,我知道默认情况下这样做,但是我需要2个repos,其支持是有限的).
Git有其他类似的快捷方式(例如checkout -b和pull自己),所以我想知道我是否错过了什么.谢谢!
我目前在构建中看到一组错误.
如果你放松詹金斯(比如说是箱子崩溃,还是杀人-9),这是预期的行为吗?
或者是否有更糟糕的事情(如糟糕的网络连接)?
堆栈和错误是:
hudson.remoting.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:158)
at $Proxy175.join(Unknown Source) at
hudson.Launcher$RemoteLauncher$ProcImpl.join(Launcher.java:861) at
hudson.Launcher$ProcStarter.join(Launcher.java:345) at
hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:82)
at
hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:58)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at
hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:703)
at hudson.model.Build$RunnerImpl.build(Build.java:178) at
hudson.model.Build$RunnerImpl.doRun(Build.java:139) at
hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:473)
at hudson.model.Run.run(Run.java:1410) at
hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at
hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:238) Caused by:
hudson.remoting.RequestAbortedException: java.io.IOException:
Unexpected termination of the channel at
hudson.remoting.Request.abort(Request.java:273) at
hudson.remoting.Channel.terminate(Channel.java:732) at
hudson.remoting.Channel$ReaderThread.run(Channel.java:1157) Caused by:
java.io.IOException: Unexpected termination of the channel at
hudson.remoting.Channel$ReaderThread.run(Channel.java:1133) Caused by:
java.io.EOFException at
java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2554)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1297)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at hudson.remoting.Channel$ReaderThread.run(Channel.java:1127)
Run Code Online (Sandbox Code Playgroud) 我需要在Jenkins中以root身份而不是默认用户身份运行shell脚本.我需要改变什么?
我的sudoers文件是这样的:
# User privilege specification
root ALL=(ALL) ALL
igx ALL=(ALL) ALL
%wheel ALL=(ALL) ALL
# Allow members of group sudo to execute any command
# (Note that later entries override this, so you might need to move
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d
# Members of the admin group may gain root privileges
%admin ALL=(ALL) NOPASSWD:ALL
root ALL=(ALL) ALL
jenkins ALL=NOPASSWD: /var/lib/jenkins/workspace/ing00112/trunk/source/
jenkins ALL=(ALL) NOPASSWD:ALL
#Defaults:jenkins !requiretty
Run Code Online (Sandbox Code Playgroud) 我有一个Jenkins管道,它有多个阶段,例如:
node("nodename") {
stage("Checkout") {
git ....
}
stage("Check Preconditions") {
...
if(!continueBuild) {
// What do I put here? currentBuild.xxx ?
}
}
stage("Do a lot of work") {
....
}
}
Run Code Online (Sandbox Code Playgroud)
如果不满足某些先决条件并且没有实际工作要做,我希望能够取消(而不是失败)构建.我怎样才能做到这一点?我知道currentBuild变量可用,但我找不到它的文档.
我是jenkins管道的新手,我正在定义一个声明性语法管道,我不知道我是否可以解决我的问题,因为我找不到解决方案.
在这个例子中,我需要将一个变量传递给ansible插件(在旧版本中我使用ENV_VAR或者使用inject插件从文件中注入它,该变量来自脚本.
这是我完美的风景(但它不起作用,因为环境{}):
pipeline {
agent { node { label 'jenkins-node'}}
stages {
stage('Deploy') {
environment {
ANSIBLE_CONFIG = '${WORKSPACE}/chimera-ci/ansible/ansible.cfg'
VERSION = sh("python3.5 docker/get_version.py")
}
steps {
ansiblePlaybook credentialsId: 'example-credential', extras: '-e version=${VERSION}', inventory: 'development', playbook: 'deploy.yml'
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试了其他方法来测试env vars在其他帖子中的工作方式,例如:
pipeline {
agent { node { label 'jenkins-node'}}
stages {
stage('PREPARE VARS') {
steps {
script {
env['VERSION'] = sh(script: "python3.5 get_version.py")
}
echo env.VERSION
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但"echo env.VERSION"返回null.
还尝试了相同的例子: - VERSION = python3.5 get_version.py …
我开始使用Jenkins声明管道.从我看到的一些例子中,我注意到Jenkinsfile是使用Pipeline指令设置的:
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'make'
}
}
stage('Test'){
steps {
sh 'make check'
junit 'reports/**/*.xml'
}
}
stage('Deploy') {
steps {
sh 'make publish'
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
在其他示例中,我注意到Jenkinsfile是使用节点指令设置的:
node {
stage 'Checkout'
checkout scm
stage 'Build'
bat 'nuget restore SolutionName.sln'
bat "\"${tool 'MSBuild'}\" SolutionName.sln /p:Configuration=Release /p:Platform=\"Any CPU\" /p:ProductVersion=1.0.0.${env.BUILD_NUMBER}"
stage 'Archive'
archive 'ProjectName/bin/Release/**'
}
Run Code Online (Sandbox Code Playgroud)
我还没有找到关于何时/为何使用这些内容的确切文档.有没有人知道为什么这些不同以及什么时候适合使用它们?
我不确定,但我相信'node'指令用于脚本管道而不是声明管道.
提前感谢任何指导.