尝试运行测试套件,但Jenkins没有提取最新的代码

问题描述 投票:1回答:5

我正在使用Jenkins运行测试套件,我已经配置了一个工作来做到这一点。我有一个正在执行所有步骤的管道脚本,但似乎在LIVE上通过在LIVE上添加一个新按钮的最新版本,我的测试运行了一个没有该按钮的代码版本,它似乎是没有拉最新的代码。我在脚本中做错了什么?

我试图从Bitbucket下拉最新的代码,但没有成功,并通过做'docker-compose build --build-arg BRANCH = $ {branch} apache'来构建分支

node {
   stage('Pull latest Docker repo') { 
      git credentialsId: 'xyz',
          url: '[email protected]:domain/myportal-docker.git'
   }
   stage('Install app') {
      sh 'docker-compose down'
      sh 'docker-compose build --no-cache mysql'
      if (params.buildapp == true){
        sh 'docker-compose build --build-arg BRANCH=${branch} apache'
      }
      sh 'docker-compose up -d'
   }
   stage('Set up Selenium') {
      try {
        sh 'docker rm selenium -f'
      }
      catch(exc) {
        echo 'No selenium container running'
      }
      sh 'docker pull selenium/standalone-chrome'
      sh 'docker run -d -p 4444:4444 --name=selenium --net=host -v /dev/shm:/dev/shm selenium/standalone-chrome:3.141.59-dubnium'
   }
   stage('Load tests') { 
      dir("../") {}
      git credentialsId: 'xyz',
          url: '[email protected]:domain/my-tests.git'
   }
   stage('Run tests') {
      sh 'composer install'
      sh 'vendor/bin/codecept --debug run --steps tests/jenkins'
   }
}

测试运行正常,但不知怎的,它们不运行最新的代码,它们针对主分支运行,但它没有最新的代码。此外,我有一个随需应变的工作,我想尝试并搞乱它曾经有一些信息可能来自你们中的一些人。

selenium docker jenkins bitbucket codeception
5个回答
1
投票

params.buildapp为false,因此它不构建apache容器。只有在构建此容器时才会从您的仓库中提取代码。


0
投票

可能与您的Dockerfile有关

你需要确保用ADD ./yourcodefolder关闭你的文件


0
投票

有这个人的任何其他想法?

当我尝试以上所有内容并没有任何效果。测试运行正常,但不是最新的代码。

正如我在第一篇文章中所说,我知道,因为我们在第一页上有一个新按钮,而且我的版本不在测试运行的版本上。


0
投票

@teddym6现在看起来像这样,我的Dockerfile:

来自webdevops / php-apache:7.1

ARG WWW_ROOT ARG APP_DIR ARG APP_ROOT = $ {WWW_ROOT} / $ {APP_DIR} ARG BRANCH

ENV WEB_DOCUMENT_ROOT = $ {APP_ROOT} / htdocs

RUN mkdir /root/.ssh/ ADD ./.ssh/ /root/.ssh/ RUN chmod -R 0600 /root/.ssh/* RUN echo“使用分支$ {BRANCH}代码”RUN git clone --branch $ {BRANCH} --depth 1 [email protected]:domain / myportal-docker.git $ {APP_ROOT}

WORKDIR $ {APP_ROOT}

运行mkdir -p运行时htdocs / assets运行chmod -R a + w运行时htdocs / assets

WORKDIR / usr / src / app

COPY app / local.php $ {APP_ROOT} /config/local.php

添加/ usr / src / app WORKDIR / usr / src / app


0
投票

回到这个,因为它让我头疼,所以控制台输出看起来像这样:

  Started by timer
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/jobs/Autotest/workspace
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Pull latest Docker repo)
[Pipeline] git
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url [email protected]:domain/myportal-docker.git
 # timeout=10
Fetching upstream changes from [email protected]:domain/myportal-docker.git
 > git --version # timeout=10
using GIT_SSH to set credentials Jenkins Portal Tests Repo
 > git fetch --tags --progress [email protected]:domain/myportal-docker.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 20cdc207dc87e736983d6b28b5a81853c7c37f70 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 20cdc207dc87e736983d6b28b5a81853c7c37f70
 > git branch -a -v --no-abbrev # timeout=10
 > git branch -D master # timeout=10
 > git checkout -b master 20cdc207dc87e736983d6b28b5a81853c7c37f70
Commit message: "Got rid of the WORKDIR"
 > git rev-list --no-walk 20cdc207dc87e736983d6b28b5a81853c7c37f70 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Install app)
[Pipeline] sh
[workspace] Running shell script
+ docker-compose down
Stopping workspace_apache_1 ... 
Stopping workspace_mysql_1  ... 
[2A[2K
Stopping workspace_apache_1 ... [32mdone[0m
[2B[1A[2K
Stopping workspace_mysql_1  ... [32mdone[0m
[1BRemoving workspace_apache_1 ... 
Removing workspace_mysql_1  ... 
[1A[2K
Removing workspace_mysql_1  ... [32mdone[0m
[1B[2A[2K
Removing workspace_apache_1 ... [32mdone[0m
[2BRemoving network workspace_frontend
Removing network workspace_backend
[Pipeline] sh
[workspace] Running shell script
+ docker-compose build --no-cache mysql
Building mysql
Step 1/2 : FROM mysql:5.7.24
 ---> ba7a93aae2a8
Step 2/2 : ADD mysql.cnf /etc/mysql/mysql.conf.d/mysql.cnf
 ---> cd3843490228
Successfully built cd3843490228
Successfully tagged workspace_mysql:latest
[Pipeline] echo
Will deploy from feature/docker-enablement
[Pipeline] echo
BuildApp Param false
[Pipeline] sh
[workspace] Running shell script
+ docker-compose up -d
Creating network "workspace_frontend" with the default driver
Creating network "workspace_backend" with the default driver
Creating workspace_mysql_1 ... 
Creating workspace_mysql_1
[1A[2K
Creating workspace_mysql_1 ... [32mdone[0m
[1BCreating workspace_apache_1 ... 
Creating workspace_apache_1
[1A[2K
Creating workspace_apache_1 ... [32mdone[0m
[1B[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Set up Selenium)
[Pipeline] sh
[workspace] Running shell script
+ docker rm selenium -f
selenium
[Pipeline] sh
[workspace] Running shell script
+ docker pull selenium/standalone-chrome
Using default tag: latest
latest: Pulling from selenium/standalone-chrome
Digest: sha256:c478febf26729b7cc27e2fac7d10fa79cf2519b5ab83f9cf82705248258b6495
Status: Image is up to date for selenium/standalone-chrome:latest
[Pipeline] sh
[workspace] Running shell script
+ docker run -d -p 4444:4444 --name=selenium --net=host -v /dev/shm:/dev/shm selenium/standalone-chrome:3.141.59-dubnium
WARNING: Published ports are discarded when using host network mode
952481c15140f1b9fe797cbee495268d7fd191c4ec07194297e19b27109f829a
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Load tests)
[Pipeline] dir
Running in /var/lib/jenkins/jobs/Autotest
[Pipeline] {
[Pipeline] }
[Pipeline] // dir
[Pipeline] git
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url [email protected]:domain/myportal-docker.git
 # timeout=10
Fetching upstream changes from [email protected]:domain/myportal-docker.git
 > git --version # timeout=10
using GIT_SSH to set credentials Jenkins Portal Tests Repo
 > git fetch --tags --progress [email protected]:domain/myportal-docker.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision a5ddc6742c13e3b8c37e7ebda625fd8d89b1386a (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f a5ddc6742c13e3b8c37e7ebda625fd8d89b1386a
 > git branch -a -v --no-abbrev # timeout=10
 > git branch -D master # timeout=10
 > git checkout -b master a5ddc6742c13e3b8c37e7ebda625fd8d89b1386a
Commit message: "Commented out the forum request button test"
 > git rev-list --no-walk a5ddc6742c13e3b8c37e7ebda625fd8d89b1386a # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Run tests)
[Pipeline] sh
[workspace] Running shell script
+ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
[Pipeline] sh
[workspace] Running shell script
+ vendor/bin/codecept --debug run --steps tests/jenkins
Codeception PHP Testing Framework v2.5.2
Powered by PHPUnit 6.5.13 by Sebastian Bergmann and contributors.
Running with seed:

完成上述所有操作后,测试运行正常,但正如此主题所说,而不是最新的代码。

© www.soinside.com 2019 - 2024. All rights reserved.